|
|
|
@ -11,12 +11,12 @@ |
|
|
|
|
]" @click="detailInfo.collect = !detailInfo.collect"></view> --> |
|
|
|
|
</view> |
|
|
|
|
<view class="audio-box"> |
|
|
|
|
<view class="audio" :class="{ audioActive: activeAudio === 1 }" @click="activeAudio = 1;"> |
|
|
|
|
<view v-if="detailInfo.enAudio" class="audio" :class="{ audioActive: activeAudio === 1 }" @click="activeAudio = 1;"> |
|
|
|
|
英 <text>{{ detailInfo.enAudio }}</text> |
|
|
|
|
<image v-if="activeAudio !== 1" src="@/static/images/learning/audio.png" mode="aspectFill" @click="openAudio(1)"></image> |
|
|
|
|
<image v-else src="@/static/images/learning/audio_active.png" mode="aspectFill" @click="openAudio(1)"></image> |
|
|
|
|
</view> |
|
|
|
|
<view class="audio" :class="{ audioActive: activeAudio === 2 }" @click="activeAudio = 2;"> |
|
|
|
|
<view v-if="detailInfo.uaAudio" class="audio" :class="{ audioActive: activeAudio === 2 }" @click="activeAudio = 2;"> |
|
|
|
|
美 <text>{{ detailInfo.uaAudio }}</text> |
|
|
|
|
<image v-if="activeAudio !== 2" src="@/static/images/learning/audio.png" mode="aspectFill" @click="openAudio(0)"></image> |
|
|
|
|
<image v-else src="@/static/images/learning/audio_active.png" mode="aspectFill" @click="openAudio(0)"></image> |
|
|
|
@ -90,6 +90,7 @@ |
|
|
|
|
name: '', |
|
|
|
|
allList: [], |
|
|
|
|
chapterId: 0, |
|
|
|
|
audioLoading: false, |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
onLoad({id, subjectId, name}) { |
|
|
|
@ -119,13 +120,31 @@ |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
openAudio(type) { |
|
|
|
|
console.log(`https://dict.youdao.com/dictvoice?type=${type}&audio=${this.detailInfo.name}`, this.audioLoading); |
|
|
|
|
if (this.audioLoading) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
this.audioLoading = true; |
|
|
|
|
const audio = uni.createInnerAudioContext(); |
|
|
|
|
audio.src = `http://dict.youdao.com/dictvoice?type=${type}&audio=${this.detailInfo.name}`; |
|
|
|
|
console.log(`http://dict.youdao.com/dictvoice?type=${type}&audio=${this.detailInfo.name}`); |
|
|
|
|
uni.downloadFile({ |
|
|
|
|
url: `https://dict.youdao.com/dictvoice?type=${type}&audio=${this.detailInfo.name}`, |
|
|
|
|
success: (res) => { |
|
|
|
|
if (res.statusCode === 200) { |
|
|
|
|
console.log('下载成功'); |
|
|
|
|
audio.src = res.tempFilePath; |
|
|
|
|
audio.play(); |
|
|
|
|
this.audioLoading = false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
// audio.src = `https://dict.youdao.com/dictvoice?type=${type}&audio=${this.detailInfo.name}`; |
|
|
|
|
// audio.play(); |
|
|
|
|
audio.onError((res) => { |
|
|
|
|
console.log(res); |
|
|
|
|
}); |
|
|
|
|
// audio.onPlay((res) => { |
|
|
|
|
// console.log(res); |
|
|
|
|
// }) |
|
|
|
|
}, |
|
|
|
|
toNext() { |
|
|
|
|
const index = this.allList.findIndex(v => Number(v.id) === Number(this.id)); |
|
|
|
|