From c96612e8a63ecef9590be0f8b5199277ec94e5b9 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期三, 18 九月 2024 18:43:12 +0800 Subject: [PATCH] 云学习购买目录,修改bug --- packageDomain/pages/resourceDetails/myAudio/index.js | 155 ++++++++++++++++++++++----------------------------- 1 files changed, 66 insertions(+), 89 deletions(-) diff --git a/packageDomain/pages/resourceDetails/myAudio/index.js b/packageDomain/pages/resourceDetails/myAudio/index.js index 27fce10..06c0fb7 100644 --- a/packageDomain/pages/resourceDetails/myAudio/index.js +++ b/packageDomain/pages/resourceDetails/myAudio/index.js @@ -1,6 +1,9 @@ // 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({ @@ -27,6 +30,7 @@ parentProductLinkPath: '', productLinkPath: '', threeLeveData: [], + source: "", showData: '', src: '', selectedId: null, @@ -41,7 +45,6 @@ myAudioDuration: '00:00', // 瑙嗛鏃堕棿 myAudioCurrent: '00:00', // 褰撳墠鎾斁杩涘害 isplay: false, //鏄惁榛樿鎾斁, - selectId: '', speed: 1.0, myAudioPos: '', startTime: "", //杩涘叆椤甸潰褰撳墠鏃堕棿 @@ -96,7 +99,8 @@ cmsId: options.cmsId, parentProductLinkPath: options.parentProductLinkPath, productLinkPath: options.productLinkPath, - formPath: options.formPath + formPath: options.formPath, + source: options.source, }) if (options.parentName !== "鏁欏璧勬簮" && options.parentName !== "浜戝涔�") { @@ -104,8 +108,21 @@ 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() + } }, /** @@ -127,14 +144,17 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌 */ 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() }, /** @@ -144,29 +164,24 @@ * */ 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) { @@ -185,6 +200,7 @@ if (this.data.cmsId) { data.cmsItemId = this.data.cmsId } + console.log('缁熻', data) app.MG.job.newJobWithApiNewEvent(data).then((res) => {}) }, /** @@ -204,9 +220,8 @@ /** * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� */ - onShareAppMessage() { - - }, + onShareAppMessage() {}, + onShareTimeline() {}, onTabsChange(event) {}, onTabsClick(event) {}, @@ -266,9 +281,31 @@ 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); + if (this.data.storeInfo == 'jsek_digitalCourses') { + if (this.data.isBuy) { + if (item.sysType == 'CmsItem') { + this.data.threeLeveData.push(item) + } + } else { + if (item.sysType == 'CmsItem' && item.freeFile) { + this.data.threeLeveData.push(item) + } + } + } else { + if (res.datas.purchasedSaleMethodIdList.includes(item.defaultSaleMethodId) || item.freeFile) { + this.data.threeLeveData.push(item) + } + } + } } + }); this.data.threeLeveData.forEach((items, indexs) => { if (this.data.productLinkPath == items.productLinkPath) { @@ -284,7 +321,6 @@ showDataUrl = datas.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + datas.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + datas.freeFile } titleName = datas.name; - console.log(showDataUrl, 676767) } this.setData({ @@ -296,7 +332,6 @@ hidden: false }); this.pubulicPlayFun(); - }); }, @@ -308,15 +343,12 @@ 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: '', activeId: item.id - }) if (item.selectType == "audio" || item.learnSelectType === "audio") { if (this.data.formPath == 'jsek_cloudLearning') { @@ -576,7 +608,6 @@ }, // 鎾斁鍏叡浠g爜 pubulicPlayFun() { - // debugger this.setData({ speed: 1.0, }) @@ -610,9 +641,6 @@ myAudioCurrent: '00:00', myAudioPos: '', }) - - - }); //杩涘害鏉″彉鍖� @@ -645,57 +673,6 @@ }); }, - //鍙冲垏鎹� - 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; @@ -774,7 +751,7 @@ myAudio.playbackRate = this.data.speed; // 鎾斁閫熺巼 }, 200); }, - //鑾峰彇瑙嗛瀛︿範 + //鑾峰彇闊抽瀛︿範 getPlayerList() { app.MG.identity .getUserKey({ @@ -792,12 +769,12 @@ 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 -- Gitblit v1.9.1