From 81c23f9c2f5bdfbe962d0b19a5a80ea7c12f043d Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期三, 10 七月 2024 17:39:02 +0800 Subject: [PATCH] 二维码 --- pages/index/resourceCover.js | 87 +++++++++++++++++++++++++------------------ 1 files changed, 50 insertions(+), 37 deletions(-) diff --git a/pages/index/resourceCover.js b/pages/index/resourceCover.js index 79f79e8..de4f902 100644 --- a/pages/index/resourceCover.js +++ b/pages/index/resourceCover.js @@ -1,5 +1,8 @@ // pages/index/resourceCover.js const app = getApp() +import { + loginInfo +} from '../../assets/js/login'; Page({ /** @@ -12,16 +15,30 @@ cmsId: '', productLinkPath: '', parentProductLinkPath: '', - formPath: '' + formPath: '', + copyUrl: '', }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ onLoad(options) { - if (options.scene) { - this.getBookInfo(options.scene) + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + loginInfo(app, (data) => { + // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� + if (data) { + if (options.scene) { + this.getBookInfo(options.scene) + } + } + }) + } else { + if (options.scene) { + this.getBookInfo(options.scene) + } } + }, /** @@ -40,8 +57,8 @@ getBookInfo(refcode) { const obj = { - storeInfo: app.config.jslx, - path: app.config.jslx, + storeInfo: app.config.goodsStore, + path: app.config.goodsStore, queryType: 'ProductCmsItem', SysType: "CmsItem", RefCode: refcode, @@ -79,7 +96,7 @@ book.learnSelectType == "audio" ) { url = "/packageDomain/pages/resourceDetails/myAudio/index"; - } else if (book.selectType == "picture" || book.selectType == "zip") { + } else if (book.selectType == "picture") { url = "/packageDomain/pages/resourceDetails/document/index"; } this.setData({ @@ -91,59 +108,55 @@ formPath: book.learnSelectType ? 'jsek_cloudLearning' : '' }) wx.redirectTo({ - url: `${url}?productLinkPath=${this.data.productLinkPath}&parentProductLinkPath=${this.data.parentProductLinkPath}&bookId=${book.productLinkInfo.ProductId}&bookName=${book.productLinkInfo.Name}&cmsId=${book.id}&storeInfo=${book.storeInfo}&formPath=${this.data.formPath}`, + url: `${url}?productLinkPath=${this.data.productLinkPath}&parentProductLinkPath=${this.data.parentProductLinkPath}&bookId=${book.productLinkInfo.ProductId}&activeId=${book.id}&bookName=${book.productLinkInfo.Name}&cmsId=${book.id}&formPath=${this.data.formPath}`, }); - if (book.selectType == "pdf") { + if (book.selectType == "pdf" || book.selectType == 'document') { const fileLink = book.file ? book.file : book.freeFile console.log(fileLink); - wx.navigateTo({ + wx.redirectTo({ url: "/packageBookService/pages/components/webView/index?md5=" + fileLink + "&fileName=" + book.name + - "&fileType=" + - book.selectType + "&bookBuy=true" + "&fileType=pdf" + "&bookBuy=true" }); } - if (book.selectType == 'document') { + if (book.selectType == 'zip') { const fileLink = book.file ? app.config.requestCtx + "/file/api/ApiDownload?md5=" + book.file : app.config.requestCtx + "/file/api/ApiDownload?md5=" + book.freeFile; console.log(fileLink, "fileLink"); + this.setData({ + copyUrl: fileLink + }) + // wx.redirectTo({ + // url: "/packageBookService/pages/bookServices/webView/index?url=" + fileLink + // }); //鎻愮ず鍔犺浇涓� // 鍗曟涓嬭浇鍏佽鐨勬渶澶ф枃浠朵负 200MB - wx.downloadFile({ - url: fileLink, - filePath: wx.env.USER_DATA_PATH + `/${book.name}.${book.selectType}`, - success: function (res) { - console.log(res, "wx.downloadFile success res"); - if (res.statusCode != 200) { - util.hideLoadingWithErrorTips(); - return false; - } - var Path = res.tempFilePath; //杩斿洖鐨勬枃浠朵复鏃跺湴鍧�锛岀敤浜庡悗闈㈡墦寮�鏈湴棰勮鎵�鐢� - let data = res.filePath; - wx.openDocument({ - filePath: data, - showMenu: true, - success: function (res) { - console.log("鎵撳紑鎴愬姛"); - util.hideLoading(); - }, - }); - }, - fail: function (err) { - console.log(err, "wx.downloadFile fail err"); - util.hideLoadingWithErrorTips(); - }, - }); + } }) }, + copyUrl(e) { + + let url = e.currentTarget.dataset.value + console.log(url) + // wx.setClipboardData(url) + wx.setClipboardData({ + data: `${e.currentTarget.dataset.value}`, + success(res) { + console.log(res.data) // data + }, + fail(err) { + reject(err); + } + }) + }, /** * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� */ -- Gitblit v1.9.1