Ver Fonte

音频修改

jwyu há 2 anos atrás
pai
commit
348a6aea6a

+ 6 - 2
pages-report/components/audioBox.vue

@@ -82,11 +82,13 @@ export default {
             let curAudio=this.$store.state.report.audioData.list[this.$store.state.report.audioData.index]
             if(this.globalBgMusic.src){
                 console.log(this.globalBgMusic);
+                console.log(type);
                 if(type==='change'){
                     this.globalBgMusic.src=curAudio.video_url
                     this.globalBgMusic.title=curAudio.video_name
                 }else{
                     this.currentTime=parseInt(this.globalBgMusic.currentTime)
+                    this.play=!this.globalBgMusic.paused
                 }
             }else{
                 this.globalBgMusic.src=curAudio.video_url
@@ -101,9 +103,11 @@ export default {
         handleAudioFun(){
             this.globalBgMusic.onPlay(()=>{
                 this.play=true
+                this.$store.commit('updateAudioPause',false)
             })
             this.globalBgMusic.onPause(()=>{
                 this.play=false
+                this.$store.commit('updateAudioPause',true)
             })
             this.globalBgMusic.onStop(()=>{
                 this.$store.commit('removeAudio')
@@ -147,13 +151,13 @@ export default {
                 if(temIndex>0){
                     let index=temIndex-1
                     this.$store.commit('updateAudioIndex', index)
-                    this.init()
+                    this.init('change')
                 }
             }else{
                 if(temIndex<this.$store.state.report.audioData.list.length-1){
                     let index=temIndex+1
                     this.$store.commit('updateAudioIndex', index)
-                    this.init()
+                    this.init('change')
                 }
             }
         },

+ 18 - 3
pages-report/reportList.vue

@@ -22,8 +22,8 @@
           <view class="tips" v-html="item.abstract"></view>
           <view class="time">{{item.publish_time|formatReportTime}}</view>
           <view :class="['audio-box',!item.auth_ok&&'grey-audio-box']" @click.stop="handleClickAudio(item)">
-            <image src="./static/audio.png" mode="aspectFill"/>
-            <text>播放</text>
+            <image :src="curAudioReportId==item.report_id&&!curAudioPaused?'./static/audio-s.png':'./static/audio.png'" mode="aspectFill"/>
+            <text>{{curAudioReportId==item.report_id&&!curAudioPaused?'暂停':'播放'}}</text>
           </view>
         </view>
       </view>
@@ -62,6 +62,12 @@ export default {
   computed: {
     showAudioPop(){//是否显示音频弹窗
       return this.$store.state.report.audioData.show 
+    },
+    curAudioReportId(){//当前播放的音频所属报告
+      return this.$store.state.report.audioData.reportId
+    },
+    curAudioPaused(){//当前音频是否暂停状态
+      return this.$store.state.report.audioData.paused
     }
   },
   components: {
@@ -174,7 +180,16 @@ export default {
         })
         return
       }
-      this.$store.commit('addAudio', item.video_list)
+      // 判断是否为同一个音频
+      if(this.$store.state.report.audioData.reportId==item.report_id){
+        if(this.globalBgMusic.paused){
+          this.globalBgMusic.play()
+        }else{
+          this.globalBgMusic.pause()
+        }
+      }else{
+        this.$store.commit('addAudio', {list:item.video_list,reportId:item.report_id})
+      }
     }
 
   },

+ 23 - 4
pages-report/specialColumn/detail.vue

@@ -5,7 +5,7 @@
             <image :src="info.avatar_img_url" mode="aspectFill" class="avatar"/>
             <view class="user-name">
                 <text>{{info.report_author}}</text>
-                <text class="tag" v-if="vip_title">{{info.vip_title}}</text>
+                <text class="tag" v-if="info.vip_title">{{info.vip_title}}</text>
             </view>
             <view class="user-title">{{info.author_descript}}</view>
             <view class="user-intro">{{info.abstract}}</view>
@@ -27,8 +27,8 @@
                     <view class="van-ellipsis tips">摘要:{{item.abstract}}</view>
                     <view class="time">{{item.publish_time|formatReportTime}}</view>
                     <view :class="['audio-box',!info.auth_ok&&'grey-audio-box']" @click.stop="handleClickAudio(item)">
-                        <image src="../static/audio.png" mode="aspectFill"/>
-                        <text>播放</text>
+                        <image :src="curAudioReportId==item.report_id&&!curAudioPaused?'../static/audio-s.png':'../static/audio.png'" mode="aspectFill"/>
+                        <text>{{curAudioReportId==item.report_id&&!curAudioPaused?'暂停':'播放'}}</text>
                     </view>
                 </view>
             </view>
@@ -47,6 +47,12 @@ export default {
     computed: {
         showAudioPop(){//是否显示音频弹窗
             return this.$store.state.report.audioData.show 
+        },
+        curAudioReportId(){//当前播放的音频所属报告
+            return this.$store.state.report.audioData.reportId
+        },
+        curAudioPaused(){//当前音频是否暂停状态
+            return this.$store.state.report.audioData.paused
         }
     },
     components: {
@@ -137,7 +143,20 @@ export default {
                 })
                 return
             }
-            this.$store.commit('addAudio', [{video_url:item.video_url,video_name:item.video_name,video_play_seconds:item.video_play_seconds}])
+            // 判断是否为同一个音频
+            if(this.$store.state.report.audioData.reportId==item.report_id){
+                if(this.globalBgMusic.paused){
+                    this.globalBgMusic.play()
+                }else{
+                    this.globalBgMusic.pause()
+                }
+            }else{
+                this.$store.commit('addAudio', {
+                    list:[{video_url:item.video_url,video_name:item.video_name,video_play_seconds:item.video_play_seconds}],
+                    reportId:item.report_id
+                })
+            }
+            
         }
     }
 }

BIN
pages-report/static/audio-s.png


+ 9 - 1
store/modules/report.js

@@ -4,21 +4,29 @@ const reportModules={
             show:false,//是否显示音频弹窗
             list:[],
             index:0,//当前是播放第几个
+            reportId:0,//当前是哪个报告的音频
+            paused:true,//当前是否音频正在播放 true暂停状态
         }
     },
     mutations: {
         addAudio(state,e){
             state.audioData.show=true
-            state.audioData.list=e
+            state.audioData.list=e.list
             state.audioData.index=0
+            state.audioData.reportId=e.reportId
         },
         updateAudioIndex(state,e){
             state.audioData.index=e
         },
+        updateAudioPause(state,e){
+            state.audioData.paused=e
+        },
         removeAudio(state,e){
             state.audioData.show=false
             state.audioData.list=[]
             state.audioData.index=0
+            state.audioData.reportId=0
+            state.audioData.paused=true
         }
     }
 }