From 5997579aa13e3b11677ee4d6eac3584f4e11429f Mon Sep 17 00:00:00 2001 From: zhongshujie <2862698242@qq.com> Date: 星期二, 08 七月 2025 16:53:57 +0800 Subject: [PATCH] 优化 --- packageBookService/pages/bookServices/detail/index.js | 94 ++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 76 insertions(+), 18 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js index f9aefe9..07cb6b1 100644 --- a/packageBookService/pages/bookServices/detail/index.js +++ b/packageBookService/pages/bookServices/detail/index.js @@ -212,9 +212,19 @@ protocolTxt: '', learnMenu: null, md5List: [], - editDialog: false + editDialog: false, + scrollTop: 0, // 鎵爜杩涜祫婧愭粴鍔� + source: '', + activeId: '', + qrTabValue: '' }, - + // 鎵爜鍒拌祫婧愬垪琛紝婊氬姩鍒拌璧勬簮浣嶇疆 + handleScrollTop(e) { + if (this.data.tabValue == this.data.qrTabValue) + this.setData({ + scrollTop: e.detail.top + }) + }, resetTree: function (e) { this.setData({ currentCheck: e.detail.checkedItem, @@ -258,7 +268,11 @@ name: decodeURI(options.name), storeInfo: options.storeInfo, }, + source: options.source, + activeId: options.resourceId, + qrTabValue: options.tabValue }); + console.log('浼犲弬', this.data); wx.setNavigationBarTitle({ title: decodeURI(options.name), }) @@ -301,6 +315,7 @@ } this.setData({ num: Number(this.data.paperBookList.length) + Number(this.data.electronicBookList.length), + editDialog: false }); if (this.data.bookDetail.id) { this.getBookInfo(this.data.bookDetail.id) @@ -771,7 +786,11 @@ editDialog: true }) }, - + closeEditDialog() { + this.setData({ + editDialog: false + }) + }, // 鎴戣寤鸿 suggestBtn() { // 妫�鏌ョ櫥褰曠姸鎬� @@ -1081,7 +1100,11 @@ } let result = []; if (type.refCode == "jsek_teachingResources") { - this.findChildIds(list, result); + if (this.data.activeId) { + result = this.findChildIdsByCode(res.datas.cmsDatas[0].datas) + } else { + this.findChildIds(list, result); + } this.setData({ openTeachids: result, loading: false, @@ -1100,14 +1123,21 @@ ) || (flags && cloundSaleMethod.Price == 0) // 鍒ゆ柇浜戝涔犲叏閮ㄨ喘涔版寜閽槸鍚︽樉绀� let isShowBuyCloundMenu = flags && cloundSaleMethod.Price > 0 && !this.data.buyIdList.includes(cloundSaleMethod.Id) - // 鍒ゆ柇璧勬簮璐拱鎸夐挳鏄惁鏄剧ず - let isShowBuyCloundBtn = !flags && res.datas.cmsDatas[0].datas.some(citem => citem.saleMethod.length != 0) + // 鍒ゆ柇璧勬簮璐拱鎸夐挳鏄惁鏄剧ず 锛堜簯瀛︿範鏃犻攢鍞柟寮忥紝璧勬簮鍜岀洰褰曚腑鏈夐攢鍞柟寮忥紝涓斿敭浠峰ぇ浜�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()) // 鍒ゆ柇璐墿杞︽寜閽拰閿佹寜閽槸鍚︽樉绀� this.handleTreeData(list).forEach(item => { item.isbuy = this.resourceIsBuy(item); item.isShopCar = this.isShoppingCart(item); }) - this.findChildIds(list, result); + if (this.data.activeId) { + result = this.findChildIdsByCode(res.datas.cmsDatas[0].datas) + } else { + this.findChildIds(list, result); + } this.setData({ isshowDrawBtn, isShowBuyCloundMenu, @@ -1119,7 +1149,7 @@ learnPath: type.productLinkPath }); } - console.log('1', this.data.teach); + console.log('1', result); }) }, // 鑾峰彇 浜戞祴璇� @@ -1200,7 +1230,7 @@ }); } if (data.length > 0) { - console.log('data', data); + console.log('data01', data); let list = [] that.getTreeList(data, list, query.cmsPath) list = that.ensureTreeConsistency(list) @@ -1268,6 +1298,17 @@ break } } + }, + + // 鑾峰彇鐩綍鎵爜灞曞紑椤� + findChildIdsByCode(list) { + let arr = [] + const data = list.find(item => item.id == this.data.activeId) + if (data) { + const ids = data.productLinkInfo.find(item => item.CmsItemId == data.id).LinkPath.split('\\') + arr = [data.id, ...ids].map(item => Number(item)) + } + return arr }, // 鍥句功娣诲姞璐墿杞� @@ -2099,12 +2140,6 @@ }, // 璐拱缁勫嵎 buyMock() { - const token = wx.getStorageSync(app.config.tokenKey); - if (token) { - buyMockFun() - } else { - this.logInFun(() => {}) - } const buyMockFun = async () => { let res; if (!this.data.mockData.id) @@ -2153,6 +2188,13 @@ console.log(error); } } + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + buyMockFun() + } else { + this.logInFun(() => {}) + } + }, // 璁板綍璐拱缁勫嵎鏃堕棿 recordBuyMock() { @@ -2679,9 +2721,14 @@ //鍘绘牱涔︾敵璇峰崟 goApply() { - wx.navigateTo({ - url: "/packageDomain/pages/sampleBookList/applicationForm/index", - }); + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + wx.navigateTo({ + url: "/packageDomain/pages/sampleBookList/applicationForm/index", + }); + } else { + this.logInFun(() => {}) + } }, handleTree() { // const child = this.selectComponent('#teach-tree') @@ -3023,6 +3070,17 @@ cloundMenuIsBuy: flag }) }, + + // 鏄剧ずISBN + showISBN() { + wx.showModal({ + title: '', + content: this.data.bookDetail.isbn, + showCancel: false, + confirmText: '鍏抽棴', + success: (res) => {} + }) + }, /** * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� */ -- Gitblit v1.9.1