wangxy 2 недель назад
Родитель
Сommit
f44e8066e1

+ 5 - 1
pages/chaojidanci/newEnglish/components/mainCard.vue

@@ -22,7 +22,7 @@
 		</swiper-item>
 		<swiper-item>
 			<view class="swiper-item uni-bg-blue">
-				<selectPageVue :active-word="activeWord" :active-words="activeWords" @play-audio="handlePlayAudio">
+				<selectPageVue :active-word="activeWord" :active-words="activeWords" @play-audio="handlePlayAudio"  @stop-audio="handleStopAudio">
 				</selectPageVue>
 			</view>
 		</swiper-item>
@@ -113,6 +113,10 @@
 			code
 		})
 	}
+	
+	function handleStopAudio() {
+	  emits("stop-audio");
+	}
 
 	function goXiangjie() {
 		emits('goXiangjie')

+ 1 - 0
pages/chaojidanci/newEnglish/components/selectPage.vue

@@ -91,6 +91,7 @@
 
 	function handleSelect(d1) {
 		data.answer = d1;
+		emits('stop-audio');
 		checkIsRight();
 	}
 

+ 0 - 1
pages/chaojidanci/newEnglish/components/useAudio.js

@@ -89,7 +89,6 @@ export class audioPlayer {
 	// 停止播放(释放资源)
 	stop() {
 		audioContext?.stop();
-		audioContext = null;
 	}
 
 }

+ 7 - 0
pages/chaojidanci/newEnglish/index.vue

@@ -8,6 +8,7 @@
       <template v-for="item in data.wordList">
         <mainCardVue :active-word="data.activeWord" :pageData="data" :active-words="activeWords"
                      @play-audio="handlePlayAudio" @goXiangjie="goXiangjie" @swiper-change="handleSwiperChange"
+					 @stop-audio="handleStopAudio"
                      :is-playing="isAudioPlaying" v-if="item.id == data.activeId" :key="item.id">
         </mainCardVue>
       </template>
@@ -258,6 +259,12 @@ async function handlePlayAudio({
     });
   }
 }
+
+function handleStopAudio() {
+  AudioP.stop();
+  isAudioPlaying.value = false;
+  uni.$emit('danci-audio-ended');
+}
 </script>
 
 <style>