From e38c14de9637d22d0a35ae06bede82dcf31b64ec Mon Sep 17 00:00:00 2001 From: YM <479443481@qq.com> Date: 星期二, 10 九月 2024 16:52:58 +0800 Subject: [PATCH] 1 --- packageBookService/pages/bookServices/detail/components/tree/index.js | 275 +++++++++++++++++++++--------------------------------- 1 files changed, 109 insertions(+), 166 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js index ef5aa5a..fd3b476 100644 --- a/packageBookService/pages/bookServices/detail/components/tree/index.js +++ b/packageBookService/pages/bookServices/detail/components/tree/index.js @@ -11,7 +11,7 @@ }, learnList: { type: Array, - value: [] + value: [], }, bookInfo: { type: Object, @@ -48,6 +48,9 @@ checkAllState: { type: Boolean, }, + deadline: { + type: String, + }, }, data: { sonPurchaseSaleMethodId: "", @@ -58,7 +61,8 @@ selectAll: [], shoppingCart: true, stop: false, - cart: true + cart: true, + canExecute: true }, ready() {}, @@ -92,6 +96,7 @@ }, // 鑺傜偣灞曞紑 handleChange(e) { + console.log(e.detail.value); this.setData({ openIds: e.detail.value, }); @@ -132,26 +137,17 @@ goPlayer(e) { // 妫�鏌ョ櫥褰曠姸鎬� const token = wx.getStorageSync(app.config.tokenKey); - if (token) { 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 : '鏁欏璧勬簮' - let url; + const parentProductLinkPath = parent ? + parent.productLinkPath : + wx.getStorageSync("teachResourcesPath"); + const parentName = parent ? parent.name : "鏁欏璧勬簮"; if (this.properties.isShowCheck && this.resourceIsBuy(item)) { return false; } - 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) @@ -162,126 +158,66 @@ "璇峰厛璐拱璇ヨ祫婧�" : "璇峰厛鐐瑰嚮棰嗗彇鏌ョ湅鎸夐挳", }); } - 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(fileLink, "fileLink"); - //鎻愮ず鍔犺浇涓� - util.showLoading(); - // 鍗曟涓嬭浇鍏佽鐨勬渶澶ф枃浠朵负 200MB - wx.downloadFile({ - url: fileLink, - 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 (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: "璧勬簮涓嶅彲鐢紝璇疯仈绯荤鐞嗗憳", + }); + } + } else if ((this.properties.tab == "jsek_teachingResources" || this.properties.tab == "jsek_cloudLearning") && (!item.file && !item.freeFile && !item.protectedFile)) { + return wx.showToast({ + icon: 'error', + title: '鏆傛棤璧勬簮', + }) } + if (item.selectType == 'zip') { + if (this.properties.applyState == 'Normal') { + return wx.showToast({ + icon: 'error', + title: '璇峰墠寰�PC绔笅杞�', + }) + } else { + return wx.showToast({ + icon: 'error', + title: '璇峰厛鐢宠涓嬭浇', + }) + } + } - - - - - - - - - - - - - - - - - - - - - - // 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(); - // }, - // }); - // } - - - - - + let url; if (item.selectType == "webpage") { - this.setData({ - webpageSrc: item.jsek_link, - }); - console.log(this.data.webpageSrc, "webpageSrc"); + // 缃戦〉绫诲瀷璺宠浆鍒扮綉鍧�澶嶅埗椤碉紝鍥犱负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}` + }) } + + 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") { + 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}`, + }); } }, @@ -348,7 +284,6 @@ for (let node of tree) { findAndUpdate(node); // 瀵规瘡涓《灞傝妭鐐规墽琛屾煡鎵惧拰鏇存柊鎿嶄綔 } - // console.log(tree, 'tree345'); return tree; // 杩斿洖淇敼鍚庣殑瀹屾暣鏁扮粍 }, @@ -425,15 +360,20 @@ // 杩欎釜鏃跺�檆hecked鐨勫�兼槸fals let checkResourceTitleList = []; const item = e.currentTarget.dataset.item; - const parent = this.findParentById(this.properties.learnList, item.id) - let childrenList - let flagNum - if (parent) childrenList = parent.children.filter(citem => citem.id !== item.id) - if (childrenList) flagNum = childrenList.findIndex(item => item.checked == false) + const parent = this.findParentById(this.properties.learnList, item.id); + let childrenList; + let flagNum; + if (parent) + childrenList = parent.children.filter((citem) => citem.id !== item.id); + if (childrenList) + flagNum = childrenList.findIndex((item) => item.checked == false); let list = this.flattenTree([item]); let ids = []; list.forEach((item) => { - if (item.sysType == 'CmsFolder' || (item.sysType == 'CmsItem' && item.saleMethod.length)) + if ( + item.sysType == "CmsFolder" || + (item.sysType == "CmsItem" && item.saleMethod.length) + ) ids.push(item.id); }); var myEventDetail = { @@ -446,7 +386,7 @@ }; // 瑙﹀彂浜嬩欢鐨勯�夐」 this.triggerEvent("changeListChecked", myEventDetail, myEventOption); if (flagNum == -1) { - let checkedState + let checkedState; var myEventDetail = { ids: [parent.id], flag, @@ -477,14 +417,17 @@ // 瀛愰」鍕鹃�� checkResource(e) { const citem = e.currentTarget.dataset.item; - const parent = e.currentTarget.dataset.parent - let outermost - if (parent) outermost = this.findParentById(this.properties.learnList, parent.id) - const childrenList = parent.children.filter(item => item.id !== citem.id && item.saleMethod.length) - const flag = childrenList.findIndex(item => item.checked == false) + const parent = e.currentTarget.dataset.parent; + let outermost; + if (parent) + outermost = this.findParentById(this.properties.learnList, parent.id); + const childrenList = parent.children.filter( + (item) => item.id !== citem.id && item.saleMethod.length + ); + const flag = childrenList.findIndex((item) => item.checked == false); // 鏀瑰彉璇ラ」checked var myEventDetail = { - id: citem.id + id: citem.id, }; var myEventOption = { bubbles: true, @@ -493,8 +436,8 @@ this.triggerEvent("changeResourceChecked", myEventDetail, myEventOption); // 閫氳繃鍒ゆ柇,鑱旈�氱埗绾hecked if (flag == -1) { - let checkedState - citem.checked == false ? checkedState = true : checkedState = false + let checkedState; + citem.checked == false ? (checkedState = true) : (checkedState = false); var myEventDetail = { ids: [parent.id], flag: checkedState, @@ -519,9 +462,14 @@ } // 鑱旈�氭渶澶栧眰绾hecked, 濡傛灉鎵�鏈夊瓙椤瑰嬀閫�, 涓斿綋鍓嶆渶澶栧眰鏈嬀閫�, 鍒欏姞涓婃渶澶栧眰鐨勫嬀閫� if (!citem.checked && outermost) { - let allchildren = this.flattenTree([outermost]) - allchildren = allchildren.filter(item => item.sysType == 'CmsItem' && item.id !== citem.id && item.saleMethod.length) - const satate = allchildren.findIndex(item => item.checked == false) + let allchildren = this.flattenTree([outermost]); + allchildren = allchildren.filter( + (item) => + item.sysType == "CmsItem" && + item.id !== citem.id && + item.saleMethod.length + ); + const satate = allchildren.findIndex((item) => item.checked == false); if (satate == -1) { var myEventDetail = { ids: [outermost.id], @@ -555,7 +503,7 @@ async onCloudShoppingCart(e) { let shoppingCartGetId = []; - const item = e.currentTarget.dataset.item + const item = e.currentTarget.dataset.item; console.log(item.isShopCar); const saleMethodId = e.currentTarget.dataset.item.saleMethod[0].Id; console.log(saleMethodId); @@ -565,16 +513,13 @@ filterList: [], searchList: [], }; - const res = await app.MG.store.getShoppingCartProductList(query); res.datas.forEach((item) => { shoppingCartGetId.push(item.saleMethod.id); }); if (shoppingCartGetId.includes(saleMethodId)) { - console.log(111); // this.data.updateShoppingCartHidden(); // this.data.updateCloudLearning(); - wx.showToast({ icon: "error", title: "宸叉坊鍔�", @@ -597,10 +542,9 @@ icon: "success", title: "娣诲姞鎴愬姛", }); - item.isShopCar = false - this.triggerEvent("updateCloudLearning") + item.isShopCar = false; + this.triggerEvent("updateCloudLearning"); } - } }, sadd() { @@ -610,23 +554,22 @@ findParentById(arr, id) { for (let i = 0; i < arr.length; i++) { const item = arr[i]; - // 妫�鏌ュ綋鍓嶉」鏄惁鍖归厤锛堝嵆瀹冩槸涓嶆槸鎴戜滑瑕佹壘鐨勯」锛� + // 妫�鏌ュ綋鍓嶉」鏄惁鍖归厤锛堝嵆瀹冩槸涓嶆槸鎴戜滑瑕佹壘鐨勯」锛� if (item.id === id) { - // 濡傛灉褰撳墠椤瑰氨鏄垜浠鎵剧殑椤癸紝鍒欏畠娌℃湁鐖剁骇锛岃繑鍥� null + // 濡傛灉褰撳墠椤瑰氨鏄垜浠鎵剧殑椤癸紝鍒欏畠娌℃湁鐖剁骇锛岃繑鍥� null return null; } - // 閫掑綊鏌ユ壘褰撳墠椤圭殑瀛愰」 + // 閫掑綊鏌ユ壘褰撳墠椤圭殑瀛愰」 const child = this.findChildById(item.children, id); if (child) { - // 濡傛灉鍦ㄥ瓙椤逛腑鎵惧埌鍖归厤鐨勯」锛岃繑鍥炲綋鍓嶉」浣滀负鐖剁骇 + // 濡傛灉鍦ㄥ瓙椤逛腑鎵惧埌鍖归厤鐨勯」锛岃繑鍥炲綋鍓嶉」浣滀负鐖剁骇 return item; } } - // 濡傛灉娌℃湁鎵惧埌鍖归厤鐨勭埗椤癸紝杩斿洖 null + // 濡傛灉娌℃湁鎵惧埌鍖归厤鐨勭埗椤癸紝杩斿洖 null return null; }, - - // 杈呭姪鍑芥暟锛岀敤浜庨�掑綊鏌ユ壘瀛愰」 + // 杈呭姪鍑芥暟锛岀敤浜庨�掑綊鏌ユ壘瀛愰」 findChildById(children, id) { if (!children) { return null; @@ -634,17 +577,17 @@ for (let i = 0; i < children.length; i++) { const child = children[i]; if (child.id === id) { - // 濡傛灉鎵惧埌鍖归厤鐨勯」锛岃繑鍥炲畠 + // 濡傛灉鎵惧埌鍖归厤鐨勯」锛岃繑鍥炲畠 return child; } - // 閫掑綊妫�鏌ュ瓙椤圭殑瀛愰」 + // 閫掑綊妫�鏌ュ瓙椤圭殑瀛愰」 const subChild = this.findChildById(child.children, id); if (subChild) { return subChild; } } - // 濡傛灉娌℃湁鎵惧埌鍖归厤鐨勯」锛岃繑鍥� null + // 濡傛灉娌℃湁鎵惧埌鍖归厤鐨勯」锛岃繑鍥� null return null; - } + }, }, }); \ No newline at end of file -- Gitblit v1.9.1