From e5f45ec9c2eabaa3e4241caad2d49c3629eaf0c8 Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期一, 30 九月 2024 14:18:40 +0800 Subject: [PATCH] loading --- packageDomain/pages/resourceDetails/myVideo/index.js | 74 ++++++++++++++++++++++++++++++++++--- 1 files changed, 68 insertions(+), 6 deletions(-) diff --git a/packageDomain/pages/resourceDetails/myVideo/index.js b/packageDomain/pages/resourceDetails/myVideo/index.js index c4906d2..b051bc7 100644 --- a/packageDomain/pages/resourceDetails/myVideo/index.js +++ b/packageDomain/pages/resourceDetails/myVideo/index.js @@ -3,6 +3,7 @@ import { loginInfo } from '../../../../assets/js/login'; +import moment from 'moment' Page({ /** @@ -54,7 +55,10 @@ buyIdList: [], buyList: [], learnClassData: null, - bookDetail: null + bookDetail: null, + learnStartTime: 0, + learnTimeList: [], + learnTimeData: 0 }, // 鏍煎紡鍖栫瑪璁版椂闂� convertTimestamp(timestamp) { @@ -110,7 +114,13 @@ } else { this.resourceDetailsData() } - if (options.formPath == 'jsek_cloudLearning') this.getBookInfo(options.bookId) + if (options.formPath == 'jsek_cloudLearning') { + this.setData({ + learnStartTime: Date.now(), + }) + this.getLearnTime() + } + this.getBookInfo(this.data.bookId) }, /** @@ -133,6 +143,10 @@ if (wx.getStorageSync(app.config.tokenKey)) { let duration = this.data.pauseTime - this.data.startTime this.count(duration) + if (this.data.formPath == 'jsek_cloudLearning') { + let cloudDuration = this.data.pauseTime - this.data.learnStartTime + this.cloudCount(cloudDuration) + } } this.setPlayerList() }, @@ -149,7 +163,53 @@ this.count(duration) } this.setPlayerList() + if (this.data.formPath == 'jsek_cloudLearning') { + let cloudDuration = this.data.pauseTime - this.data.learnStartTime + this.cloudCount(cloudDuration) + } }, + getLearnTime() { + app.MG.identity + .getUserKey({ + domain: 'cloudLearningTime', + keys: [this.data.bookId] + }) + .then((res) => { + if (res.length > 0) { + if (JSON.parse(res[0].value) && JSON.parse(res[0].value).length > 0) { + this.setData({ + learnTimeList: JSON.parse(res[0].value), + learnTimeData: JSON.parse(res[0].value)[0].learnTime, + }) + } else { + this.setData({ + learnTimeList: [], + learnTimeData: 0 + }) + } + } + }) + }, + cloudCount(timeStr) { + let time = Number(this.data.learnTimeData) + Number(timeStr) + this.setData({ + learnTimeList: [{ + learnTime: time + }], + }) + app.MG.identity + .setUserKey({ + setKeyRequests: [{ + domain: 'cloudLearningTime', + key: this.data.bookId, + value: JSON.stringify(this.data.learnTimeList) + }] + }) + .then((res) => { + console.log(timeStr, '瀛︿範鏃堕暱') + }) + }, + // 鑾峰彇鍥句功璇︽儏 getBookInfo(id) { @@ -167,13 +227,15 @@ fields: {}, }; app.MG.store.getProductDetail(query).then(async (res) => { - console.log('鍥句功璇︽儏', res); this.setData({ bookDetail: res.datas, buyIdList: res.datas.purchasedSaleMethodIdList, - learnClassData: res.datas.cmsDatas[0].datas.find(item => item.refCode == "jsek_cloudLearning") + learnClassData: res.datas.length > 0 ? res.datas.cmsDatas[0].datas.find(item => item.refCode == "jsek_cloudLearning") : null }) - this.getResourceDataList(this.data.learnClassData) + if (this.data.learnClassData) { + this.getResourceDataList(this.data.learnClassData) + } + }); }, // 鏁欏璧勬簮 浜戝涔� 鑾峰彇 @@ -570,7 +632,7 @@ res.datas.forEach((item) => { // item.compliceHover = false // item.deleteHover = false - item.createDate = this.convertTimestamp(item.createDate) + item.createDate = moment(item.createDate).format('YYYY-MM-DD HH:mm:ss') }) this.setData({ "pageCount.total": res.totalSize, -- Gitblit v1.9.1