|
@@ -205,7 +205,9 @@ import {
|
|
|
apiActivityCancelRemind,
|
|
|
apiActivityRegister,
|
|
|
apiActivityCancelRegister,
|
|
|
- apiActivityAudios
|
|
|
+ apiActivityAudios,
|
|
|
+ apiActivityAudioPlayRecordAdd,
|
|
|
+ apiActivityAudioPlayRecordUpate
|
|
|
} from '@/api/activity'
|
|
|
import {apiApplyPermission,apiUserInfo} from '@/api/user'
|
|
|
import sharePoster from '../../components/sharePoster/sharePoster.vue'
|
|
@@ -309,6 +311,7 @@ export default {
|
|
|
audioCurrentTime:0,//音频播放实时时间
|
|
|
audioTime:0,//当前音频时间
|
|
|
audioCurrentUrl:'',//当前音频地址
|
|
|
+ recordId:0,//新增音频播放记录成功的id
|
|
|
},
|
|
|
|
|
|
showPoster:true
|
|
@@ -377,6 +380,31 @@ export default {
|
|
|
const endTime=moment(end).format('HH:mm');
|
|
|
return `${day} ${startTime}-${endTime} ${week}`
|
|
|
},
|
|
|
+
|
|
|
+ //新增音频播放统计
|
|
|
+ async handleAudioPlayRecordAdd(primary_id,extend_id){
|
|
|
+ const res=await apiActivityAudioPlayRecordAdd({
|
|
|
+ primary_id:Number(primary_id),
|
|
|
+ extend_id:Number(extend_id),
|
|
|
+ from_page:'活动列表'
|
|
|
+ })
|
|
|
+ if(res.code===200){
|
|
|
+ console.log('新增音频播放记录成功');
|
|
|
+ this.currentAudioMsg.recordId=res.data.id
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ //更新音频播放记录
|
|
|
+ async handleAudioPlayRecordUpdate(){
|
|
|
+ const res=await apiActivityAudioPlayRecordUpate({
|
|
|
+ id:Number(this.currentAudioMsg.recordId),
|
|
|
+ stop_seconds:Number(this.currentAudioMsg.audioCurrentTime)
|
|
|
+ })
|
|
|
+ if(res.code===200){
|
|
|
+ console.log('更新音频播放记录成功');
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
// 初始化音频状态
|
|
|
initAudio(){
|
|
|
console.log('音频src',this.globalBgMusic.src);
|
|
@@ -396,6 +424,7 @@ export default {
|
|
|
audioCurrentTime:0,//音频播放实时时间
|
|
|
audioTime:0,//当前音频时间
|
|
|
audioCurrentUrl:'',//当前音频地址
|
|
|
+ recordId:0
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -408,6 +437,10 @@ export default {
|
|
|
if(this.currentAudioMsg.activityId!=item.activityId){
|
|
|
const res=await apiActivityAudios({activity_id: Number(item.activityId)})
|
|
|
if(res.code===200){
|
|
|
+ // 如果当前有其他的在播放则要掉一次更新
|
|
|
+ if(this.currentAudioMsg.activityId){
|
|
|
+ this.handleAudioPlayRecordUpdate()
|
|
|
+ }
|
|
|
if(res.data){
|
|
|
this.currentAudioMsg.activityId=item.activityId
|
|
|
this.currentAudioMsg.list=res.data
|
|
@@ -459,6 +492,7 @@ export default {
|
|
|
|
|
|
// 播放音频
|
|
|
handlePlayAudio(item){
|
|
|
+ this.handleAudioPlayRecordAdd(item.activity_voice_id,item.activityId)
|
|
|
this.globalBgMusic.src=item.voiceUrl
|
|
|
this.globalBgMusic.title=item.voiceName
|
|
|
|
|
@@ -480,14 +514,16 @@ export default {
|
|
|
this.currentAudioMsg.play=false
|
|
|
})
|
|
|
this.globalBgMusic.onStop(()=>{
|
|
|
- this.currentAudioMsg.play=false
|
|
|
+ console.log('stop',this.currentAudioMsg);
|
|
|
+ this.handleAudioPlayRecordUpdate()
|
|
|
this.currentAudioMsg.play=false
|
|
|
this.currentAudioMsg.audioCurrentTime=0
|
|
|
this.currentAudioMsg.audioTime=0
|
|
|
this.currentAudioMsg.audioCurrentUrl=0
|
|
|
})
|
|
|
this.globalBgMusic.onEnded(()=>{
|
|
|
- console.log('onEnded');
|
|
|
+ console.log('onEnded',this.currentAudioMsg);
|
|
|
+ this.handleAudioPlayRecordUpdate()
|
|
|
this.currentAudioMsg.play=false
|
|
|
this.handleAudioBtn('next','auto')
|
|
|
})
|
|
@@ -518,6 +554,7 @@ export default {
|
|
|
}
|
|
|
if(type==='before'){
|
|
|
if(!this.isFirstAudio){
|
|
|
+ this.handleAudioPlayRecordUpdate()
|
|
|
this.currentAudioMsg.list.forEach((_item,index)=>{
|
|
|
if(_item.voiceUrl==this.currentAudioMsg.audioCurrentUrl){
|
|
|
this.handlePlayAudio(this.currentAudioMsg.list[index-1])
|
|
@@ -528,6 +565,7 @@ export default {
|
|
|
|
|
|
if(type==='next'){
|
|
|
if(!this.isLastAudio){
|
|
|
+ this.handleAudioPlayRecordUpdate()
|
|
|
this.currentAudioMsg.list.forEach((_item,index)=>{
|
|
|
if(_item.voiceUrl==this.currentAudioMsg.audioCurrentUrl){
|
|
|
this.handlePlayAudio(this.currentAudioMsg.list[index+1])
|