From 8dc4e50769a7ebc5f0a3d766f61aa08b8f23b772 Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期五, 06 九月 2024 11:23:21 +0800 Subject: [PATCH] login --- packageDomain/pages/resourceDetails/myAudio/index.js | 68 +++++++++++++++++++++++++++++---- 1 files changed, 59 insertions(+), 9 deletions(-) diff --git a/packageDomain/pages/resourceDetails/myAudio/index.js b/packageDomain/pages/resourceDetails/myAudio/index.js index 04285e2..1a5f65d 100644 --- a/packageDomain/pages/resourceDetails/myAudio/index.js +++ b/packageDomain/pages/resourceDetails/myAudio/index.js @@ -48,7 +48,9 @@ pauseTime: 0, //鏆傚仠鏃堕棿 formPath: '', loading: true, - hidden: true + hidden: true, + playerList: [], + progress: 0, }, format(time) { @@ -102,6 +104,12 @@ parentName: options.parentName, }) } + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + loginInfo(app, (data) => { + if (data) {} else {} + }) + } this.resourceDetailsData() this.getNoteList() }, @@ -132,6 +140,7 @@ let duration = this.data.pauseTime - this.data.startTime this.count(duration) } + this.setPlayerList() }, /** @@ -164,6 +173,7 @@ myAudio.stop(); // 閿�姣� InnerAudioContext 瀹炰緥 // myAudio.destroy(); + this.setPlayerList() }, count(timeStr) { const data = { @@ -269,14 +279,13 @@ 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 } @@ -292,29 +301,33 @@ 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 { @@ -613,8 +626,9 @@ 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); }) }, @@ -764,5 +778,41 @@ 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) => {}) + } + }, }) \ No newline at end of file -- Gitblit v1.9.1