|
|
|
@ -364,36 +364,36 @@ export default { |
|
|
|
|
|
|
|
// 处理文本点击事件 |
|
|
|
handleTextClick(textContent, item, pageIndex) { |
|
|
|
console.log('🎯 ===== 文本点击事件开始 ====='); |
|
|
|
console.log('📝 点击文本:', textContent); |
|
|
|
console.log('📄 textContent类型:', typeof textContent); |
|
|
|
console.log('❓ textContent是否为undefined:', textContent === undefined); |
|
|
|
console.log('📦 完整item对象:', item); |
|
|
|
console.log('📝 item.content:', item ? item.content : 'item为空'); |
|
|
|
console.log('📖 当前页面索引:', this.currentPage); |
|
|
|
console.log('👆 点击的页面索引:', pageIndex); |
|
|
|
console.log('📊 当前页面类型:', this.currentPageType); |
|
|
|
console.log('📄 是否为文本页面:', this.isTextPage); |
|
|
|
console.log('📋 当前页面数据:', this.bookPages[this.currentPage - 1]); |
|
|
|
console.log('📏 页面数据长度:', this.bookPages[this.currentPage - 1] ? this.bookPages[this.currentPage - 1].length : '页面不存在'); |
|
|
|
// console.log('🎯 ===== 文本点击事件开始 ====='); |
|
|
|
// console.log('📝 点击文本:', textContent); |
|
|
|
// console.log('📄 textContent类型:', typeof textContent); |
|
|
|
// console.log('❓ textContent是否为undefined:', textContent === undefined); |
|
|
|
// console.log('📦 完整item对象:', item); |
|
|
|
// console.log('📝 item.content:', item ? item.content : 'item为空'); |
|
|
|
// console.log('📖 当前页面索引:', this.currentPage); |
|
|
|
// console.log('👆 点击的页面索引:', pageIndex); |
|
|
|
// console.log('📊 当前页面类型:', this.currentPageType); |
|
|
|
// console.log('📄 是否为文本页面:', this.isTextPage); |
|
|
|
// console.log('📋 当前页面数据:', this.bookPages[this.currentPage - 1]); |
|
|
|
// console.log('📏 页面数据长度:', this.bookPages[this.currentPage - 1] ? this.bookPages[this.currentPage - 1].length : '页面不存在'); |
|
|
|
|
|
|
|
// 检查音频播放状态 |
|
|
|
console.log('🎵 ===== 音频状态检查 ====='); |
|
|
|
console.log(' isWordAudioPlaying:', this.isWordAudioPlaying); |
|
|
|
console.log(' currentWordAudio存在:', !!this.currentWordAudio); |
|
|
|
console.log(' currentWordMeaning存在:', !!this.currentWordMeaning); |
|
|
|
// console.log('🎵 ===== 音频状态检查 ====='); |
|
|
|
// console.log(' isWordAudioPlaying:', this.isWordAudioPlaying); |
|
|
|
// console.log(' currentWordAudio存在:', !!this.currentWordAudio); |
|
|
|
// console.log(' currentWordMeaning存在:', !!this.currentWordMeaning); |
|
|
|
|
|
|
|
if (this.isWordAudioPlaying) { |
|
|
|
console.log('⚠️ 检测到单词音频正在播放状态,这可能会阻止句子音频播放'); |
|
|
|
console.log('🔄 尝试重置音频播放状态...'); |
|
|
|
// console.log('⚠️ 检测到单词音频正在播放状态,这可能会阻止句子音频播放'); |
|
|
|
// console.log('🔄 尝试重置音频播放状态...'); |
|
|
|
this.isWordAudioPlaying = false; |
|
|
|
console.log('✅ 音频播放状态已重置'); |
|
|
|
// console.log('✅ 音频播放状态已重置'); |
|
|
|
} |
|
|
|
|
|
|
|
// 检查是否点击的是当前页面 |
|
|
|
if (pageIndex !== undefined && pageIndex !== this.currentPage - 1) { |
|
|
|
console.warn('⚠️ 点击的不是当前页面,忽略点击事件'); |
|
|
|
console.log(` 期望页面: ${this.currentPage - 1}, 点击页面: ${pageIndex}`); |
|
|
|
// console.log(` 期望页面: ${this.currentPage - 1}, 点击页面: ${pageIndex}`); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
@ -410,16 +410,16 @@ export default { |
|
|
|
// 如果textContent为undefined,尝试从item中获取 |
|
|
|
if (!textContent && item && item.content) { |
|
|
|
textContent = item.content; |
|
|
|
console.log('🔄 从item中获取到content:', textContent); |
|
|
|
// console.log('🔄 从item中获取到content:', textContent); |
|
|
|
} |
|
|
|
|
|
|
|
// 最终验证textContent |
|
|
|
if (!textContent || typeof textContent !== 'string' || textContent.trim() === '') { |
|
|
|
console.error('❌ handleTextClick: 无效的文本内容', textContent); |
|
|
|
console.log(' textContent:', textContent); |
|
|
|
console.log(' 类型:', typeof textContent); |
|
|
|
console.log(' 是否为空字符串:', textContent === ''); |
|
|
|
console.log(' trim后是否为空:', textContent && textContent.trim() === ''); |
|
|
|
// console.log(' textContent:', textContent); |
|
|
|
// console.log(' 类型:', typeof textContent); |
|
|
|
// console.log(' 是否为空字符串:', textContent === ''); |
|
|
|
// console.log(' trim后是否为空:', textContent && textContent.trim() === ''); |
|
|
|
uni.showToast({ |
|
|
|
title: '文本内容无效', |
|
|
|
icon: 'none' |
|
|
|
@ -427,13 +427,13 @@ export default { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
console.log('✅ 文本内容验证通过:', textContent); |
|
|
|
console.log(' 文本长度:', textContent.length); |
|
|
|
console.log(' 文本预览:', textContent.substring(0, 50) + (textContent.length > 50 ? '...' : '')); |
|
|
|
// console.log('✅ 文本内容验证通过:', textContent); |
|
|
|
// console.log(' 文本长度:', textContent.length); |
|
|
|
// console.log(' 文本预览:', textContent.substring(0, 50) + (textContent.length > 50 ? '...' : '')); |
|
|
|
|
|
|
|
// 检查是否有音频控制组件的引用 |
|
|
|
console.log('🔍 检查音频控制组件引用...'); |
|
|
|
console.log(' customTabbar存在:', !!this.$refs.customTabbar); |
|
|
|
// console.log('🔍 检查音频控制组件引用...'); |
|
|
|
// console.log(' customTabbar存在:', !!this.$refs.customTabbar); |
|
|
|
|
|
|
|
if (!this.$refs.customTabbar) { |
|
|
|
console.error('❌ customTabbar引用不存在'); |
|
|
|
@ -444,7 +444,7 @@ export default { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
console.log(' audioControls存在:', !!this.$refs.customTabbar.$refs.audioControls); |
|
|
|
// console.log(' audioControls存在:', !!this.$refs.customTabbar.$refs.audioControls); |
|
|
|
|
|
|
|
if (!this.$refs.customTabbar.$refs.audioControls) { |
|
|
|
console.error('❌ audioControls引用不存在'); |
|
|
|
@ -460,6 +460,15 @@ export default { |
|
|
|
console.log('🔍 检查页面类型支持...'); |
|
|
|
console.log(' isTextPage:', this.isTextPage); |
|
|
|
console.log(' currentPageType:', this.currentPageType); |
|
|
|
console.log(' 当前页面索引:', this.currentPage); |
|
|
|
console.log(' 页面类型数组:', this.pageTypes); |
|
|
|
|
|
|
|
// 特别针对划线重点页面的调试 |
|
|
|
if (this.currentPageType === '1') { |
|
|
|
console.log('📝 当前是划线重点页面,点击的文本:', textContent); |
|
|
|
console.log('📝 文本长度:', textContent.length); |
|
|
|
console.log('📝 文本前50字符:', textContent.substring(0, 50)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!this.isTextPage && this.currentPageType !== '1') { |
|
|
|
console.warn('⚠️ 当前页面不是文本页面或卡片页面'); |
|
|
|
@ -475,31 +484,94 @@ export default { |
|
|
|
|
|
|
|
// 获取音频控制组件实例 |
|
|
|
const audioControls = this.$refs.customTabbar.$refs.audioControls; |
|
|
|
console.log('🎵 音频控制组件状态:'); |
|
|
|
console.log(' currentPageAudios存在:', !!audioControls.currentPageAudios); |
|
|
|
console.log(' currentPageAudios长度:', audioControls.currentPageAudios ? audioControls.currentPageAudios.length : 0); |
|
|
|
console.log(' isAudioLoading:', audioControls.isAudioLoading); |
|
|
|
console.log(' currentAudioIndex:', audioControls.currentAudioIndex); |
|
|
|
console.log(' isPlaying:', audioControls.isPlaying); |
|
|
|
|
|
|
|
// 检查音频是否正在加载中 |
|
|
|
if (audioControls.isAudioLoading) { |
|
|
|
console.log('⏳ 音频正在加载中,等待加载完成后再播放'); |
|
|
|
uni.showToast({ |
|
|
|
title: '音频正在加载中,请稍后再试', |
|
|
|
icon: 'loading', |
|
|
|
duration: 1500 |
|
|
|
}); |
|
|
|
|
|
|
|
// 等待音频加载完成后自动播放 |
|
|
|
const checkAndPlay = () => { |
|
|
|
if (!audioControls.isAudioLoading && audioControls.currentPageAudios.length > 0) { |
|
|
|
console.log('✅ 音频加载完成,开始播放指定音频'); |
|
|
|
const success = audioControls.playSpecificAudio(textContent); |
|
|
|
if (!success) { |
|
|
|
console.error('❌ 音频加载完成后播放失败'); |
|
|
|
} |
|
|
|
} else if (!audioControls.isAudioLoading) { |
|
|
|
console.error('❌ 音频加载完成但没有音频数据'); |
|
|
|
uni.showToast({ |
|
|
|
title: '当前页面没有音频内容', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// 继续等待 |
|
|
|
setTimeout(checkAndPlay, 500); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// 延迟检查,给音频加载一些时间 |
|
|
|
setTimeout(checkAndPlay, 1000); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 检查是否有音频数据 |
|
|
|
if (!audioControls.currentPageAudios || audioControls.currentPageAudios.length === 0) { |
|
|
|
console.warn('⚠️ 当前页面没有音频数据,尝试重新加载'); |
|
|
|
uni.showToast({ |
|
|
|
title: '正在重新加载音频...', |
|
|
|
icon: 'loading' |
|
|
|
}); |
|
|
|
|
|
|
|
// 尝试重新加载音频 |
|
|
|
audioControls.getCurrentPageAudio(); |
|
|
|
|
|
|
|
// 等待重新加载完成后播放 |
|
|
|
const retryPlay = () => { |
|
|
|
if (!audioControls.isAudioLoading && audioControls.currentPageAudios.length > 0) { |
|
|
|
console.log('✅ 音频重新加载完成,开始播放'); |
|
|
|
const success = audioControls.playSpecificAudio(textContent); |
|
|
|
if (!success) { |
|
|
|
console.error('❌ 音频重新加载后播放失败'); |
|
|
|
} |
|
|
|
} else if (!audioControls.isAudioLoading) { |
|
|
|
console.error('❌ 音频重新加载失败'); |
|
|
|
uni.showToast({ |
|
|
|
title: '音频加载失败,请检查网络连接', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// 继续等待 |
|
|
|
setTimeout(retryPlay, 500); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
setTimeout(retryPlay, 1500); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 调用AudioControls组件的播放指定音频方法 |
|
|
|
console.log('🚀 调用 playSpecificAudio...'); |
|
|
|
console.log('🚀 调用 playSpecificAudio,音频数据长度:', audioControls.currentPageAudios.length); |
|
|
|
const success = audioControls.playSpecificAudio(textContent); |
|
|
|
|
|
|
|
console.log('🎵 playSpecificAudio 返回结果:', success); |
|
|
|
// console.log('🎵 playSpecificAudio 返回结果:', success); |
|
|
|
|
|
|
|
if (success) { |
|
|
|
console.log('✅ 成功播放指定音频段落'); |
|
|
|
// console.log('✅ 成功播放指定音频段落'); |
|
|
|
} else { |
|
|
|
console.error('❌ 播放指定音频段落失败'); |
|
|
|
console.log('💡 失败可能原因:'); |
|
|
|
console.log(' 1. 文本内容与音频数据不匹配'); |
|
|
|
console.log(' 2. 音频数据尚未加载完成'); |
|
|
|
console.log(' 3. 音频文件路径错误或文件损坏'); |
|
|
|
console.log(' 4. 网络连接问题'); |
|
|
|
// console.log('💡 失败可能原因:'); |
|
|
|
// console.log(' 1. 文本内容与音频数据不匹配'); |
|
|
|
// console.log(' 2. 音频数据尚未加载完成'); |
|
|
|
// console.log(' 3. 音频文件路径错误或文件损坏'); |
|
|
|
// console.log(' 4. 网络连接问题'); |
|
|
|
} |
|
|
|
|
|
|
|
console.log('🎯 ===== 文本点击事件结束 ====='); |
|
|
|
// console.log('🎯 ===== 文本点击事件结束 ====='); |
|
|
|
}, |
|
|
|
|
|
|
|
onHighlightChange(highlightData) { |
|
|
|
@ -513,13 +585,13 @@ export default { |
|
|
|
|
|
|
|
// 可以在这里处理分段音频的额外信息 |
|
|
|
if (highlightData.isSegmented) { |
|
|
|
console.log('分段音频高亮:', { |
|
|
|
highlightIndex: highlightData.highlightIndex, |
|
|
|
segmentIndex: highlightData.segmentIndex, |
|
|
|
startIndex: highlightData.startIndex, |
|
|
|
endIndex: highlightData.endIndex, |
|
|
|
currentText: highlightData.currentText |
|
|
|
}); |
|
|
|
// console.log('分段音频高亮:', { |
|
|
|
// highlightIndex: highlightData.highlightIndex, |
|
|
|
// segmentIndex: highlightData.segmentIndex, |
|
|
|
// startIndex: highlightData.startIndex, |
|
|
|
// endIndex: highlightData.endIndex, |
|
|
|
// currentText: highlightData.currentText |
|
|
|
// }); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 清除高亮 |
|
|
|
@ -532,10 +604,10 @@ export default { |
|
|
|
async getVoiceList() { |
|
|
|
const voiceRes = await this.$api.music.list() |
|
|
|
if(voiceRes.code === 200){ |
|
|
|
console.log('音色列表API返回:', voiceRes.result); |
|
|
|
console.log('第一个音色数据:', voiceRes.result[0]); |
|
|
|
// console.log('音色列表API返回:', voiceRes.result); |
|
|
|
// console.log('第一个音色数据:', voiceRes.result[0]); |
|
|
|
this.voiceId = Number(voiceRes.result[0].voiceType) |
|
|
|
console.log('获取默认音色ID:', this.voiceId, '类型:', typeof this.voiceId); |
|
|
|
// console.log('获取默认音色ID:', this.voiceId, '类型:', typeof this.voiceId); |
|
|
|
} |
|
|
|
}, |
|
|
|
toggleNavbar() { |
|
|
|
|