From 93aadab3e592ccb4d2f7ff00f4bd79d6e7a7daec Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期四, 11 七月 2024 15:48:28 +0800 Subject: [PATCH] 详情页接口优化,图书列表页骨架屏优化 --- packageBookService/pages/bookServices/detail/index.js | 52 +++++++++++++++++++++++++++++++++------------------- 1 files changed, 33 insertions(+), 19 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js index a101f1d..ec54438 100644 --- a/packageBookService/pages/bookServices/detail/index.js +++ b/packageBookService/pages/bookServices/detail/index.js @@ -187,7 +187,7 @@ title: options.name, }) this.getBookInfo(options.id); - this.getResourceClass(); // 鑾峰彇璧勬簮鎵�灞炲垎绫� + // this.getResourceClass(); // 鑾峰彇璧勬簮鎵�灞炲垎绫� const token = wx.getStorageSync(app.config.tokenKey); if (token) { this.getShoppingCartProductGet(); @@ -405,14 +405,19 @@ this.getSubTtem(); // 鑾峰彇鍥句功鍒嗙被 if (res.datas.bookClassification) { + let classData = [] const bookClassification = JSON.parse(res.datas.bookClassification); if (Array.isArray(bookClassification) && bookClassification.length) { for (let index = 0; index < bookClassification.length; index++) { const element = bookClassification[index]; const iconType = element[0]; const classType = element[1]; - await this.getBookClass(iconType, classType); + classData.push({ + iconType, + classType + }) } + await this.getBookClass(classData); } } @@ -571,28 +576,37 @@ }); }, // 鑾峰彇鍥句功鍒嗙被 - async getBookClass(iconType, classType) { + async getBookClass(list) { let name = ""; const query = { refCodes: ["bookClassification"], }; await app.MG.store.getProductTypeField(query).then((res) => { - JSON.parse(res[0].config).option.forEach((item) => { - if (item.value == iconType) { - item.child.forEach((citem) => { - if (citem.value == classType) { - const flag = this.data.bookClass.findIndex((ditem) => ditem == citem.name) - if (flag == -1) { - let list = this.data.bookClass - list.push(citem.name) - this.setData({ - bookClass: list - }) - } + for (let aindex = 0; aindex < list.length; aindex++) { + const aitem = list[aindex]; + const iconType = aitem.iconType + const classType = aitem.classType + JSON.parse(res[0].config).option.forEach((item) => { + if (item.value == iconType) { + if (item.child && item.child.length) { + item.child.forEach((citem) => { + if (citem.value == classType) { + const flag = this.data.bookClass.findIndex((ditem) => ditem == citem.name) + if (flag == -1) { + let list = this.data.bookClass + list.push(citem.name) + this.setData({ + bookClass: list + }) + } + } + }); } - }); - } - }); + + } + }); + } + }); }, // 鏀惰棌 @@ -671,7 +685,7 @@ const checkData = this.data.cmsDatas.find( (item) => item.refCode == e.detail.value ); - + if (!this.data.resourceClassList.length) this.getResourceClass() if (checkData) { if (e.detail.value == "jsek_cloudLearning") { this.setData({ -- Gitblit v1.9.1