import Vue from 'vue'; import Vuex from 'vuex'; Vue.use(Vuex) export default new Vuex.Store({ state: { bgAudioMannager: null, messageObj: {} , // 用户信息 }, mutations: { // 日报详情 setMessageObj(state, obj) { state.messageObj = obj }, createAudio(state) { state.bgAudioMannager = uni.getBackgroundAudioManager(); }, setSeekAudio(state, t) { state.bgAudioMannager.seek(t) }, // 加载音频监听方法 initAudioMethod (state, obj) { state.bgAudioMannager.onCanplay(() => { state.bgAudioMannager.currentTime = obj.currentTime }); state.bgAudioMannager.onStop(() => { console.log('停止播放'); }); state.bgAudioMannager.onPause(() => { console.log('暂停播放'); }); state.bgAudioMannager.onEnded(() => { //初始化 需要的参数 console.log('自然播放结束事件'); }); state.bgAudioMannager.onError((res) => { console.log(res.errMsg); console.log(res.errCode); }); }, // 停止全局音频播放 stopAduio(state) { state.bgAudioMannager && state.bgAudioMannager.pause() if (state.bgAudioMannager && state.bgAudioMannager.src) { state.bgAudioMannager.src = '' } }, }, action: { } })