From 12e72812d28c95394a17ec495985d44aff1c77f7 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期三, 06 十一月 2024 15:13:22 +0800 Subject: [PATCH] 文档资源查看优化 --- packageDomain/pages/resourceDetails/document/index.js | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-) diff --git a/packageDomain/pages/resourceDetails/document/index.js b/packageDomain/pages/resourceDetails/document/index.js index f887867..2001062 100644 --- a/packageDomain/pages/resourceDetails/document/index.js +++ b/packageDomain/pages/resourceDetails/document/index.js @@ -41,6 +41,7 @@ distance: 0, //璁板綍鎵嬫寚绉诲姩璺濈 scale: 1, //瀹氫箟鍒濆鍖栫殑椤甸潰缂╂斁澶у皬 newScale: 1, //璁板綍鏂扮殑椤甸潰缂╂斁澶у皬 + pdfSrc: '' }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 @@ -49,7 +50,6 @@ wx.setNavigationBarTitle({ title: '璧勬簮璇︽儏' }); - console.log(options); const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� @@ -79,7 +79,6 @@ } else { this.resourceDetailsData() } - }, /** @@ -105,7 +104,7 @@ this.setData({ pauseTime: Date.now() }) - if (wx.getStorageSync(app.config.tokenKey) && epubObj && epubObj.bookBuy) { + if (wx.getStorageSync(app.config.tokenKey)) { let duration = this.data.pauseTime - this.data.startTime this.count(duration) } @@ -118,7 +117,7 @@ this.setData({ pauseTime: Date.now() }) - if (wx.getStorageSync(app.config.tokenKey) && epubObj && epubObj.bookBuy) { + if (wx.getStorageSync(app.config.tokenKey)) { let duration = this.data.pauseTime - this.data.startTime this.count(duration) } @@ -152,9 +151,7 @@ /** * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� */ - onReachBottom() { - - }, + onReachBottom() {}, /** * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� @@ -197,7 +194,6 @@ query.storeInfo = this.data.storeInfo } app.MG.store.getProductDetail(query).then((res) => { - console.log(res); res.datas.cmsDatas[0].datas.forEach((item) => { if (this.data.productLinkPath == item.productLinkPath) { this.handleTeachData(item) @@ -286,7 +282,6 @@ //鍒氳繘鏉ョ殑鏃跺�欒皟鐢� handleTeachData(item) { //鍥剧墖 - if (item.selectType == 'picture') { this.setData({ showData: item.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.freeFile, @@ -307,15 +302,25 @@ }) wx.hideLoading(); } + // if (item.selectType == 'pdf') { + // console.log('pdf', item); + // wx.hideLoading() + // let md5 = item.file ? item.file : item.freeFile + // let pdfSrc = app.config.pdfUrl + "?MD5=" + md5 + "&url=" + app.config.requestCtx + '¤tPage=' + "1" + "&isPreview=" + false + "&warterMark=" + "鍖椾含甯堣寖澶у鍑虹増绀�" + "&previewPages=" + 30 + "&token=" + wx.getStorageSync(app.config.tokenKey) + // this.setData({ + // pdfSrc: pdfSrc + // }) + // } //鏂囨。绛� - if (item.selectType == 'pdf' || item.selectType == 'document') { + if (item.selectType == 'document' || item.selectType == 'pdf') { + let md5 = item.file ? item.file : item.freeFile app.MG.file.getPdfInfo({ - md5: item.file + md5: md5 }).then((res) => { let naturalResources = [] 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' + const src = app.config.requestCtx + '/file/GetPdfPageImage?md5=' + md5 + '&index=' + (i + 1) + '&dpi=300' naturalResources.push(src) } } @@ -331,7 +336,6 @@ handleTap: function () { const naturalResources = this.data.naturalResources; naturalResources.forEach(function (item) { - // console.log(item); }); }, @@ -368,7 +372,6 @@ const { trigger } = e.detail; - console.log(trigger); this.setData({ visible: false, }); -- Gitblit v1.9.1