From 04c7b0163caeae4ab1c5da62e301fa993101cfad Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期一, 31 三月 2025 10:40:45 +0800 Subject: [PATCH] bug修改 --- packageBookService/pages/bookServices/detail/components/tree/index.js | 189 ++++++++++++++++++++++++----------------------- 1 files changed, 97 insertions(+), 92 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js index 185b9d2..d7151ef 100644 --- a/packageBookService/pages/bookServices/detail/components/tree/index.js +++ b/packageBookService/pages/bookServices/detail/components/tree/index.js @@ -53,6 +53,12 @@ }, cloundMenuIsBuy: { type: Boolean + }, + learnMenu: { + type: Object + }, + isCloundHaveSaleMethod: { + type: Boolean } }, data: { @@ -66,7 +72,6 @@ purchaseList: [] }, ready() {}, - onLoad() {}, observers: { treeList: function (newValue) { @@ -160,105 +165,107 @@ // 璺宠浆闊宠棰戞挱鏀惧櫒 goPlayer(e) { // 妫�鏌ョ櫥褰曠姸鎬� - const token = wx.getStorageSync(app.config.tokenKey); - if (!token) return false - const item = e.currentTarget.dataset.item; - const parent = e.currentTarget.dataset.parent; - const parentProductLinkPath = parent ? - parent.productLinkPath : - wx.getStorageSync("teachResourcesPath"); - const parentName = parent ? parent.name : "鏁欏璧勬簮"; - // 璧勬簮璐拱椤甸潰(鍙睍绀烘湭璐拱璧勬簮) 鐐瑰嚮涓嶈烦杞� - if (this.properties.isShowCheck) return false; - if (item.selectType == "webpage") { - // 缃戦〉绫诲瀷璺宠浆鍒扮綉鍧�澶嶅埗椤碉紝鍥犱负url浼犲弬涓嶈兘浼� 甯﹀弬鏁扮殑缃戠粶鍦板潃锛屾墍浠ユ澶勮鎶婄綉缁滃湴鍧�閲岀殑浼犲弬鎽樺嚭鏉ワ紝鏀惧埌url閲� - let urlData = '' - const flags = item.jsek_link.indexOf("?") - if (flags > -1) { - urlData = item.jsek_link.slice(flags + 1, item.jsek_link.length) + const goPlayerFun = () => { + const item = e.currentTarget.dataset.item; + const parent = e.currentTarget.dataset.parent; + const parentProductLinkPath = parent ? + parent.productLinkPath : + wx.getStorageSync("teachResourcesPath"); + const parentName = parent ? parent.name : "鏁欏璧勬簮"; + // 璧勬簮璐拱椤甸潰(鍙睍绀烘湭璐拱璧勬簮) 鐐瑰嚮涓嶈烦杞� + if (this.properties.isShowCheck) return false; + if (item.selectType == "webpage" || item.learnSelectType == "webpage") { + // 缃戦〉绫诲瀷璺宠浆鍒扮綉鍧�澶嶅埗椤碉紝鍥犱负url浼犲弬涓嶈兘浼� 甯﹀弬鏁扮殑缃戠粶鍦板潃锛屾墍浠ユ澶勮鎶婄綉缁滃湴鍧�閲岀殑浼犲弬鎽樺嚭鏉ワ紝鏀惧埌url閲� + let urlData = '' + const flags = item.jsek_link.indexOf("?") + if (flags > -1) { + urlData = item.jsek_link.slice(flags + 1, item.jsek_link.length) + } + url = '/packageBookService/pages/bookServices/linkPage/index' + return wx.navigateTo({ + url: urlData ? url + `?path=${item.jsek_link.slice(0,flags)}` + '&' + urlData : url + `?path=${item.jsek_link}` + }) } - url = '/packageBookService/pages/bookServices/linkPage/index' - return wx.navigateTo({ - url: urlData ? url + `?path=${item.jsek_link.slice(0,flags)}` + '&' + urlData : url + `?path=${item.jsek_link}` - }) - } - if (!item.file && !item.freeFile && !item.protectedFile) { - return wx.showToast({ - icon: 'error', - title: '鏆傛棤璧勬簮', - }) - } - if (item.selectType == 'zip') { - if (this.properties.applyState == 'Normal') { + if (!item.file && !item.freeFile && !item.protectedFile) { + return wx.showToast({ + icon: 'error', + title: '鏆傛棤璧勬簮', + }) + } + if (item.selectType == 'zip' || item.learnSelectType == 'zip') { return wx.showToast({ icon: 'error', title: '璇峰墠寰�PC绔笅杞�', }) - } else { - return wx.showToast({ - icon: 'error', - title: '璇峰厛鐢宠涓嬭浇', - }) } - } - if (this.properties.tab == "jsek_teachingResources" && (item.file || item.freeFile)) { - let file = item.fileMap[item.file] ? item.fileMap[item.file] : item.fileMap[item.freeFile] - if (file && file.protectType !== "Public") { - return wx.showToast({ - icon: "error", - title: "璧勬簮涓嶅彲鐢紝璇疯仈绯荤鐞嗗憳", - }); - } - } - if (this.properties.tab == "jsek_cloudLearning") { - // 鍒ゆ柇鐖剁骇鎴栬嚜韬槸鍚﹁喘涔� - var myEventOption = { - bubbles: true, - composed: true, - }; - // 鍑哄彂鍒ゆ柇浜戝涔犳槸鍚﹁喘涔板垽鏂� - this.triggerEvent("getCloundIsBuy", {}, myEventOption) - if (!this.properties.cloundMenuIsBuy) { - // 浜戝涔犳湭璐拱锛屾煡鎵句互璐拱鐨勭洰褰曞拰璧勬簮鏈韩 - const learn = this.handleTreeData(this.properties.treeList).filter( - (citem) => citem.saleMethod && - citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal') && - new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').EndDate).getTime() >= new Date().getTime() && - new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime() && - item.productLinkPath.includes(citem.productLinkPath) - ) - // 璧勬簮鍜岀埗绾х洰褰曢兘鏃犻攢鍞柟寮� - // if (!learn.length) return wx.showToast({ - // icon: 'error', - // title: '鏆傛湭寮�鍞�', - // }) - const buyList = learn.filter((citem) => this.properties.buyIds.includes(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').Id)) - // 璧勬簮鍜屾湰韬兘鏈喘涔� - if (!buyList.length) { - const itemSaleMethod = item.saleMethod && item.saleMethod.length ? item.saleMethod.find(citem => citem.SaleType == 'Normal') : undefined + if (this.properties.tab == "jsek_teachingResources" && (item.file || item.freeFile)) { + let file = item.fileMap[item.file] ? item.fileMap[item.file] : item.fileMap[item.freeFile] + if (file && file.protectType !== "Public") { return wx.showToast({ - icon: 'error', - title: itemSaleMethod && itemSaleMethod.Price == 0 ? '璇峰厛棰嗗彇璧勬簮' : '璇峰厛璐拱璧勬簮', - }) + icon: "none", + title: "璧勬簮涓嶅彲鐢紝璇疯仈绯荤鐞嗗憳", + }); } } + if (this.properties.tab == "jsek_cloudLearning") { + // 1.鎵惧嚭鎵�鏈夌埗绾х洰褰曞拰鏈韩(鏈夐攢鍞柟寮�) 鍜� 浜戝涔犳湰韬�(鏈夐攢鍞柟寮�) 鏀惧埌涓�涓暟缁� 涓虹┖鍒欐殏鏈紑鏀鹃攢鍞� + let learn = [] + if (this.properties.isCloundHaveSaleMethod) { + // 1.1 浜戝涔犳湁閿�鍞柟寮忥紝鍔犲叆鐖剁骇鏁扮粍 + learn.push(this.properties.learnMenu) + } else { + // 1.2 浜戝涔犳棤閿�鍞柟寮忥紝灏嗙埗绾х洰褰曞拰鏈韩鍔犲叆鏁扮粍 + learn = this.handleTreeData(this.properties.learnList).filter( + (citem) => citem.saleMethod && + citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal' && ditem.Price > 0) && + new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').EndDate).getTime() >= new Date().getTime() && + new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime() && + item.productLinkPath.includes(citem.productLinkPath) + ) + } + // 2.鎵惧嚭杩欎釜鏁扮粍閲屽凡璐拱鐨� 褰㈡垚鏂版暟缁� 涓虹┖鍒欐湭璐拱 + let buyList = [] + if (learn.length) buyList = learn.filter((item) => this.properties.buyIds.includes(item.saleMethod.find((citem) => citem.SaleType == 'Normal').Id)) + // 鏈夌埗绾�(鍖呭惈閿�鍞柟寮�)锛屼笖鏈喘涔� + if (learn.length && !buyList.length && !item.freeFile) return wx.showToast({ + icon: 'error', + title: '璇峰厛璐拱璇ヨ祫婧�', + }) + if (item.protectedFile || item.freeFile) { + let file = item.fileMap[item.protectedFile] ? item.fileMap[item.protectedFile] : item.fileMap[item.freeFile] + if (file && file.protectType !== "Public") { + return wx.showToast({ + icon: 'none', + title: "璧勬簮涓嶅彲鐢紝璇疯仈绯荤鐞嗗憳", + }); + } + } + } + let url; + if (item.selectType == "video" || item.learnSelectType == "video") { + url = "/packageDomain/pages/resourceDetails/myVideo/index"; + } + if ( + item.selectType == "audio" || + item.learnSelectType == "audio" + ) { + url = "/packageDomain/pages/resourceDetails/myAudio/index"; + } + if (item.selectType == "picture" || item.selectType == 'document' || item.selectType == 'pdf' || item.learnSelectType == "picture" || item.learnSelectType == 'document' || item.learnSelectType == 'pdf') { + url = "/packageDomain/pages/resourceDetails/document/index"; + } + 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}&applyState=${this.properties.applyState}&deadline=${this.properties.deadline}`, + }); } - let url; - if (item.selectType == "video" || item.learnSelectType == "video") { - url = "/packageDomain/pages/resourceDetails/myVideo/index"; + const token = wx.getStorageSync(app.config.tokenKey); + if (!token && this.data.tab != 'jsek_teachingResources') { + loginInfo(app, (data) => { + if (data) {} + }) + } else { + goPlayerFun() } - if ( - item.selectType == "audio" || - item.learnSelectType == "audio" - ) { - url = "/packageDomain/pages/resourceDetails/myAudio/index"; - } - if (item.selectType == "picture" || item.selectType == 'document') { - url = "/packageDomain/pages/resourceDetails/document/index"; - } - 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}&applyState=${this.properties.applyState}&deadline=${this.properties.deadline}`, - }); }, // 鎷垮埌鎵�鏈夐」 @@ -412,7 +419,6 @@ this.setData({ openIds: this.data.openIds, }); - wx.hideLoading() }, // 瀛愰」鍕鹃�� checkResource(e) { @@ -483,7 +489,6 @@ this.triggerEvent("changeListChecked", myEventDetail, myEventOption); } } - wx.hideLoading() }, // 鍔犲叆璐墿杞� async onCloudShoppingCart(e) { @@ -502,7 +507,7 @@ }); if (shoppingCartGetId.includes(saleMethodId)) { wx.showToast({ - icon: "error", + icon: "success", title: "宸叉坊鍔�", }); this.setData({ -- Gitblit v1.9.1