| | |
| | | myAudioDuration: '00:00', // 视频时间 |
| | | myAudioCurrent: '00:00', // 当前播放进度 |
| | | isplay: false, //是否默认播放, |
| | | selectId: '', |
| | | speed: 1.0, |
| | | myAudioPos: '', |
| | | startTime: "", //进入页面当前时间 |
| | |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide() { |
| | | // this.setData({ |
| | | // pauseTime: Date.now() |
| | | // }) |
| | | // if (wx.getStorageSync(app.config.tokenKey)) { |
| | | // let duration = this.data.pauseTime - this.data.startTime |
| | | // this.count(duration) |
| | | // } |
| | | // this.setPlayerList() |
| | | this.setData({ |
| | | pauseTime: Date.now() |
| | | isplay: true |
| | | }) |
| | | if (wx.getStorageSync(app.config.tokenKey)) { |
| | | let duration = this.data.pauseTime - this.data.startTime |
| | | this.count(duration) |
| | | } |
| | | this.setPlayerList() |
| | | }, |
| | | |
| | | /** |
| | |
| | | * |
| | | */ |
| | | onUnload() { |
| | | // this.setData({ |
| | | // pauseTime: Date.now() |
| | | // }) |
| | | // if (wx.getStorageSync(app.config.tokenKey)) { |
| | | // let duration = this.data.pauseTime - this.data.startTime |
| | | // this.count(duration) |
| | | // } |
| | | |
| | | |
| | | // myAudio.src = '' |
| | | // myAudio.destroy() |
| | | this.setData({ |
| | | // myAudioPos: '', |
| | | isplay: false, //是否默认播放, |
| | | myAudioCurrent: '00:00', // 当前播放进度 |
| | | showData: '', |
| | | speed: 1.0, |
| | | pauseTime: Date.now() |
| | | }); |
| | | myAudio.playbackRate = this.data.speed; |
| | | // 停止音频播放 |
| | | myAudio.stop(); |
| | | // 销毁 InnerAudioContext 实例 |
| | | // myAudio.destroy(); |
| | | // 统计学习时长 |
| | | if (wx.getStorageSync(app.config.tokenKey)) { |
| | | let duration = this.data.pauseTime - this.data.startTime |
| | | this.count(duration) |
| | | } |
| | | this.setPlayerList() |
| | | }, |
| | | count(timeStr) { |
| | |
| | | if (this.data.cmsId) { |
| | | data.cmsItemId = this.data.cmsId |
| | | } |
| | | console.log('统计', data) |
| | | app.MG.job.newJobWithApiNewEvent(data).then((res) => {}) |
| | | }, |
| | | /** |
| | |
| | | if (this.data.showData != '') { |
| | | this.setData({ |
| | | titleName: item.name, |
| | | selectId: item.id, |
| | | selectedId: e.currentTarget.dataset.index, |
| | | showData: '', |
| | | activeId: item.id |
| | | |
| | | }) |
| | | if (item.selectType == "audio" || item.learnSelectType === "audio") { |
| | | if (this.data.formPath == 'jsek_cloudLearning') { |
| | |
| | | myAudioCurrent: '00:00', |
| | | myAudioPos: '', |
| | | }) |
| | | |
| | | |
| | | |
| | | }); |
| | | |
| | | //进度条变化 |
| | |
| | | }); |
| | | }, |
| | | |
| | | //右切换 |
| | | onLeftSwitch() { |
| | | this.setData({ |
| | | speed: 1.0, |
| | | myAudioCurrent: '00:00' |
| | | }) |
| | | const index = this.data.threeLeveData.findIndex((item) => item.id == this.data.selectId) |
| | | if (this.data.threeLeveData[index - 1]) { |
| | | this.changeItem(this.data.threeLeveData[index - 1]) |
| | | this.setData({ |
| | | selectedId: index - 1, |
| | | }) |
| | | } else { |
| | | console.log('已经是第一首了'); |
| | | } |
| | | }, |
| | | //右切换 |
| | | onRightSwitch() { |
| | | this.setData({ |
| | | speed: 1.0, |
| | | myAudioCurrent: '00:00' |
| | | }) |
| | | const index = this.data.threeLeveData.findIndex((item) => item.id == this.data.selectId) |
| | | if (this.data.threeLeveData[index + 1]) { |
| | | this.changeItem(this.data.threeLeveData[index + 1]) |
| | | this.setData({ |
| | | selectedId: index + 1, |
| | | }) |
| | | } else { |
| | | console.log('已经是最后一首了'); |
| | | } |
| | | }, |
| | | |
| | | // 左右切换 |
| | | changeItem(item) { |
| | | if (this.data.showData != '') { |
| | | this.setData({ |
| | | showData: '' |
| | | }) |
| | | } |
| | | this.setData({ |
| | | titleName: item.name, |
| | | selectId: item.id |
| | | }) |
| | | if (item.selectType == "audio") { |
| | | this.setData({ |
| | | showData: app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file |
| | | }) |
| | | this.pubulicPlayFun() |
| | | } |
| | | }, |
| | | // 播放倍速 |
| | | onSpeed() { |
| | | let c = this.data.speed; |
| | |
| | | setPlayerList() { |
| | | let that = this |
| | | if (that.data.progress > 0) { |
| | | let index = that.data.playerList.findIndex((itemData) => itemData.cmsItemId == that.data.selectId) |
| | | let index = that.data.playerList.findIndex((itemData) => itemData.cmsItemId == that.data.activeId) |
| | | if (index > -1) { |
| | | that.data.playerList.splice(index, 1) |
| | | } |
| | | that.data.playerList.push({ |
| | | cmsItemId: that.data.selectId, |
| | | cmsItemId: that.data.activeId, |
| | | progress: that.data.progress |
| | | }) |
| | | app.MG.identity |