From c2cd778fd3f40a75df483758bb2f1fe1dedc7eef Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期五, 26 四月 2024 09:49:25 +0800 Subject: [PATCH] 资源购买页请求慢优化 --- packageBookService/pages/bookServices/detail/components/tree/index.js | 90 +++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 86 insertions(+), 4 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js index 5d4a08b..77b7035 100644 --- a/packageBookService/pages/bookServices/detail/components/tree/index.js +++ b/packageBookService/pages/bookServices/detail/components/tree/index.js @@ -165,15 +165,19 @@ wx.navigateTo({ url: `${url}?productLinkPath=${item.productLinkPath}&parentProductLinkPath=${parentProductLinkPath}&parentName=${parentName}&activeId=${item.id}&bookId=${this.properties.bookInfo.id}&bookName=${this.properties.bookInfo.name}&cmsId=${this.properties.bookInfo.rootCmsItemId}&formPath=${this.properties.tab}`, }); + + if (item.selectType == "document" || item.selectType == "pdf") { - const fileLink = - app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.file; + console.log(item, 'item789'); + // freeFile + const fileLink = item.file ? + app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.file : app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.freeFile console.log(fileLink, "fileLink"); //鎻愮ず鍔犺浇涓� util.showLoading(); // 鍗曟涓嬭浇鍏佽鐨勬渶澶ф枃浠朵负 200MB wx.downloadFile({ - url: fileLink, // 鍦板潃宸叉墦鐮侊紝鑷繁鎹釜鍏朵粬鐨勫湴鍧�锛�"https://www.xxxxx.com/file/娴嬭瘯閫氱煡.pdf"锛� + url: fileLink, success: function (res) { console.log(res, "wx.downloadFile success res"); if (res.statusCode != 200) { @@ -196,6 +200,84 @@ }, }); } + + + + + + + + + + + + + + + + + + + + + + + + // if (item.selectType == "document" || item.selectType == "pdf") { + // const fileLink = app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.file; + + // let filePath = wx.env.USER_DATA_PATH + '/' + item.name + // console.log(filePath, 'filePath'); + // //鎻愮ず鍔犺浇涓� + // util.showLoading(); + // // 鍗曟涓嬭浇鍏佽鐨勬渶澶ф枃浠朵负 200MB + // wx.downloadFile({ + // url: fileLink, + // success: function (res) { + + // if (res.statusCode != 200) { + // util.hideLoadingWithErrorTips(); + // return false; + // } + // var Path = res.tempFilePath; //杩斿洖鐨勬枃浠朵复鏃跺湴鍧�锛岀敤浜庡悗闈㈡墦寮�鏈湴棰勮鎵�鐢� + + // wx.saveFile({ + // tempFilePath: Path, + // success: function (res) { + // var savedFilePath = res.savedFilePath; + // // 灏嗘枃浠朵繚瀛樹负 item.name + // wx.saveFile({ + // tempFilePath: savedFilePath, + // filePath: wx.env.USER_DATA_PATH + '/' + item.name, + // success: function (res) { + // wx.openDocument({ + // filePath: res.savedFilePath, + // showMenu: true, + // success: function (res) { + // util.hideLoading(); + // }, + // }); + // }, + // fail: function (err) { + // util.hideLoadingWithErrorTips(); + // } + // }); + // }, + // fail: function (err) { + // util.hideLoadingWithErrorTips(); + // } + // }); + // }, + // fail: function (err) { + // util.hideLoadingWithErrorTips(); + // }, + // }); + // } + + + + + if (item.selectType == "webpage") { this.setData({ webpageSrc: item.jsek_link, @@ -204,6 +286,7 @@ } } }, + // 鎷垮埌鎵�鏈夐」 getAllChildren(id) { let result = []; @@ -519,7 +602,6 @@ item.isShopCar = false this.triggerEvent("updateCloudLearning") } - } }, sadd() { -- Gitblit v1.9.1