From b4c4308f99088e6e853d683983f82295bb3cc9f7 Mon Sep 17 00:00:00 2001 From: hflllll Date: Sat, 20 Sep 2025 18:38:54 +0800 Subject: [PATCH] =?UTF-8?q?'=E5=8A=A0=E5=85=A5=E9=9F=B3=E8=89=B2=E9=80=89?= =?UTF-8?q?=E6=8B=A9'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- subPages/home/book.vue | 45 +++++++++++++++++++++++---------------------- subPages/home/music.vue | 5 +++-- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/subPages/home/book.vue b/subPages/home/book.vue index 285db68..81205bf 100644 --- a/subPages/home/book.vue +++ b/subPages/home/book.vue @@ -768,6 +768,7 @@ export default { } } }, + async previousPage() { // 如果正在加载音频,禁止翻页 if (this.isAudioLoading) { @@ -787,27 +788,27 @@ export default { // 清空当前音频状态 this.resetAudioState(); } - }, - async nextPage() { - // 如果正在加载音频,禁止翻页 - if (this.isAudioLoading) { - return; - } + }, + async nextPage() { + // 如果正在加载音频,禁止翻页 + if (this.isAudioLoading) { + return; + } + + if (this.currentPage < this.bookPages.length) { + // 停止当前音频播放 + this.pauseAudio(); - if (this.currentPage < this.bookPages.length) { - // 停止当前音频播放 - this.pauseAudio(); - - this.currentPage++; - // 获取对应页面的数据(如果还没有获取过) - if (this.courseIdList[this.currentPage - 1] && this.bookPages[this.currentPage - 1].length === 0) { - await this.getBookPages(this.courseIdList[this.currentPage - 1]); - } - - // 清空当前音频状态 - this.resetAudioState(); + this.currentPage++; + // 获取对应页面的数据(如果还没有获取过) + if (this.courseIdList[this.currentPage - 1] && this.bookPages[this.currentPage - 1].length === 0) { + await this.getBookPages(this.courseIdList[this.currentPage - 1]); } - }, + + // 清空当前音频状态 + this.resetAudioState(); + } + }, formatTime(seconds) { const mins = Math.floor(seconds / 60); const secs = Math.floor(seconds % 60); @@ -816,7 +817,7 @@ export default { toggleSound() { console.log('音色切换') uni.navigateTo({ - url: '/subPages/home/music' + url: '/subPages/home/music?voiceId=' + this.voiceId }) }, unlockBook() { @@ -931,9 +932,9 @@ export default { }, async onLoad(args) { uni.$on('selectVoice', (voiceId) => { - console.log('收到音色选择:', voiceId); + // console.log('收到音色选择:', voiceId); - this.selectedVoiceId = voiceId + this.voiceId = voiceId }) this.courseId = args.courseId // 重置音频状态 diff --git a/subPages/home/music.vue b/subPages/home/music.vue index a33e57f..efb447b 100644 --- a/subPages/home/music.vue +++ b/subPages/home/music.vue @@ -54,7 +54,7 @@ export default { data() { return { - selectedVoiceId: 2, // 默认选择智小虎 + selectedVoiceId: '', // 默认选择智小虎 voiceList: [ ] @@ -81,7 +81,8 @@ export default { } } }, - onLoad() { + onLoad(options) { + this.selectedVoiceId = options.voiceId this.getVoice() } }