From 892efc9976feb68ce1a3a4d759317e2585d67ebe Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期六, 07 九月 2024 18:16:18 +0800 Subject: [PATCH] bug修改 --- packageDomain/pages/resourceDetails/myVideo/index.js | 189 +++++++++++++++++++++++++++++++++++------------ 1 files changed, 141 insertions(+), 48 deletions(-) diff --git a/packageDomain/pages/resourceDetails/myVideo/index.js b/packageDomain/pages/resourceDetails/myVideo/index.js index f20f1b1..67ed12b 100644 --- a/packageDomain/pages/resourceDetails/myVideo/index.js +++ b/packageDomain/pages/resourceDetails/myVideo/index.js @@ -1,6 +1,8 @@ // pages/resourceDetails/index.js const app = getApp() - +import { + loginInfo +} from '../../../../assets/js/login'; Page({ /** @@ -25,11 +27,12 @@ productLinkPath: '', threeLeveData: [], showData: '', + showDataVod: '', src: '', selectedId: null, topicId: '', titleName: '', - submitTitle: "", + submitTitle: "1", inputStyle: 'border: 2rpx solid rgba(220,220,220,1);border-radius: 12rpx; padding:16rpx', textvalue: '', style: 'height: 248rpx', @@ -42,7 +45,10 @@ loading: false, hidden: true, videoError: false, - videoLoading: false + videoLoading: false, + progress: 0, + playerList: [], + videoLoaidng: true }, // 鏍煎紡鍖栫瑪璁版椂闂� convertTimestamp(timestamp) { @@ -60,6 +66,7 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ onLoad(options) { + console.log('璧勬簮', options); wx.setNavigationBarTitle({ title: '璧勬簮璇︽儏-瑙嗛' }); @@ -77,16 +84,25 @@ parentProductLinkPath: options.parentProductLinkPath, productLinkPath: options.productLinkPath, formPath: options.formPath, - flag: false + flag: false, }) - console.log(this.data.storeInfo,13) if (options.parentName !== "鏁欏璧勬簮" && options.parentName !== "浜戝涔�") { this.setData({ parentName: options.parentName, }) } - this.resourceDetailsData() - this.getNoteList() + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + loginInfo(app, (data) => { + if (data) { + this.resourceDetailsData() + } else { + this.resourceDetailsData() + } + }) + } else { + this.resourceDetailsData() + } }, /** @@ -117,6 +133,7 @@ let duration = this.data.pauseTime - this.data.startTime this.count(duration) } + this.setPlayerList() }, /** @@ -130,6 +147,7 @@ let duration = this.data.pauseTime - this.data.startTime this.count(duration) } + this.setPlayerList() }, count(timeStr) { const data = { @@ -170,12 +188,13 @@ }, onTabsChange(event) { - + console.log(event, 234) + let tabValue = event.detail.value + if (tabValue == '1') { + this.getNoteList() + } }, - onTabsClick(event) { - - }, handleChange(e) { this.setData({ activeValues: e.detail.value, @@ -185,7 +204,6 @@ }, showDialog(e) { - this.setData({ dialogKey: true, textvalue: '', @@ -205,7 +223,8 @@ }, resourceDetailsData() { this.setData({ - // videoLoaidng: true + videoLoaidng: true, + loading: true }) let query = { storeInfo: this.data.storeInfo, @@ -233,68 +252,145 @@ } } app.MG.store.getProductDetail(query).then(res => { - console.log(this.data.productLinkPath, 345) res.datas.cmsDatas[0].datas.forEach((item) => { - console.log(item, 222) if (item.selectType === "video" || item.learnSelectType === "video") { this.data.threeLeveData.push(item) this.setData({ threeLeveData: this.data.threeLeveData }) - this.data.threeLeveData.forEach((items, index) => { // 淇敼姝ゅ娣诲姞index鍙傛暟 - if (this.data.productLinkPath == items.productLinkPath) { - console.log(items, 5678) - if (this.data.formPath === "jsek_cloudLearning") { - let file - items.protectedFile ? file = items.protectedFile : file = items.freeFile - this.setData({ - showData: app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + file + '&token=' + wx.getStorageSync(app.config.tokenKey), - titleName: items.name - }) - } else { - this.setData({ - showData: item.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.freeFile, - titleName: items.name - }) - } - let selectedIndex = index; // 瀛樺偍閫変腑椤圭殑绱㈠紩 - this.setData({ - selectedId: selectedIndex // 璁剧疆閫変腑椤圭殑绱㈠紩 - }); - } - }); } }) + this.data.threeLeveData.forEach((items, index) => { // 淇敼姝ゅ娣诲姞index鍙傛暟 + if (this.data.productLinkPath == items.productLinkPath) { + if (this.data.formPath === "jsek_cloudLearning") { + let file + items.protectedFile || items.file ? file = items.protectedFile || items.file : file = items.freeFile + this.setData({ + showData: app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + file + '&token=' + wx.getStorageSync(app.config.tokenKey), + titleName: items.name + }) + this.aliVod(file, this.data.showData) + } else { + this.setData({ + showData: items.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + items.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + items.freeFile, + titleName: items.name + }) + this.aliVod(items.file, this.data.showData) + } + let selectedIndex = index; // 瀛樺偍閫変腑椤圭殑绱㈠紩 + this.setData({ + selectedId: selectedIndex // 璁剧疆閫変腑椤圭殑绱㈠紩 + }); + } + }); this.setData({ loading: false, - hidden: false + hidden: false, }) - console.log('鍦板潃', this.data.showData); }) }, onVideo(e) { + this.setPlayerList() const item = e.currentTarget.dataset.item this.setData({ videoLoaidng: true, selectedId: e.currentTarget.dataset.index, + activeId: item.id, // showData: '', titleName: item.name }) if (item.selectType == "video" || item.learnSelectType === "video") { if (this.data.formPath === "jsek_cloudLearning") { let file - item.protectedFile ? file = item.protectedFile : file = item.freeFile + item.protectedFile || item.file ? file = item.protectedFile || item.file : file = item.freeFile this.setData({ showData: app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + file + '&token=' + wx.getStorageSync(app.config.tokenKey) }) - console.log(this.data.showData); + this.aliVod(file, this.data.showData) } else { this.setData({ showData: item.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.freeFile, }) + this.aliVod(item.file, this.data.showData) } } }, + + aliVod(md5, currentVideo) { + let query = { + md5: md5, + appRefCode: app.config.appRefCode + } + app.MG.file.getAliVod(query).then((res) => { + if (res) { + if (res && res.data == '') { + this.setData({ + showDataVod: currentVideo, + }) + } else { + this.setData({ + showDataVod: res, + }) + } + this.setData({}) + } else if (currentVideo) { + this.setData({ + showDataVod: currentVideo, + }) + } else { + return ElMessage.error('鏃犳硶鑾峰彇瑙嗛璧勬簮') + } + }) + }, + + timeUpdate(e) { + console.log(2); + let { + currentTime, + duration + } = e.detail + this.setData({ + progress: ((currentTime / duration) * 100).toFixed(2) + }) + }, + //鑾峰彇瑙嗛瀛︿範 + 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.activeId) + if (index > -1) { + that.data.playerList.splice(index, 1) + } + that.data.playerList.push({ + cmsItemId: that.data.activeId, + progress: that.data.progress + }) + app.MG.identity + .setUserKey({ + setKeyRequests: [{ + domain: 'videoPlayer', + key: that.data.bookId, + value: JSON.stringify(that.data.playerList) + }] + }) + .then((res) => {}) + } + }, + getProductUserSubmitTopicGet() { app.MG.ugc.getProductUserSubmitTopic({ @@ -351,8 +447,6 @@ } else if (this.data.submitType == 'edit') { this.updateNote() } - console.log(this.data.textvalue); - console.log(this.data.titleName); this.setData({ dialogKey: false }); @@ -367,9 +461,9 @@ }, // 鑾峰彇绗旇鍒楄〃 async getNoteList() { - // this.setData({ - // loading: true - // }) + this.setData({ + loading: true + }) let topicId await app.MG.ugc .getProductUserSubmitTopic({ @@ -405,7 +499,6 @@ // item.deleteHover = false item.createDate = this.convertTimestamp(item.createDate) }) - console.log(res, 'res'); this.setData({ "pageCount.total": res.totalSize, noteList: res.datas, @@ -546,12 +639,12 @@ console.log(e); }, videoError: function (e) { - console.log('瑙嗛鍔犺浇澶辫触', e); this.setData({ videoError: true }); }, loadedmetadata(e) { + console.log(1); this.setData({ videoLoaidng: false }) -- Gitblit v1.9.1