|
@@ -2,8 +2,12 @@ import { createStore } from "vuex";
|
|
|
import {ElMessage} from 'element-plus'
|
|
|
import {apiUserInfo} from '@/api/user.js'
|
|
|
import {apiActivityAudioPlayRecordAdd,apiActivityAudioPlayRecordUpate} from '@/api/activity'
|
|
|
+import {apiViewLogUpdate} from '@/api/common'
|
|
|
+import{apiCountAudioClick}from '@/api/question'
|
|
|
+import {apiVoicePlayRecord} from '@/api/voice'
|
|
|
|
|
|
let lastActivityAudioRecordId=0//上次新曾活动音频记录时的id
|
|
|
+let lastAudioRecordId=0//上次问答社区\语音播报 音频记录id
|
|
|
|
|
|
const token=localStorage.getItem('token')||''
|
|
|
let platform='web'
|
|
@@ -72,6 +76,19 @@ export default createStore({
|
|
|
|
|
|
// 设置音频播放
|
|
|
addAudio(state,e){
|
|
|
+ // 更新活动音频播放时长
|
|
|
+ if(state.audioData.activityId!=0&&lastActivityAudioRecordId!=0){
|
|
|
+ handleActivityAudioRecordUpdate(state.audioData)
|
|
|
+ }
|
|
|
+ // 更新问答\语音播报 音频播放时长
|
|
|
+ if(lastAudioRecordId!=0){
|
|
|
+ if(state.audioData.voiceId!=0){
|
|
|
+ handleAudioRecordUpdate({audioCurrentTime:state.audioData.audioCurrentTime,source:2})
|
|
|
+ }
|
|
|
+ if(state.audioData.questionId!=0){
|
|
|
+ handleAudioRecordUpdate({audioCurrentTime:state.audioData.audioCurrentTime,source:1})
|
|
|
+ }
|
|
|
+ }
|
|
|
state.audioData.index=e.index
|
|
|
state.audioData.list=e.list
|
|
|
state.audioData.activityId=e.activityId||0
|
|
@@ -81,11 +98,14 @@ export default createStore({
|
|
|
state.audioData.show=true
|
|
|
state.audioData.INS.play()
|
|
|
if(state.audioData.activityId!=0){
|
|
|
- if(lastActivityAudioRecordId!=0){
|
|
|
- handleActivityAudioRecordUpdate(state.audioData)
|
|
|
- }
|
|
|
handleActivityAudioRecordAdd(state.audioData)
|
|
|
}
|
|
|
+ if(state.audioData.voiceId!=0){
|
|
|
+ handleVoiceAudioRecordAdd(state.audioData)
|
|
|
+ }
|
|
|
+ if(state.audioData.questionId!=0){
|
|
|
+ handleQuestionAudioRecordAdd(state.audioData)
|
|
|
+ }
|
|
|
},
|
|
|
//切换音频
|
|
|
changeAudio(state,e){
|
|
@@ -96,7 +116,25 @@ export default createStore({
|
|
|
if(state.audioData.activityId!=0){
|
|
|
handleActivityAudioRecordUpdate(state.audioData)
|
|
|
}
|
|
|
+ if(state.audioData.voiceId!=0){
|
|
|
+ handleAudioRecordUpdate({audioCurrentTime:state.audioData.audioCurrentTime,source:2})
|
|
|
+ }
|
|
|
+ if(state.audioData.questionId!=0){
|
|
|
+ handleAudioRecordUpdate({audioCurrentTime:state.audioData.audioCurrentTime,source:1})
|
|
|
+ }
|
|
|
+
|
|
|
state.audioData.index--
|
|
|
+
|
|
|
+ if(state.audioData.activityId!=0){
|
|
|
+ handleActivityAudioRecordAdd(state.audioData)
|
|
|
+ }
|
|
|
+ if(state.audioData.voiceId!=0){
|
|
|
+ handleVoiceAudioRecordAdd(state.audioData)
|
|
|
+ }
|
|
|
+ if(state.audioData.questionId!=0){
|
|
|
+ handleQuestionAudioRecordAdd(state.audioData)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}else if(e==='next'){//点击按钮切换下一首
|
|
|
if(state.audioData.index==state.audioData.list.length-1){
|
|
@@ -105,8 +143,23 @@ export default createStore({
|
|
|
if(state.audioData.activityId!=0){
|
|
|
handleActivityAudioRecordUpdate(state.audioData)
|
|
|
}
|
|
|
+ if(state.audioData.voiceId!=0){
|
|
|
+ handleAudioRecordUpdate({audioCurrentTime:state.audioData.audioCurrentTime,source:2})
|
|
|
+ }
|
|
|
+ if(state.audioData.questionId!=0){
|
|
|
+ handleAudioRecordUpdate({audioCurrentTime:state.audioData.audioCurrentTime,source:1})
|
|
|
+ }
|
|
|
|
|
|
state.audioData.index++
|
|
|
+ if(state.audioData.activityId!=0){
|
|
|
+ handleActivityAudioRecordAdd(state.audioData)
|
|
|
+ }
|
|
|
+ if(state.audioData.voiceId!=0){
|
|
|
+ handleVoiceAudioRecordAdd(state.audioData)
|
|
|
+ }
|
|
|
+ if(state.audioData.questionId!=0){
|
|
|
+ handleQuestionAudioRecordAdd(state.audioData)
|
|
|
+ }
|
|
|
}
|
|
|
}else if(e==='auto'){//自动播放切换下一首
|
|
|
if(state.audioData.index==state.audioData.list.length-1){
|
|
@@ -114,6 +167,12 @@ export default createStore({
|
|
|
if(state.audioData.activityId!=0){
|
|
|
handleActivityAudioRecordUpdate(state.audioData)
|
|
|
}
|
|
|
+ if(state.audioData.voiceId!=0){
|
|
|
+ handleAudioRecordUpdate({audioCurrentTime:state.audioData.audioCurrentTime,source:2})
|
|
|
+ }
|
|
|
+ if(state.audioData.questionId!=0){
|
|
|
+ handleAudioRecordUpdate({audioCurrentTime:state.audioData.audioCurrentTime,source:1})
|
|
|
+ }
|
|
|
|
|
|
state.audioData.list=[]
|
|
|
state.audioData.index=0
|
|
@@ -128,8 +187,23 @@ export default createStore({
|
|
|
if(state.audioData.activityId!=0){
|
|
|
handleActivityAudioRecordUpdate(state.audioData)
|
|
|
}
|
|
|
+ if(state.audioData.voiceId!=0){
|
|
|
+ handleAudioRecordUpdate({audioCurrentTime:state.audioData.audioCurrentTime,source:2})
|
|
|
+ }
|
|
|
+ if(state.audioData.questionId!=0){
|
|
|
+ handleAudioRecordUpdate({audioCurrentTime:state.audioData.audioCurrentTime,source:1})
|
|
|
+ }
|
|
|
|
|
|
state.audioData.index++
|
|
|
+ if(state.audioData.activityId!=0){
|
|
|
+ handleActivityAudioRecordAdd(state.audioData)
|
|
|
+ }
|
|
|
+ if(state.audioData.voiceId!=0){
|
|
|
+ handleVoiceAudioRecordAdd(state.audioData)
|
|
|
+ }
|
|
|
+ if(state.audioData.questionId!=0){
|
|
|
+ handleQuestionAudioRecordAdd(state.audioData)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -138,6 +212,12 @@ export default createStore({
|
|
|
if(state.audioData.activityId!=0){
|
|
|
handleActivityAudioRecordUpdate(state.audioData)
|
|
|
}
|
|
|
+ if(state.audioData.voiceId!=0){
|
|
|
+ handleAudioRecordUpdate({audioCurrentTime:state.audioData.audioCurrentTime,source:2})
|
|
|
+ }
|
|
|
+ if(state.audioData.questionId!=0){
|
|
|
+ handleAudioRecordUpdate({audioCurrentTime:state.audioData.audioCurrentTime,source:1})
|
|
|
+ }
|
|
|
|
|
|
state.audioData.list=[]
|
|
|
state.audioData.index=0
|
|
@@ -164,6 +244,12 @@ export default createStore({
|
|
|
if(state.audioData.activityId!=0){
|
|
|
handleActivityAudioRecordUpdate(state.audioData)
|
|
|
}
|
|
|
+ if(state.audioData.voiceId!=0){
|
|
|
+ handleAudioRecordUpdate({audioCurrentTime:state.audioData.audioCurrentTime,source:2})
|
|
|
+ }
|
|
|
+ if(state.audioData.questionId!=0){
|
|
|
+ handleAudioRecordUpdate({audioCurrentTime:state.audioData.audioCurrentTime,source:1})
|
|
|
+ }
|
|
|
|
|
|
state.audioData.show=false
|
|
|
},
|
|
@@ -255,4 +341,35 @@ function handleActivityAudioRecordUpdate(params) {
|
|
|
console.log('更新音频记录成功');
|
|
|
}
|
|
|
})
|
|
|
+}
|
|
|
+
|
|
|
+// 更新问答社区、语音播报模块 音频播放记录
|
|
|
+function handleAudioRecordUpdate(params){
|
|
|
+ apiViewLogUpdate({
|
|
|
+ id:lastAudioRecordId,
|
|
|
+ stop_seconds:parseInt(params.audioCurrentTime),
|
|
|
+ source:params.source,
|
|
|
+ }).then(res=>{
|
|
|
+ console.log('更新播放时长成功');
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+//新增语音播报音频播放记录
|
|
|
+function handleVoiceAudioRecordAdd(params){
|
|
|
+ apiVoicePlayRecord({
|
|
|
+ broadcast_id:params.voiceId
|
|
|
+ }).then(res=>{
|
|
|
+ console.log('上报音频播放记录');
|
|
|
+ lastAudioRecordId=res.data
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+//新增问答社区语音播放记录
|
|
|
+function handleQuestionAudioRecordAdd(params){
|
|
|
+ apiCountAudioClick({
|
|
|
+ community_question_audio_id:params.list[params.index].id
|
|
|
+ }).then(res=>{
|
|
|
+ console.log('上报问答音频播放记录');
|
|
|
+ lastAudioRecordId=res.data
|
|
|
+ })
|
|
|
}
|