From e060ad2b2da9884e00b36796548eacc6a2b9a5d3 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期五, 29 三月 2024 09:44:30 +0800 Subject: [PATCH] 图书详情,列表页bug修改 --- packageBookService/pages/bookServices/detail/components/tree/index.js | 130 ++++++++++++++++++++++-------------------- 1 files changed, 68 insertions(+), 62 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js index 675c529..715f67e 100644 --- a/packageBookService/pages/bookServices/detail/components/tree/index.js +++ b/packageBookService/pages/bookServices/detail/components/tree/index.js @@ -1,5 +1,7 @@ -import Message from 'tdesign-miniprogram/message/message'; const util = require('./components/util') // 寮曞叆灏佽杩囩殑鍔犺浇鎻愮ず +import { + loginInfo +} from '../../../../../../assets/js/login' const app = getApp() Component({ // checked: false, @@ -127,71 +129,75 @@ }, // 璺宠浆闊宠棰戞挱鏀惧櫒 goPlayer(e) { - if (this.properties.isShowCheck) return true - const item = e.currentTarget.dataset.item - const parent = e.currentTarget.dataset.parent - let url - if (item.selectType == 'video' || item.learnSelectType == 'video') { - url = '/packageDomain/pages/resourceDetails/myVideo/index' - } else if (item.selectType == 'audio' || item.learnSelectType == 'audio') { - url = '/packageDomain/pages/resourceDetails/myAudio/index' - } else if (item.selectType == 'picture' || item.selectType == 'zip') { - url = '/packageDomain/pages/resourceDetails/document/index' - } - if (this.properties.tab == 'jsek_cloudLearning' && this.resourceIsBuy(item)) { - return wx.showToast({ - icon: 'error', - title: '璇峰厛璐拱璇ヨ祫婧�', - }) - } - wx.navigateTo({ - url: `${url}?productLinkPath=${item.productLinkPath}&parentProductLinkPath=${parent.productLinkPath}&parentName=${parent.name}&activeId=${item.id}&bookId=${this.properties.bookInfo.id}&bookName=${this.properties.bookInfo.name}&cmsId=${this.properties.bookInfo.rootCmsItemId}`, - }) - - - if (item.selectType == 'document' || item.selectType == 'pdf') { - const fileLink = app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file - console.log(fileLink, 'fileLink'); - //鎻愮ず鍔犺浇涓� - util.showLoading() - // 鍗曟涓嬭浇鍏佽鐨勬渶澶ф枃浠朵负 200MB - wx.downloadFile({ - url: fileLink, // 鍦板潃宸叉墦鐮侊紝鑷繁鎹釜鍏朵粬鐨勫湴鍧�锛�"https://www.xxxxx.com/file/娴嬭瘯閫氱煡.pdf"锛� - success: function (res) { - console.log(res, "wx.downloadFile success res") - if (res.statusCode != 200) { - util.hideLoadingWithErrorTips() - return false - } - var Path = res.tempFilePath //杩斿洖鐨勬枃浠朵复鏃跺湴鍧�锛岀敤浜庡悗闈㈡墦寮�鏈湴棰勮鎵�鐢� - wx.openDocument({ - filePath: Path, - showMenu: true, - success: function (res) { - console.log('鎵撳紑鎴愬姛'); - util.hideLoading() - } - }) - }, - fail: function (err) { - console.log(err, "wx.downloadFile fail err"); - util.hideLoadingWithErrorTips() + // 妫�鏌ョ櫥褰曠姸鎬� + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + loginInfo(app, (data) => { + // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� + if (data) { + // 鐧诲綍鎴愬姛锛岃嚜鍔ㄨ褰晅oken鍜岀敤鎴蜂俊鎭紝骞惰繑鍥瀟rue + } else { + // 鍑虹幇閿欒锛岃繑鍥瀎alse } }) - - - } - - if (item.selectType == 'webpage') { - console.log(11); - this.setData({ - webpageSrc: item.jsek_link + } else { + if (this.properties.isShowCheck) return true + const item = e.currentTarget.dataset.item + const parent = e.currentTarget.dataset.parent + let url + if (item.selectType == 'video' || item.learnSelectType == 'video') { + url = '/packageDomain/pages/resourceDetails/myVideo/index' + } else if (item.selectType == 'audio' || item.learnSelectType == 'audio') { + url = '/packageDomain/pages/resourceDetails/myAudio/index' + } else if (item.selectType == 'picture' || item.selectType == 'zip') { + url = '/packageDomain/pages/resourceDetails/document/index' + } + if (this.properties.tab == 'jsek_cloudLearning' && this.resourceIsBuy(item)) { + return wx.showToast({ + icon: 'error', + title: '璇峰厛璐拱璇ヨ祫婧�', + }) + } + wx.navigateTo({ + url: `${url}?productLinkPath=${item.productLinkPath}&parentProductLinkPath=${parent.productLinkPath}&parentName=${parent.name}&activeId=${item.id}&bookId=${this.properties.bookInfo.id}&bookName=${this.properties.bookInfo.name}&cmsId=${this.properties.bookInfo.rootCmsItemId}`, }) - console.log(this.data.webpageSrc, 'webpageSrc'); + if (item.selectType == 'document' || item.selectType == 'pdf') { + const fileLink = app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file + console.log(fileLink, 'fileLink'); + //鎻愮ず鍔犺浇涓� + util.showLoading() + // 鍗曟涓嬭浇鍏佽鐨勬渶澶ф枃浠朵负 200MB + wx.downloadFile({ + url: fileLink, // 鍦板潃宸叉墦鐮侊紝鑷繁鎹釜鍏朵粬鐨勫湴鍧�锛�"https://www.xxxxx.com/file/娴嬭瘯閫氱煡.pdf"锛� + success: function (res) { + console.log(res, "wx.downloadFile success res") + if (res.statusCode != 200) { + util.hideLoadingWithErrorTips() + return false + } + var Path = res.tempFilePath //杩斿洖鐨勬枃浠朵复鏃跺湴鍧�锛岀敤浜庡悗闈㈡墦寮�鏈湴棰勮鎵�鐢� + wx.openDocument({ + filePath: Path, + showMenu: true, + success: function (res) { + console.log('鎵撳紑鎴愬姛'); + util.hideLoading() + } + }) + }, + fail: function (err) { + console.log(err, "wx.downloadFile fail err"); + util.hideLoadingWithErrorTips() + } + }) + } + if (item.selectType == 'webpage') { + this.setData({ + webpageSrc: item.jsek_link + }) + console.log(this.data.webpageSrc, 'webpageSrc'); + } } - - - }, // 鎷垮埌鎵�鏈夐」 getAllChildren(id) { -- Gitblit v1.9.1