From 50ca1ad0d141d7dc0ddf29b2d3051b85ceff8f56 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期二, 05 十一月 2024 10:21:05 +0800 Subject: [PATCH] pdf阅读优化 --- packageDomain/pages/resourceDetails/document/index.js | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 37 insertions(+), 15 deletions(-) diff --git a/packageDomain/pages/resourceDetails/document/index.js b/packageDomain/pages/resourceDetails/document/index.js index dd3cd03..0f5bb65 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: '' }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 @@ -70,10 +71,15 @@ const token = wx.getStorageSync(app.config.tokenKey) if (!token) { loginInfo(app, (data) => { - if (data) {} else {} + if (data) { + this.resourceDetailsData() + } else { + this.resourceDetailsData() + } }) + } else { + this.resourceDetailsData() } - this.resourceDetailsData() }, /** @@ -146,21 +152,21 @@ /** * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� */ - onReachBottom() { - - }, + onReachBottom() {}, /** * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� */ - onShareAppMessage() { - - }, + onShareAppMessage() {}, + onShareTimeline() {}, goBack() { wx.navigateBack() }, resourceDetailsData() { + wx.showLoading({ + title: '姝e湪鍔犺浇...', + }); let query = { path: '*', queryType: '*', @@ -278,39 +284,55 @@ //鍒氳繘鏉ョ殑鏃跺�欒皟鐢� handleTeachData(item) { //鍥剧墖 - console.log(item, 'item11111'); 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, }) - console.log(this.data.showData, 'showData'); + wx.hideLoading(); } // 涓嬭浇鏂囦欢zip if (item.selectType == 'zip') { this.setData({ zipData: item }) + wx.hideLoading(); } //缃戦〉 if (item.selectType == 'webpage') { this.setData({ webpageSrc: item.jsek_link }) + 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' - this.data.naturalResources.push(src) - // console.log(this.data.naturalResources, ' this.data.naturalResources'); + const src = app.config.requestCtx + '/file/GetPdfPageImage?md5=' + md5 + '&index=' + (i + 1) + '&dpi=300' + naturalResources.push(src) } } + this.setData({ + naturalResources + }) + wx.hideLoading(); }) } + }, handleTap: function () { -- Gitblit v1.9.1