| | |
| | | // pages/resourceDetails/index.js |
| | | const app = getApp() |
| | | const myAudio = wx.createInnerAudioContext(); |
| | | import { |
| | | loginInfo |
| | | } from '../../../../assets/js/login'; |
| | | // innerAudioContext.onPlay(function callback), |
| | | // InnerAudioContext.onTimeUpdate(function callback) |
| | | Page({ |
| | |
| | | parentProductLinkPath: '', |
| | | productLinkPath: '', |
| | | threeLeveData: [], |
| | | source: "", |
| | | showData: '', |
| | | src: '', |
| | | selectedId: null, |
| | |
| | | pauseTime: 0, //暂停时间 |
| | | formPath: '', |
| | | loading: true, |
| | | hidden: true |
| | | hidden: true, |
| | | playerList: [], |
| | | progress: 0, |
| | | }, |
| | | |
| | | format(time) { |
| | |
| | | cmsId: options.cmsId, |
| | | parentProductLinkPath: options.parentProductLinkPath, |
| | | productLinkPath: options.productLinkPath, |
| | | formPath: options.formPath |
| | | formPath: options.formPath, |
| | | source: options.source, |
| | | }) |
| | | |
| | | if (options.parentName !== "教学资源" && options.parentName !== "云学习") { |
| | |
| | | parentName: options.parentName, |
| | | }) |
| | | } |
| | | this.resourceDetailsData() |
| | | this.getNoteList() |
| | | const token = wx.getStorageSync(app.config.tokenKey) |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | if (data) { |
| | | this.resourceDetailsData() |
| | | this.getNoteList() |
| | | } else { |
| | | this.resourceDetailsData() |
| | | this.getNoteList() |
| | | } |
| | | }) |
| | | } else { |
| | | this.resourceDetailsData() |
| | | this.getNoteList() |
| | | } |
| | | }, |
| | | |
| | | /** |
| | |
| | | let duration = this.data.pauseTime - this.data.startTime |
| | | this.count(duration) |
| | | } |
| | | this.setPlayerList() |
| | | }, |
| | | |
| | | /** |
| | |
| | | myAudio.stop(); |
| | | // 销毁 InnerAudioContext 实例 |
| | | // myAudio.destroy(); |
| | | this.setPlayerList() |
| | | }, |
| | | count(timeStr) { |
| | | const data = { |
| | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | }, |
| | | onShareAppMessage() {}, |
| | | onShareTimeline() {}, |
| | | onTabsChange(event) {}, |
| | | |
| | | onTabsClick(event) {}, |
| | |
| | | let titleName = ''; |
| | | |
| | | res.datas.cmsDatas[0].datas.forEach((item, index) => { |
| | | if (item.selectType === "audio" || item.learnSelectType === "audio") { |
| | | this.data.threeLeveData.push(item); |
| | | if (this.data.source == 'qrcode') { |
| | | if (item.id == this.data.activeId) { |
| | | this.data.threeLeveData.push(item); |
| | | } |
| | | } else { |
| | | if (item.selectType === "audio" || item.learnSelectType === "audio") { |
| | | this.data.threeLeveData.push(item); |
| | | } |
| | | } |
| | | |
| | | }); |
| | | this.data.threeLeveData.forEach((items, indexs) => { |
| | | if (this.data.productLinkPath == items.productLinkPath) { |
| | | selectedId = indexs; |
| | | |
| | | } |
| | | }) |
| | | if (selectedId !== -1) { |
| | | let datas = this.data.threeLeveData[selectedId]; |
| | | |
| | | if (this.data.formPath == 'jsek_cloudLearning') { |
| | | showDataUrl = app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + datas.protectedFile + '&token=' + wx.getStorageSync(app.config.tokenKey); |
| | | let file = datas.protectedFile ? datas.protectedFile : datas.file |
| | | showDataUrl = app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + file + '&token=' + wx.getStorageSync(app.config.tokenKey); |
| | | } else { |
| | | showDataUrl = datas.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + datas.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + datas.freeFile |
| | | } |
| | |
| | | hidden: false |
| | | }); |
| | | this.pubulicPlayFun(); |
| | | |
| | | }); |
| | | }, |
| | | |
| | | onVideo(e) { |
| | | this.setPlayerList() |
| | | this.setData({ |
| | | myAudioCurrent: '00:00', |
| | | myAudioPos: '', |
| | | isplay: false |
| | | }) |
| | | const item = e.currentTarget.dataset.item |
| | | console.log(item, 222) |
| | | if (this.data.showData != '') { |
| | | this.setData({ |
| | | titleName: item.name, |
| | | selectId: item.id, |
| | | selectedId: e.currentTarget.dataset.index, |
| | | showData: '' |
| | | showData: '', |
| | | activeId: item.id |
| | | |
| | | }) |
| | | if (item.selectType == "audio" || item.learnSelectType === "audio") { |
| | | if (this.data.formPath == 'jsek_cloudLearning') { |
| | | let file = item.protectedFile ? item.protectedFile : item.file |
| | | // 这里处理云学习的 |
| | | this.setData({ |
| | | showData: app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + item.protectedFile + '&token=' + wx.getStorageSync(app.config.tokenKey) |
| | | showData: app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + file + '&token=' + wx.getStorageSync(app.config.tokenKey) |
| | | }) |
| | | this.pubulicPlayFun() |
| | | } else { |
| | |
| | | }, |
| | | // 播放公共代码 |
| | | pubulicPlayFun() { |
| | | // debugger |
| | | this.setData({ |
| | | speed: 1.0, |
| | | }) |
| | |
| | | myAudioPos: myAudio.currentTime / myAudio.duration * 100, |
| | | myAudioCurrent: this.format(myAudio.currentTime), |
| | | myAudioDuration: this.format(myAudio.duration), |
| | | progress: ((myAudio.currentTime / myAudio.duration) * 100).toFixed(2) |
| | | }); |
| | | console.log(myAudio.currentTime.toFixed(3), myAudio.duration); |
| | | // console.log(myAudio.currentTime.toFixed(3), myAudio.duration); |
| | | }) |
| | | }, |
| | | |
| | |
| | | myAudio.playbackRate = this.data.speed; // 播放速率 |
| | | }, 200); |
| | | }, |
| | | |
| | | //获取音频学习 |
| | | getPlayerList() { |
| | | app.MG.identity |
| | | .getUserKey({ |
| | | domain: 'videoPlayer', |
| | | keys: [this.data.bookId] |
| | | }) |
| | | .then((res) => { |
| | | if (res.length > 0) { |
| | | this.setData({ |
| | | playerList: JSON.parse(res[0].value) |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | setPlayerList() { |
| | | let that = this |
| | | if (that.data.progress > 0) { |
| | | let index = that.data.playerList.findIndex((itemData) => itemData.cmsItemId == that.data.selectId) |
| | | if (index > -1) { |
| | | that.data.playerList.splice(index, 1) |
| | | } |
| | | that.data.playerList.push({ |
| | | cmsItemId: that.data.selectId, |
| | | progress: that.data.progress |
| | | }) |
| | | app.MG.identity |
| | | .setUserKey({ |
| | | setKeyRequests: [{ |
| | | domain: 'videoPlayer', |
| | | key: that.data.bookId, |
| | | value: JSON.stringify(that.data.playerList) |
| | | }] |
| | | }) |
| | | .then((res) => {}) |
| | | } |
| | | }, |
| | | }) |