From b125d3ea74d61fb8e4d7238c83906aeea52c6b4c Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期二, 12 三月 2024 14:39:55 +0800
Subject: [PATCH] 更新代码

---
 pages/bookServices/list/index.js |   84 +++++++++++++++++++++++++++++++++++-------
 1 files changed, 70 insertions(+), 14 deletions(-)

diff --git a/pages/bookServices/list/index.js b/pages/bookServices/list/index.js
index 7388ef4..ccb63b6 100644
--- a/pages/bookServices/list/index.js
+++ b/pages/bookServices/list/index.js
@@ -9,7 +9,11 @@
     searchValue: '',
     path: '',
     pathList: [],
-    page: 1,
+    pageCount: {
+      page: 1,
+      total: 0,
+    },
+    isMore: null,
     assortCheck: {
       name: '',
       code: '',
@@ -39,6 +43,10 @@
     stairCode: '', // 涓�绾у垎绫婚�変腑椤�
     secondCode: '', // 浜岀骇鍒嗙被閫変腑椤�
     sort: '', // 鎺掑簭
+    enable: false,
+    loadingProps: {
+      size: '50rpx',
+    },
   },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
@@ -74,10 +82,20 @@
       this.setData({
         'stairList.value': options.stairCode,
         stairCode: options.stairCode,
-        secondCode: options.secondCode,
-        'secondList.value': options.secondCode,
         path: `${options.assortCode}\\${options.stairCode}`,
       });
+    }
+    // 浜岀骇鍒嗙被璧嬪��
+    if (options.secondCode) {
+      this.setData({
+        secondCode: options.secondCode,
+        pathList: [{
+          Path: options.secondCode,
+          Type: '*',
+          StoreRefCode: app.config.goodsStore,
+        }
+        ],
+      })
     }
     // 鑾峰彇浜岀骇鍒嗙被
     this.getSecondList(`${options.assortCode}\\${options.stairCode}`);
@@ -90,37 +108,61 @@
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
    */
-  onReady() {},
+  onReady() {
+  },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
    */
-  onShow() {},
+  onShow() {
+  },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
    */
-  onHide() {},
+  onHide() { },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
    */
-  onUnload() {},
+  onUnload() { },
 
   /**
    * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
    */
-  onPullDownRefresh() {},
+  onPullDownRefresh() {
+    console.log('涓嬫媺');
+  },
 
   /**
    * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
    */
-  onReachBottom() {},
+  onReachBottom(e) {
+    console.log('搴曢儴');
+    const flag = this.data.bookList.length < this.data.pageCount.total
+    if (flag) {
+      this.setData({
+        isMore: true,
+        "pageCount.page": this.data.pageCount.page + 1
+      })
+      this.getBookList(this.data.path)
+    } else {
+      this.setData({
+        isMore: true,
+      })
+      setTimeout(() => {
+        this.setData({
+          isMore: false
+        })
+      }, 100)
+      console.log('娌℃湁鏇村浜�');
+    }
+  },
 
   /**
    * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
    */
-  onShareAppMessage() {},
+  onShareAppMessage() { },
   goBack() {
     wx.navigateBack();
   },
@@ -179,8 +221,11 @@
       }
       this.setData({
         'secondList.options': options,
-        'secondList.value': this.data.secondCode,
       });
+      const second = [this.data.secondCode]
+      this.setData({
+        'secondList.value': second
+      })
     });
   },
   // 鑾峰彇閲嶇偣椤圭洰
@@ -276,8 +321,8 @@
         height: 145,
       },
       paging: {
-        start: (this.data.page - 1) * 16,
-        size: 16,
+        start: 0,
+        size: this.data.pageCount.page * 8,
       },
       fields: {
         author: [],
@@ -290,7 +335,10 @@
     app.MG.store.getProductList(query).then((res) => {
       this.setData({
         bookList: res.datas,
+        enable: false,
+        "pageCount.total": res.total
       });
+      console.log('鍥句功鍒楄〃', res, this.data.pageCount);
     });
   },
   // 涓�绾у垎绫诲垏鎹�
@@ -299,6 +347,7 @@
       ? `${this.data.assortCheck.code}\\${e.detail.value}`
       : this.data.assortCheck.code;
     this.setData({
+      pathList: [],
       stairCode: e.detail.value,
       secondCode: '',
       path: path,
@@ -309,7 +358,6 @@
   },
   // 浜岀骇鍒嗙被鍒囨崲
   onChangeSecond(e) {
-    console.log(e);
     const pathList = [];
     for (let index = 0; index < e.detail.value.length; index++) {
       const element = e.detail.value[index];
@@ -323,6 +371,10 @@
       pathList: pathList,
       'secondList.value': e.detail.value,
     });
+
+  },
+  // 
+  onConfirmSecond() {
     this.getBookList(this.data.path);
   },
   // 閲嶇偣椤圭洰鏀瑰彉
@@ -394,4 +446,8 @@
       url: `/pages/bookServices/detail/index?id=${book.id}&name=${book.name}`,
     });
   },
+  onRefresh() {
+    this.setData({ enable: true });
+    this.getBookList(this.data.path)
+  },
 });

--
Gitblit v1.9.1