From d61a31af1b8a220af669c818f11b6a13c1fb8dba Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期二, 26 三月 2024 16:15:36 +0800 Subject: [PATCH] 图书详情页布局调整 --- packageBookService/pages/bookServices/detail/buyResource/index.js | 121 ++++++++++++++++++++++++++++++++++++--- 1 files changed, 110 insertions(+), 11 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/buyResource/index.js b/packageBookService/pages/bookServices/detail/buyResource/index.js index dc40f65..bc7e7eb 100644 --- a/packageBookService/pages/bookServices/detail/buyResource/index.js +++ b/packageBookService/pages/bookServices/detail/buyResource/index.js @@ -12,6 +12,8 @@ openLearnids: [], bookId: '', loading: false, + shoppingList: [], + shoppingCartGetId: [], }, /** @@ -29,6 +31,8 @@ this.getResourceClass() console.log(options); this.getResourceData({ productLinkPath: options.productLinkPath, refCode: options.refCode }) + this.getShoppingCartProductGet() + this.getBookInfo(options.bookId) }, /** @@ -123,7 +127,8 @@ if (type.refCode == 'jsek_teachingResources' || type.refCode == 'jsek_cloudLearning') { if (res.datas.cmsDatas[0].datas.length > 0) { res.datas.cmsDatas[0].datas.forEach(item => { - item.checked = false + item.checked = false, + item.checkAll = true }) const list = await this.getAllResource(res.datas.cmsDatas[0].datas) if (type.refCode == 'jsek_teachingResources') { @@ -133,15 +138,17 @@ }) this.findChildIds(this.data.teach, this.data.openTeachids = []) } else if (type.refCode == 'jsek_cloudLearning') { + const result = [] res.datas.cmsDatas[0].datas.forEach(item => { item.checked = false }) - const list = await this.getAllResource(res.datas.cmsDatas[0].datas) + this.findChildIds(list, result) this.setData({ learn: list, - loading: false + loading: false, + openLearnids: result }) - this.findChildIds(this.data.learn, this.data.openLearnids = []) + console.log('鏁欏璧勬簮', list); } } else { // 鏃犳暟鎹� @@ -218,15 +225,103 @@ } }) data.datas.cmsDatas[0].datas.forEach(item => { - if (this.data.tabValue == 'jsek_teachingResources') { - item.checked = false - } else if (this.data.tabValue == 'jsek_cloudLearning') { - item.checked = false - item.isbuy = this.resourceIsBuy(item) - item.isShopCar = this.isShoppingCart(item) - } + item.checked = false + item.isbuy = this.resourceIsBuy(item) + item.isShopCar = this.isShoppingCart(item) }) return data.datas.cmsDatas[0].datas + }, + getBookInfo(id) { + this.setData({ + "mockData'.id": 0, + "mockData.price": 0, + "mockData.count": 0 + }) + const query = { + path: '*', + queryType: '*', + productId: id, + favoriteTypes: 'FavoriteBookCity', + itemFields: { + 'SysType=': 'CmsFolder', + }, + coverSize: { + height: 300, + }, + fields: { + seriesName: [], + author: [], + isbn: [], + publicationDate: [], + bookClassification: [], + paperPrice: [], + JDLink: [], + tmallLink: [], + dangdangLink: [], + weidianLink: [], + content: [], + authorIntroduction: [], + isApplyBook: [], + isSell: [], + pdf: [], + protectedEpub: [], + probationPage: [], //pdf璇曡椤垫暟 + freeEpubPage: [], //epub璇曡鐧惧垎姣� + }, + }; + app.MG.store.getProductDetail(query).then(async (res) => { + this.setData({ + bookDetail: res.datas, + buyIdList: res.datas.purchasedSaleMethodIdList + }); + }); + + }, + // 鑾峰彇宸茶喘涔板晢鍝� + getShoppingCartProductGet() { + let query = { + start: 0, + size: 999, + filterList: [], + searchList: [] + } + app.MG.store.getShoppingCartProductList(query).then((res) => { + const list = [] + res.datas.forEach((item) => { + list.push(item.saleMethod.id) + }) + this.setData({ + shoppingList: res.datas, + shoppingCartGetId: list + }) + }) + }, + // 鍒ゆ柇璧勬簮鏄惁璐拱 + resourceIsBuy(data) { + if (data.saleMethod && data.saleMethod.length) { + const isSHow = this.data.buyIdList.some((item) => item == data.saleMethod[0].Id) + return !isSHow + } else { + return false + } + }, + // 鍒ゆ柇璧勬簮鍔犲叆璐墿杞︽寜閽槸鍚︽樉绀� + isShoppingCart(data) { + if (data.saleMethod && data.saleMethod.length) { + if (data.saleMethod[0].Price <= 0) return false + // 鍐嶅垽鏂槸鍚﹁喘涔� + const isBuy = this.data.buyIdList.some((item) => item == data.saleMethod[0].Id) + if (isBuy) { + // 璐拱浜� + return false + } else { + // 鍒ゆ柇鏄惁鍔犲叆璐墿杞� + const isSHow = this.data.shoppingCartGetId.some((item) => item == data.saleMethod[0].Id) + return !isSHow + } + } else { + return false + } }, // 鑾峰彇灞曞紑椤� findChildIds(data, result) { @@ -267,4 +362,8 @@ }) }) }, + checkAll() { + const child = this.selectComponent('#tree') + child.checkAll() + } }) \ No newline at end of file -- Gitblit v1.9.1