浏览代码

英语题追加音频播放

wangxy 4 月之前
父节点
当前提交
a444f1ee75
共有 1 个文件被更改,包括 50 次插入49 次删除
  1. 50 49
      components/question/yingyu/textReplaceIcon.vue

+ 50 - 49
components/question/yingyu/textReplaceIcon.vue

@@ -39,17 +39,21 @@
 					const regex = new RegExp(`\\${placeholder}`, 'g');
 					if (!this.isplaying) {
 
-						const cId = this.code ? `t_${this.question.stId}_${index}_${this.code}`:`t_${this.question.stId}_${index}`
+						const cId = this.code ? `t_${this.question.stId}_${index}_${this.code}` :
+							`t_${this.question.stId}_${index}`
 						result = result.replace(regex,
 							`<view	class="yingyu-canplay-img" id="${cId}"></view>`
 						);
-					} else if (this.isplaying && this.question.stId == this.isplaying.stId && this.isplaying.index == index) {
-						const cId = this.code ? `t_${this.question.stId}_${index}_${this.code}`:`t_${this.question.stId}_${index}`
+					} else if (this.isplaying && this.question.stId == this.isplaying.stId && this.isplaying
+						.index == index) {
+						const cId = this.code ? `t_${this.question.stId}_${index}_${this.code}` :
+							`t_${this.question.stId}_${index}`
 						result = result.replace(regex,
 							`<view	class="yingyu-playing-img" id="${cId}"></view>`
 						);
 					} else {
-						const cId = this.code ? `t_${this.question.stId}_${index}_${this.code}`:`t_${this.question.stId}_${index}`
+						const cId = this.code ? `t_${this.question.stId}_${index}_${this.code}` :
+							`t_${this.question.stId}_${index}`
 						result = result.replace(regex,
 							`<view	class="yingyu-canplay-img" id="${cId}"></view>`
 						);
@@ -69,67 +73,64 @@
 					this.isFirst = -1
 					return;
 				}
-
 				if (this.isplaying) {
 					uni.$emit('do-yy-audio-stop', data);
 					this.isFirst++;
 					return;
 				}
-
 				// 初次播放
 				if (!this.isplaying) {
 					uni.$emit('do-yy-audio-play', data);
 					this.isFirst++;
 					return;
 				}
-
 			}
 		},
-				created() {
-					// 切换不同播放音频时 重置状态
-					uni.$on('reset-playing-status', (data) => {
-						if (this.isplaying) {
-							if (data.stId == this.isplaying.stId && data.index == this.isplaying.index) {
-								this.isplaying = null;
-							}
-						}
-					})
-					// 音频播放
-					uni.$on('yy-audio-playing', (data) => {
-						if (this.isplaying) {
-							// 存在播放实例 并且播放非同一音频
-							if (this.isplaying.stId != data.value.stId) {
-								this.isplaying = null;
-							}
-						} else {
-							// 不存在播放实例 
-							this.isplaying = data;
-						}
-					})
-					// 音频异常  重置音频
-					uni.$on('yy-audio-error', (data) => {
-						this.isplaying = null;
-					})
-					// 音频自然播放结束  重置音频
-					uni.$on('yy-audio-end', (data) => {
-						this.isplaying = null;
-					})
-					// 音频销毁 重置音频
-					uni.$on('destory-stop', (data) => {
-						this.isplaying = null;
-					})
-					// 试题切换 重置音频
-					uni.$on('swiper-change', () => {
-						this.isplaying = null;
-					})
-					// 解析关闭 重置音频
-					uni.$on('question-jiexi-close', () => {
+		created() {
+			// 切换不同播放音频时 重置状态
+			uni.$on('reset-playing-status', (data) => {
+				if (this.isplaying) {
+					if (data.stId == this.isplaying.stId && data.index == this.isplaying.index) {
 						this.isplaying = null;
-					})
-					uni.$on('unitTest-submit', () => {
+					}
+				}
+			})
+			// 音频播放
+			uni.$on('yy-audio-playing', (data) => {
+				if (this.isplaying) {
+					// 存在播放实例 并且播放非同一音频
+					if (this.isplaying.stId != data.value.stId) {
 						this.isplaying = null;
-					})
+					}
+				} else {
+					// 不存在播放实例 
+					this.isplaying = data;
 				}
+			})
+			// 音频异常  重置音频
+			uni.$on('yy-audio-error', (data) => {
+				this.isplaying = null;
+			})
+			// 音频自然播放结束  重置音频
+			uni.$on('yy-audio-end', (data) => {
+				this.isplaying = null;
+			})
+			// 音频销毁 重置音频
+			uni.$on('destory-stop', (data) => {
+				this.isplaying = null;
+			})
+			// 试题切换 重置音频
+			uni.$on('swiper-change', () => {
+				this.isplaying = null;
+			})
+			// 解析关闭 重置音频
+			uni.$on('question-jiexi-close', () => {
+				this.isplaying = null;
+			})
+			uni.$on('unitTest-submit', () => {
+				this.isplaying = null;
+			})
+		}
 	}
 </script>
 <script module="YY" lang="renderjs">