From ccda9ec2fe70d8f51ef184eafc04b78d22dfbabd Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期三, 26 六月 2024 15:02:28 +0800 Subject: [PATCH] 小程序,教材,课程 --- packageBookService/pages/bookServices/detail/buyResource/index.js | 78 ++++++++++++++++++++++++++++++++++----- 1 files changed, 68 insertions(+), 10 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/buyResource/index.js b/packageBookService/pages/bookServices/detail/buyResource/index.js index 92e8ef6..6cdc969 100644 --- a/packageBookService/pages/bookServices/detail/buyResource/index.js +++ b/packageBookService/pages/bookServices/detail/buyResource/index.js @@ -19,7 +19,8 @@ checkAllState: true, productLinkPath: '', refCode: '', - haider: false + haider: false, + naData: false }, /** @@ -85,11 +86,48 @@ wx.navigateBack(); }, + // 鑾峰彇鎵�鏈夊瓙椤规暟閲� + getChildrenItem(data) { + let num = 0 + + function getNum(data) { + for (let index = 0; index < data.length; index++) { + const item = data[index]; + if (item.sysType == 'CmsItem') { + num += 1 + } else if (item.sysType == 'CmsFolder') { + if (item.children && item.children.length) + getNum(item.children) + } + } + } + getNum(data) + return num + }, + + // 缁櫬风洰褰曟坊鍔犲瓙椤规暟閲� + changeResourceChildren(list) { + const changeList = (list) => { + for (let index = 0; index < list.length; index++) { + const item = list[index]; + if (item.sysType == 'CmsFolder' && item.children && item.children.length) { + item.childrenItem = this.getChildrenItem([item]) + changeList(item.children) + } else if (item.sysType == 'CmsFolder' && item.children && !item.children.length) { + item.childrenItem = 0 + } else if (item.sysType == 'CmsFolder' && !item.children) { + item.childrenItem = 0 + } + } + } + changeList(list) + return list + }, + // 鎵佸钩鍖栨暟鎹浆鎹ree getTreeList(rootList, pathLength, newArr, path) { for (const item of rootList) { - if (item.productLinkPath.length == pathLength && item.productLinkPath.includes(path)) { - item.checked = false; + if ((pathLength - item.productLinkPath.length >= 0 && pathLength - item.productLinkPath.length <= 3) && item.productLinkPath.includes(path)) { if (item.sysType == 'CmsItem') { if (item.selectType == 'webpage') { item.disabled = true @@ -101,13 +139,14 @@ if (item.file && item.fileMap && item.fileMap[item.file]) { if (item.fileMap[item.file].protectType == 'Private') item.disabled = true } - - item.isbuy = this.isShowNeedBuy(item); - item.isShopCar = this.isShoppingCart(item); } // newArr.push(item) - // 鍦ㄦ彃鍏ヨ繃绋嬩腑瀵规暟鎹繘琛屾帓搴� - newArr = this.insertAndSortObjectsByProductLinkPath(newArr, item) + // 鍦ㄦ彃鍏ヨ繃绋嬩腑瀵规暟鎹繘琛屾帓搴� 骞朵笖鍘婚櫎宸茬粡棰嗗彇鍜岃喘涔扮殑 + if (item.sysType == 'CmsFolder') { + newArr = this.insertAndSortObjectsByProductLinkPath(newArr, item) + } else if (item.sysType == 'CmsItem' && this.resourceIsBuy(item)) { + newArr = this.insertAndSortObjectsByProductLinkPath(newArr, item) + } } } //缁欐暟缁勯噷闈㈠啀娣诲姞涓�涓猚hildren鐨勭┖鏁扮粍 @@ -195,6 +234,7 @@ itemFields: { SysType: 'CmsFolder', // 璧勬簮绫诲瀷锛岃瘯璇绘枃浠讹紝鏄惁鍏佽涓嬭浇绛夊弬鏁� + learnSelectType: [], selectType: [], freeFile: [], file: [], @@ -239,8 +279,20 @@ } } }); - this.getTreeList(res.datas.cmsDatas[0].datas, 17, list, '\\') + // 鏄剧ず 闇�瑕佽喘涔扮殑鍜岄渶瑕佸厤璐归鍙栫殑 + // const arr = res.datas.cmsDatas[0].datas.filter(item => this.resourceIsBuy(item)) + // if (!arr.length) { + // return this.setData({ + // loading: false, + // haider: true, + // noData: true + // }) + // } + // debugger + const num = query.cmsPath.length + 6 + this.getTreeList(res.datas.cmsDatas[0].datas, num, list, '\\') list = this.ensureTreeConsistency(list) + list = this.changeResourceChildren(list) console.log('淇敼鍚庝簯', list); let result = []; if (type.refCode == "jsek_teachingResources") { @@ -520,7 +572,7 @@ if (isSHow) { return false; } else { - return data.saleMethod[0].price > 0 ? true : false; + return data.saleMethod[0].Price > 0 ? true : false; } return !isSHow; } else { @@ -594,6 +646,12 @@ }, //璐拱鎸夐挳 batchPurchase() { + if (!this.data.learn.length) { + return wx.showToast({ + icon: "error", + title: '鏆傛棤鏁版嵁', + }) + } let saleMethodIds = []; let requests = []; let item = []; -- Gitblit v1.9.1