From b55024ee2f42aa93e0ecaa3113bdeb286f6e59ac Mon Sep 17 00:00:00 2001 From: QYF-GitLab1 <1940665526@qq.com> Date: 星期二, 29 七月 2025 18:01:55 +0800 Subject: [PATCH] 优化按钮显示,教学互动 --- packageBookService/pages/bookServices/detail/index.js | 128 +++++++++++++++++++++++++++++------------- 1 files changed, 89 insertions(+), 39 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js index 772deaf..ba68a88 100644 --- a/packageBookService/pages/bookServices/detail/index.js +++ b/packageBookService/pages/bookServices/detail/index.js @@ -216,7 +216,8 @@ scrollTop: 0, // 鎵爜杩涜祫婧愭粴鍔� source: '', activeId: '', - qrTabValue: '' + qrTabValue: '', + cacheData: [], // 浜戝涔犲垵濮嬫暟鎹� }, // 鎵爜鍒拌祫婧愬垪琛紝婊氬姩鍒拌璧勬簮浣嶇疆 handleScrollTop(e) { @@ -459,9 +460,11 @@ freeEpubPage: [], //epub璇曡鐧惧垎姣� bookEditor: [], //鍥句功缂栬緫 contactInformation: [], //鑱旂郴鏂瑰紡 + IsTextbook: [] // 鏄惁涓烘暀鏉� 濡傛灉鏄暀鏉愮姝㈡樉绀烘墍鏈夎喘涔版寜閽� }, }; app.MG.store.getProductDetail(query).then(async (res) => { + res.datas.IsTextbook = res.datas.IsTextbook == '1' ? true : false this.getResourceCode(id, res.datas.rootCmsItemId) res.datas.bookEditor = res.datas.bookEditor ? res.datas.bookEditor : '-' res.datas.contactInformation = res.datas.contactInformation ? res.datas.contactInformation : '-' @@ -990,23 +993,40 @@ // 杩斿洖鏇存柊鍚庣殑鏁扮粍 return array; }, - // 閫掑綊鏍戠粨鏋勶紝濡傛灉鐖剁骇鏈夐攢鍞柟寮�(鏈夋晥鏈�)锛屽幓鎺夋墍鏈夊瓙闆嗙殑閿�鍞柟寮� - clearTreeSealmethod(clearSaleMethod, tree) { + // 閫掑綊鏍戠粨鏋� + handleSalmethodBtn(tree, data, parent) { for (let item of tree) { - const saleData = item.saleMethod && - item.saleMethod.length ? - item.saleMethod.find((citem) => citem.SaleType == 'Normal') : null - if ( - ((saleData && new Date(saleData.EndDate).getTime() >= new Date().getTime() && new Date(saleData.BeginDate).getTime() <= new Date().getTime()) || - clearSaleMethod) && item.children && item.children.length - ) { - item.children.forEach((ditem) => (ditem.saleMethod = [])) + // 鏄惁鏄剧ず鎸夐挳 + item.isShowIcon = false; + if (item.sysType == 'CmsItem') { + // 鏌ユ壘鐩綍涓嬭祫婧愰攢鍞柟寮忥紝鐩綍涓嬭祫婧愭病鏈夐攢鍞柟寮� + if (item.saleMethod?.length == 0) { + // 鏌ョ湅鍏剁埗绾ф槸鍚︽湁閿�鍞柟寮� + if (parent.saleMethod?.length > 0) { + // 鐖剁骇鏄湁閿�鍞柟寮忕洿鎺ユ樉绀烘寜閽� + // const index = data.findIndex(i => i.id == parent.id) + parent.isShowIcon = true + } + // else { + // // 鐖剁骇娌℃湁閿�鍞柟寮忥紝鏌ユ壘璇ヨ祫婧愮埗绾� + // const arr = parent.productLinkPath.split('\\') + // const linkData = arr[arr.length - 1] // arr[arr.length - 1] 鎺掗櫎鑷繁 + // linkData.reverse() + // const dataList = linkData.map(ritem => { + // const parentData = data.find(citem => citem.id == ritem); + // if (parentData) return parentData; + // }) + // if (dataList?.length > 0) { + // const index = data.findIndex(i => i.id == dataList[0].id) + // data[index].isShowIcon = true + // } + // } + } else { + item.isShowIcon = true + } + } else { + this.handleSalmethodBtn(item.children, data, item) } - if (item.children && item.children.length) - this.clearTreeSealmethod( - saleData && new Date(saleData.EndDate).getTime() >= new Date().getTime() && new Date(saleData.BeginDate).getTime() <= new Date().getTime(), - item.children - ) } return tree }, @@ -1047,6 +1067,9 @@ loading: false, }); } + this.setData({ + cacheData: res.datas.cmsDatas[0].datas + }) let list = [] // 鍒ゆ柇浜戝涔犳湁鏃犻攢鍞柟寮忓拰鏈夋晥鏈� const cloundSaleMethod = @@ -1111,8 +1134,8 @@ teach: list, }); } else if (type.refCode == "jsek_cloudLearning") { - // 浜戝涔犱笂鏃犻攢鍞柟寮忥紝璧扮洰褰� 璧勬簮 閿�鍞柟寮忓幓闄ゆ柟娉� - if (!flags) list = this.clearTreeSealmethod(false, list) + // 鎺у埗鎸夐挳鏄剧ず + list = this.handleSalmethodBtn(list, list, null) // 鍒ゆ柇棰嗗彇鏌ョ湅鏄惁鏄剧ず(浜戝涔狅紝鎴栬祫婧愮洰褰曪紝鏈夊敭浠蜂负0) let isshowDrawBtn = res.datas.cmsDatas[0].datas.some( (item) => @@ -1122,12 +1145,12 @@ new Date(item.saleMethod.find((citem) => citem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime() ) || (flags && cloundSaleMethod.Price == 0) // 鍒ゆ柇浜戝涔犲叏閮ㄨ喘涔版寜閽槸鍚︽樉绀� - let isShowBuyCloundMenu = flags && cloundSaleMethod.Price > 0 && !this.data.buyIdList.includes(cloundSaleMethod.Id) + let isShowBuyCloundMenu = flags && cloundSaleMethod.Price > 0 && !this.data.buyIdList.includes(cloundSaleMethod.Id) && !this.data.bookDetail.IsTextbook // 鍒ゆ柇璧勬簮璐拱鎸夐挳鏄惁鏄剧ず 锛堜簯瀛︿範鏃犻攢鍞柟寮忥紝璧勬簮鍜岀洰褰曚腑鏈夐攢鍞柟寮忥紝涓斿敭浠峰ぇ浜�0锛� let isShowBuyCloundBtn = !flags && res.datas.cmsDatas[0].datas.some(item => item.saleMethod.length && item.saleMethod.find((citem) => citem.SaleType == 'Normal').Price > 0 && new Date(item.saleMethod.find((citem) => citem.SaleType == 'Normal').EndDate).getTime() >= new Date().getTime() && - new Date(item.saleMethod.find((citem) => citem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime()) + new Date(item.saleMethod.find((citem) => citem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime()) && !this.data.bookDetail.IsTextbook // 鍒ゆ柇璐墿杞︽寜閽拰閿佹寜閽槸鍚︽樉绀� this.handleTreeData(list).forEach(item => { item.isbuy = this.resourceIsBuy(item); @@ -1714,28 +1737,55 @@ }, // 鍒ゆ柇璧勬簮鏄惁璐拱 resourceIsBuy(data) { - if (data.saleMethod && data.saleMethod.length) { - const saleData = data.saleMethod.find((item) => item.SaleType == 'Normal') - if (saleData.State == 'Disable') return false - const isShow = this.data.buyIdList.some( - (item) => item == saleData.Id - ); - // 宸茬粡璐拱 - if (isShow || saleData.Price == 0) return false - // 鏈喘涔帮紝鏌ョ湅閿�鍞柟寮忔槸鍚﹁繃鏈� - if (!isShow) { - const flag = new Date(saleData.EndDate).getTime() >= new Date().getTime() && - new Date(saleData.BeginDate).getTime() <= new Date().getTime() - if (flag) { - // 涓鸿繃鏈� 锛岄渶瑕佽喘涔� - return true - } else { - // 宸茶繃鏈� 鏃犻渶璐拱 - return false + // if (data.saleMethod && data.saleMethod.length) { + // const saleData = data.saleMethod.find((item) => item.SaleType == 'Normal') + // if (saleData.State == 'Disable') return false + // const isShow = this.data.buyIdList.some( + // (item) => item == saleData.Id + // ); + // // 宸茬粡璐拱 + // if (isShow || saleData.Price == 0) return false + // // 鏈喘涔帮紝鏌ョ湅閿�鍞柟寮忔槸鍚﹁繃鏈� + // if (!isShow) { + // const flag = new Date(saleData.EndDate).getTime() >= new Date().getTime() && + // new Date(saleData.BeginDate).getTime() <= new Date().getTime() + // if (flag) { + // // 涓鸿繃鏈� 锛岄渶瑕佽喘涔� + // return true + // } else { + // // 宸茶繃鏈� 鏃犻渶璐拱 + // return false + // } + // } + // } else { + // return false; + // } + let linkData = data.productLinkPath.split("\\"); + linkData.reverse() + let dataList = linkData.map(item => { + let data = this.data.cacheData.find(citem => citem.id == item); + if (data) return data; + }) + let isBuy = 1; + for (let i = 0; i < dataList.length; i++) { + const dataItem = dataList[i]; + if (dataItem) { + if (dataItem.saleMethod.length > 0) { + isBuy = 2; + if (this.data.bookDetail.purchasedSaleMethodIdList.indexOf(dataItem.saleMethod[0].Id) > -1 || dataItem.saleMethod[0].Price == 0) { + isBuy = 3; + break; + } else { + break; + } } } + } + if (isBuy == 2) { + // 鏈喘涔� + return false } else { - return false; + return true } }, // 浜戝涔犺祫婧愭槸鍚︽樉绀洪攣鍥炬爣锛堟湭璐拱锛屼笖璧勬簮鍞环澶т簬闆讹級 -- Gitblit v1.9.1