From 46b1a99c27482b3798aff89e7fda3554f9ae3801 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期三, 17 四月 2024 09:19:41 +0800 Subject: [PATCH] 云学习购买页显示优化 --- packageBookService/pages/bookServices/detail/buyResource/index.js | 37 +++++++++++++++++++++++++++++-------- 1 files changed, 29 insertions(+), 8 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/buyResource/index.js b/packageBookService/pages/bookServices/detail/buyResource/index.js index 34db152..8ec26df 100644 --- a/packageBookService/pages/bookServices/detail/buyResource/index.js +++ b/packageBookService/pages/bookServices/detail/buyResource/index.js @@ -17,12 +17,15 @@ paymentPage: false, superior: false, checkAllState: true, + productLinkPath: '', + refCode: '' }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ onLoad(options) { + this.getBookInfo(options.bookId); const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 const navBarHeight = @@ -31,14 +34,11 @@ barHeight: systInfo.statusBarHeight, navBarHeight: navBarHeight, bookId: options.bookId, + productLinkPath: options.productLinkPath, + refCode: options.refCode }); this.getResourceClass(); - this.getResourceData({ - productLinkPath: options.productLinkPath, - refCode: options.refCode, - }); this.getShoppingCartProductGet(); - this.getBookInfo(options.bookId); }, /** @@ -226,12 +226,12 @@ }); data.datas.cmsDatas[0].datas.forEach((item) => { item.checked = false; - item.isbuy = this.resourceIsBuy(item); + item.isbuy = this.isShowNeedBuy(item); item.isShopCar = this.isShoppingCart(item); }); return data.datas.cmsDatas[0].datas; }, - getBookInfo(id) { + async getBookInfo(id) { this.setData({ "mockData'.id": 0, "mockData.price": 0, @@ -269,12 +269,17 @@ freeEpubPage: [], //epub璇曡鐧惧垎姣� }, }; - app.MG.store.getProductDetail(query).then(async (res) => { + await app.MG.store.getProductDetail(query).then(async (res) => { this.setData({ bookDetail: res.datas, buyIdList: res.datas.purchasedSaleMethodIdList, }); + this.getResourceData({ + productLinkPath: this.data.productLinkPath, + refCode: this.data.refCode, + }); }); + }, // 鑾峰彇宸茶喘涔板晢鍝� getShoppingCartProductGet() { @@ -306,6 +311,22 @@ return false; } }, + + isShowNeedBuy(data) { + if (data.saleMethod && data.saleMethod.length) { + const isSHow = this.data.buyIdList.some( + (item) => item == data.saleMethod[0].Id + ); + if (isSHow) { + return false; + } else { + return data.saleMethod[0].price > 0 ? true : false; + } + return !isSHow; + } else { + return false; + } + }, // 鍒ゆ柇璧勬簮鍔犲叆璐墿杞︽寜閽槸鍚︽樉绀� isShoppingCart(data) { if (data.saleMethod && data.saleMethod.length) { -- Gitblit v1.9.1