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/examination/examination.js |    3 +
 pages/bookServices/assort/index.json                             |    3 +
 pages/bookServices/assort/index.wxml                             |   20 ++++++----
 packageBookService/pages/bookServices/detail/index.js            |   52 ++++++++++++++++---------
 pages/bookServices/assort/index.js                               |   37 ++++++++++++++++++
 pages/bookServices/assort/index.wxss                             |    5 ++
 6 files changed, 91 insertions(+), 29 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({
diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js
index 9a82a8d..7e2f406 100644
--- a/packageBookService/pages/bookServices/examination/examination.js
+++ b/packageBookService/pages/bookServices/examination/examination.js
@@ -1043,6 +1043,9 @@
             questionDataList: questionList,
             cardList: cardUpdatedList,
           });
+          console.log(
+            '棰樼洰', this.data.questionDataList
+          );
         });
       });
     }
diff --git a/pages/bookServices/assort/index.js b/pages/bookServices/assort/index.js
index 888e96e..fe2f1d5 100644
--- a/pages/bookServices/assort/index.js
+++ b/pages/bookServices/assort/index.js
@@ -25,6 +25,37 @@
     bookList: [],
     loading: false,
     listLoding: false,
+    stairListLoading: false,
+    rowCol: [{
+        width: '50%',
+      },
+      {
+        width: '100%'
+      },
+      {
+        width: '80%'
+      },
+      {
+        width: '100%'
+      }, {
+        width: '100%'
+      },
+      {
+        width: '100%'
+      },
+      {
+        width: '50%'
+      },
+      {
+        width: '100%'
+      },
+      {
+        width: '80%'
+      },
+      {
+        width: '100%'
+      },
+    ],
   },
 
   /**
@@ -87,6 +118,7 @@
   getAssortList() {
     this.setData({
       loading: true,
+      listLoding: true,
     });
     const query = {
       path: "*",
@@ -134,7 +166,8 @@
   // 鑾峰彇涓�绾у垎绫�
   getStairList(path) {
     this.setData({
-      listLoding: true,
+      stairListLoading: true,
+      startList: []
     });
     const query = {
       path,
@@ -160,11 +193,13 @@
           (item.icon = getPublicImage(item.icon, 500)) :
           (item.icon = item.icon);
         item.children = await this.getSecondList(item);
+
       }
       // 涓�绾у垎绫昏祴鍊�
       this.setData({
         startList: res.datas,
         listLoding: false,
+        stairListLoading: false,
         "startCheck.id": res.datas[0].id,
         "startCheck..code": "",
       });
diff --git a/pages/bookServices/assort/index.json b/pages/bookServices/assort/index.json
index 45e1881..2b5c171 100644
--- a/pages/bookServices/assort/index.json
+++ b/pages/bookServices/assort/index.json
@@ -12,6 +12,7 @@
     "t-radio-group": "tdesign-miniprogram/radio-group/radio-group",
     "t-button": "tdesign-miniprogram/button/button",
     "t-loading": "tdesign-miniprogram/loading/loading",
-    "t-image": "tdesign-miniprogram/image/image"
+    "t-image": "tdesign-miniprogram/image/image",
+    "t-skeleton": "tdesign-miniprogram/skeleton/skeleton"
   }
 }
\ No newline at end of file
diff --git a/pages/bookServices/assort/index.wxml b/pages/bookServices/assort/index.wxml
index db45635..bc3191a 100644
--- a/pages/bookServices/assort/index.wxml
+++ b/pages/bookServices/assort/index.wxml
@@ -60,20 +60,13 @@
             class="class-list"
             scroll-into-view="{{ 'list' + startCheck.id}}"
           >
-            <view wx:if="{{listLoading}}">
-              <t-loading
-                theme="spinner"
-                size="400rpx"
-                loading="{{listLoading}}"
-              ></t-loading>
-            </view>
             <view
               wx:for="{{startList}}"
               wx:for-item="item"
               wx:key="id"
               id="{{ 'list' + item.id}}"
               class="class-box"
-              wx:if="{{!listLoading}}"
+              wx:if="{{!stairListLoading}}"
             >
               <view class="class-name">{{item.name}}</view>
               <view class="class-content">
@@ -111,6 +104,17 @@
                 </view>
               </view>
             </view>
+            <view
+              wx:if="{{stairListLoading}}"
+              style="width: 100%; height: min-content"
+            >
+              <t-skeleton
+                row-col="{{rowCol}}"
+                theme="paragraph"
+                animation="gradient"
+                loading="{{stairListLoading}}"
+              ></t-skeleton>
+            </view>
             <view class="bottom-box"> </view>
           </scroll-view>
         </view>
diff --git a/pages/bookServices/assort/index.wxss b/pages/bookServices/assort/index.wxss
index 22c508a..b1c921b 100644
--- a/pages/bookServices/assort/index.wxss
+++ b/pages/bookServices/assort/index.wxss
@@ -185,4 +185,9 @@
   height: 80rpx;
   font-size: 28rpx;
   --td-loading-color: #ff6c00
+}
+
+.stairList-skeleton {
+  width: 100%;
+  height: 100%;
 }
\ No newline at end of file

--
Gitblit v1.9.1