|
@@ -38,23 +38,21 @@
|
|
// 使用正则表达式全局替换占位符
|
|
// 使用正则表达式全局替换占位符
|
|
const regex = new RegExp(`\\${placeholder}`, 'g');
|
|
const regex = new RegExp(`\\${placeholder}`, 'g');
|
|
if (!this.isplaying) {
|
|
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,
|
|
result = result.replace(regex,
|
|
`<view class="yingyu-canplay-img" id="${cId}"></view>`
|
|
`<view class="yingyu-canplay-img" id="${cId}"></view>`
|
|
);
|
|
);
|
|
- } else if (this.question.stId == this.isplaying.stId && this.isplaying.index == 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}`
|
|
const cId = this.code ? `t_${this.question.stId}_${index}_${this.code}`:`t_${this.question.stId}_${index}`
|
|
result = result.replace(regex,
|
|
result = result.replace(regex,
|
|
`<view class="yingyu-playing-img" id="${cId}"></view>`
|
|
`<view class="yingyu-playing-img" id="${cId}"></view>`
|
|
);
|
|
);
|
|
} else {
|
|
} 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}`
|
|
- console.log('before',result)
|
|
|
|
result = result.replace(regex,
|
|
result = result.replace(regex,
|
|
`<view class="yingyu-canplay-img" id="${cId}"></view>`
|
|
`<view class="yingyu-canplay-img" id="${cId}"></view>`
|
|
);
|
|
);
|
|
- console.log('after result', result)
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
this.myflag++;
|
|
this.myflag++;
|
|
@@ -87,51 +85,51 @@
|
|
|
|
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- created() {
|
|
|
|
- // 切换不同播放音频时 重置状态
|
|
|
|
- uni.$on('reset-playing-status', (data) => {
|
|
|
|
- if (this.isplaying) {
|
|
|
|
- if (data.stId == this.isplaying.stId && data.index == this.isplaying.index) {
|
|
|
|
|
|
+ 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;
|
|
this.isplaying = null;
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- // 音频播放
|
|
|
|
- uni.$on('yy-audio-playing', (data) => {
|
|
|
|
- if (this.isplaying) {
|
|
|
|
- // 存在播放实例 并且播放非同一音频
|
|
|
|
- if (this.isplaying.stId != data.value.stId) {
|
|
|
|
|
|
+ })
|
|
|
|
+ // 音频自然播放结束 重置音频
|
|
|
|
+ uni.$on('yy-audio-end', (data) => {
|
|
this.isplaying = null;
|
|
this.isplaying = null;
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- // 不存在播放实例
|
|
|
|
- this.isplaying = data;
|
|
|
|
|
|
+ })
|
|
|
|
+ // 音频销毁 重置音频
|
|
|
|
+ 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;
|
|
|
|
+ })
|
|
}
|
|
}
|
|
- })
|
|
|
|
- // 音频异常 重置音频
|
|
|
|
- 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>
|
|
<script module="YY" lang="renderjs">
|
|
<script module="YY" lang="renderjs">
|
|
@@ -187,12 +185,12 @@
|
|
}
|
|
}
|
|
},
|
|
},
|
|
initListener(question) {
|
|
initListener(question) {
|
|
- console.log('init')
|
|
|
|
if (!question) {
|
|
if (!question) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
question.placeholders.forEach((item, index) => {
|
|
question.placeholders.forEach((item, index) => {
|
|
- const cId = this.code ? `t_${this.question.stId}_${index}_${this.code}`:`t_${this.question.stId}_${index}`
|
|
|
|
|
|
+ const cId = this.code ? `t_${question.stId}_${index}_${this.code}` :
|
|
|
|
+ `t_${question.stId}_${index}`
|
|
const dom = document.getElementById(cId)
|
|
const dom = document.getElementById(cId)
|
|
if (dom) {
|
|
if (dom) {
|
|
const qaindex = this.callbacks.findIndex(item => item.index === index)
|
|
const qaindex = this.callbacks.findIndex(item => item.index === index)
|