From 4496721cd3af3c68ed4d55218d3e83ea0664c57e Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期一, 29 四月 2024 17:53:10 +0800 Subject: [PATCH] bug3 --- packageDomain/pages/resourceDetails/document/index.js | 137 +++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 129 insertions(+), 8 deletions(-) diff --git a/packageDomain/pages/resourceDetails/document/index.js b/packageDomain/pages/resourceDetails/document/index.js index 3db416d..2449ab4 100644 --- a/packageDomain/pages/resourceDetails/document/index.js +++ b/packageDomain/pages/resourceDetails/document/index.js @@ -1,4 +1,5 @@ // pages/resourceDetails/document/index.js +import Toast from 'tdesign-miniprogram/toast/index'; const app = getApp() Page({ @@ -6,6 +7,11 @@ * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { + visible: false, + showIndex: false, + closeBtn: false, + deleteBtn: false, + images: [], webpageSrc: '', navBarHeight: '', barHeight: '', @@ -23,11 +29,27 @@ naturalResources: [], titleName: '', pdfDatA: [], + startTime: "", //杩涘叆椤甸潰褰撳墠鏃堕棿 + pauseTime: 0, //鏆傚仠鏃堕棿 + applyState: '', + deadline: '', }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ onLoad(options) { + + wx.setNavigationBarTitle({ + title: '璧勬簮璇︽儏' + }); + + + + + + + + console.log(options); const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 @@ -42,7 +64,9 @@ cmsId: options.cmsId, parentName: options.parentName, parentProductLinkPath: options.parentProductLinkPath, - productLinkPath: options.productLinkPath + productLinkPath: options.productLinkPath, + applyState: options.applyState, + deadline: options.deadline }) this.resourceDetailsData() }, @@ -58,23 +82,56 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず */ onShow() { - + this.setData({ + startTime: Date.now() + }) }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌 */ onHide() { - + this.setData({ + pauseTime: Date.now() + }) + if (wx.getStorageSync(app.config.tokenKey) && epubObj.bookBuy) { + let duration = this.data.pauseTime - this.data.startTime + this.count(duration) + } }, + /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇 */ onUnload() { - + this.setData({ + pauseTime: Date.now() + }) + if (wx.getStorageSync(app.config.tokenKey) && epubObj.bookBuy) { + let duration = this.data.pauseTime - this.data.startTime + this.count(duration) + } }, + count(timeStr) { + const data = { + appRefCode: app.config.appRefCode, + type: 'LearningTime', //缁熻绫诲瀷--闃呰鏃堕暱 + data: timeStr + '', //缁熻鍐呭--鏃堕暱姣 + event: 'LearningTime', + sysType: 'App' + } + //闃呰鍟嗗搧鐨刬d + if (this.data.bookId) { + data.productId = this.data.bookId + } + //闃呰璧勬簮鐨刬d + if (this.data.cmsId) { + data.cmsItemId = this.data.cmsId + } + app.MG.job.newJobWithApiNewEvent(data).then((res) => {}) + }, /** * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 */ @@ -147,6 +204,18 @@ //zpi鏂囦欢涓嬭浇 onDownloadButton() { const item = this.data.zipData; + if (this.data.applyState !== 'Normal') { + return wx.showToast({ + icon: 'none', + title: '璇峰厛鐢宠涓嬭浇', + }) + } else { + const flag = new Date(this.data.deadline) > new Date() + if (!flag) return wx.showToast({ + icon: 'none', + title: '璇峰厛鐢宠涓嬭浇', + }) + } if (!item || !item.file) { wx.showToast({ title: '鏂囦欢淇℃伅缂哄け', @@ -154,7 +223,6 @@ }); return; } - const downloadUrl = app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file; wx.showLoading({ title: '姝e湪涓嬭浇...', @@ -214,11 +282,14 @@ //鍒氳繘鏉ョ殑鏃跺�欒皟鐢� handleTeachData(item) { //鍥剧墖 + console.log(item, 'item11111'); if (item.selectType == 'picture') { this.setData({ - showData: app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file, + + showData: item.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.freeFile, }) + console.log(this.data.showData, 'showData'); } // 涓嬭浇鏂囦欢zip if (item.selectType == 'zip') { @@ -235,7 +306,9 @@ //鏂囨。绛� if (item.selectType == 'pdf' || item.selectType == 'document') { - app.MG.file.getPdfInfo({ md5: item.file }).then((res) => { + app.MG.file.getPdfInfo({ + md5: item.file + }).then((res) => { if (res && res.totalPages) { for (let i = 0; i < res.totalPages; i++) { const src = app.config.requestCtx + '/file/GetPdfPageImage?md5=' + item.file + '&index=' + (i + 1) + '&dpi=300' @@ -258,10 +331,58 @@ naturalResources.forEach(function (item) { // console.log(item); }); - } + }, + onClick() { + this.setData({ + images: [ + this.data.showData, + // 'https://tdesign.gtimg.com/mobile/demos/swiper2.png', + ], + showIndex: true, + visible: true, + }); + }, + onChange(e) { + const { + index + } = e.detail; + console.log('change', index); + }, + + onDelete(e) { + const { + index + } = e.detail; + + Toast({ + context: this, + selector: '#t-toast', + message: `鍒犻櫎绗�${index + 1}涓猔, + }); + }, + + onClose(e) { + const { + trigger + } = e.detail; + console.log(trigger); + this.setData({ + visible: false, + }); + }, + //棰勮鍥剧墖锛屾斁澶ч瑙� + preview(event) { + console.log(event.currentTarget.dataset.src) + let currentUrl = event.currentTarget.dataset.src + + wx.previewImage({ + current: currentUrl, // 褰撳墠鏄剧ず鍥剧墖鐨刪ttp閾炬帴 + // urls: this.data.showData // 闇�瑕侀瑙堢殑鍥剧墖http閾炬帴鍒楄〃 + }) + }, }) \ No newline at end of file -- Gitblit v1.9.1