|
@@ -26,7 +26,7 @@
|
|
|
return {
|
|
|
myflag: 0,
|
|
|
isplaying: null,
|
|
|
- num: 0,
|
|
|
+ isFirst: -1,
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -59,34 +59,43 @@
|
|
|
this.$emit('@itemclick')
|
|
|
},
|
|
|
audioClick(data) {
|
|
|
- if (this.isplaying) {
|
|
|
- uni.$emit('do-yy-audio-stop', data);
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (this.isFirst >= 0) {
|
|
|
+ uni.$emit('do-yy-audio-stop', data);
|
|
|
+ this.isFirst = -1
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- // 重复播放
|
|
|
- if (this.isplaying && data.stId == this.isplaying.stId && data.index == this.isplaying.index) {
|
|
|
- uni.$emit('do-yy-audio-stop', data);
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (this.isplaying) {
|
|
|
+ uni.$emit('do-yy-audio-stop', data);
|
|
|
+ this.isFirst++;
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
// 初次播放
|
|
|
if (!this.isplaying) {
|
|
|
- uni.$emit('do-yy-audio-play', data);
|
|
|
- return;
|
|
|
+ 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) => {
|
|
|
- console.log('ccc1')
|
|
|
if (this.isplaying) {
|
|
|
// 存在播放实例 并且播放非同一音频
|
|
|
if (this.isplaying.stId != data.value.stId) {
|
|
|
this.isplaying = null;
|
|
|
- }
|
|
|
+ }
|
|
|
} else {
|
|
|
// 不存在播放实例
|
|
|
this.isplaying = data;
|