From 338ad19ee45b5380a0d8433cbbce2a727a576dfa Mon Sep 17 00:00:00 2001
From: yiming <m13691596795@163.com>
Date: 星期五, 19 四月 2024 17:34:36 +0800
Subject: [PATCH] bug2

---
 pages/bookExhibitionList/index.js |  199 +++++++++++++++++++++++++++++++++++++------------
 1 files changed, 148 insertions(+), 51 deletions(-)

diff --git a/pages/bookExhibitionList/index.js b/pages/bookExhibitionList/index.js
index babb3d4..37a8d66 100644
--- a/pages/bookExhibitionList/index.js
+++ b/pages/bookExhibitionList/index.js
@@ -8,6 +8,11 @@
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
+    loading: true,
+    hidden: true,
+    totalSize: '',
+    start: 0,
+    isMore: null,
     keynoteDisabled: true,
     value: '',
     keyword: '',
@@ -26,8 +31,7 @@
     },
     product: {
       value: '*',
-      options: [
-        {
+      options: [{
           value: '*',
           label: '鎬诲垎绫�',
         },
@@ -58,18 +62,36 @@
     navBarHeight: '',
     barHeight: '',
     windowHeight: '',
-
+    sorter: {
+      value: 'timeAsc',
+      options: [{
+          value: 'nameAsc',
+          label: '鍚嶇О姝e簭',
+        },
+        {
+          value: 'nameDesc',
+          label: '鍚嶇О鍊掑簭',
+        },
+        {
+          value: 'timeAsc',
+          label: '鍑虹増鏃堕棿姝e簭',
+        },
+        {
+          value: 'timeDesc',
+          label: '鍑虹増鏃堕棿鍊掑簭',
+        },
+      ],
+    },
   },
 
 
 
   /**
-    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
-    */
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
+   */
   onLoad(options) {
 
 
-    // console.log(this.data.filteredItems, 88888);
     const systInfo = wx.getSystemInfoSync();
     const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅
     const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴�
@@ -86,7 +108,7 @@
     }))
 
     if (this.data.filteredItems = []) {
-      console.log(11111);
+
       // singleSelectOptions.push({
       //   label: '鏆傛棤鏁版嵁',
       //   value: 'disabled',
@@ -100,7 +122,7 @@
 
 
 
-    console.log(this.data.bookExhibitionList.length, 'this.data.bookExhibitionList.length');
+
     // 鏇存柊鏁版嵁
     this.setData({
       'multipleSelect.options': singleSelectOptions,
@@ -146,18 +168,38 @@
   onPullDownRefresh() {
 
   },
-  onPullDownRefresh() {
-    this.data.page.size = 16 //鏇存敼鏄剧ず鐨勫��
-    this.bookExhibitionGet(); // 璋冪敤鏂规硶鍔犺浇鏇村鏁版嵁
+  // onPullDownRefresh() {
+  //   this.data.page.size = 16 //鏇存敼鏄剧ず鐨勫��
+  //   this.bookExhibitionGet(); // 璋冪敤鏂规硶鍔犺浇鏇村鏁版嵁
+  // },
+
+  onScrollToLower() {
+
+    if (this.data.bookExhibitionList.length < this.data.totalSize) {
+      this.setData({
+        isMore: true,
+        start: this.data.start + 1
+      })
+      this.bookExhibitionGet()
+    } else {
+      this.setData({
+        isMore: true,
+      })
+      setTimeout(() => {
+        this.setData({
+          isMore: false
+        })
+
+      }, 300)
+    }
   },
   /**
    * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
    */
   onReachBottom() {
-    // console.log(this.data.page.size);
-    // console.log(this.data.total);
+
     if (this.data.page.size >= this.data.total) {
-      console.log('宸插姞杞藉畬鎵�鏈夋暟鎹�');
+
       Toast({
         context: this,
         selector: '#t-toast',
@@ -174,7 +216,7 @@
         // 'page.start': currentPage,
         'page.size': newSize
       });
-      this.bookExhibitionGet(); // 璋冪敤鏂规硶鍔犺浇鏇村鏁版嵁
+      // this.bookExhibitionGet(); // 璋冪敤鏂规硶鍔犺浇鏇村鏁版嵁
 
 
 
@@ -198,10 +240,31 @@
       'Name*': this.data.keyword,
       '||subtitle*': this.data.keyword
     }
-    // console.log(this.data.keynoteValue);
-    let sort = {
-      Name: this.data.nameSort || 'Desc'
-    }
+
+    let sort = {};
+
+    const sortOptions = {
+      '*': {
+        CreateDate: 'Asc'
+      },
+      'nameAsc': {
+        Name: 'Asc'
+      },
+      'nameDesc': {
+        Name: 'Desc'
+      },
+      'timeAsc': {
+        CreateDate: 'Asc'
+      },
+      'timeDesc': {
+        CreateDate: 'Desc'
+      }
+    };
+
+    sort = sortOptions[this.data.product.value] || {};
+
+
+
     app.MG.store.getProductList({
       storeInfo: 'jsek_bookFair',
       path: newValue,
@@ -212,20 +275,26 @@
         'bookClassification*': this.data.keynoteValue || [],
         ...searchObj
       },
-      paging: this.data.page,
+      paging: {
+        start: '0',
+        size: this.data.start * 10
+      },
       sort: sort,
       // coverSize: {
       //   width: 100
       // },
     }).then(res => {
       res.datas.forEach((item) => {
+        if (item.subtitle == undefined) {
+          item.subtitle = ''
+        }
         item.subtitleName = item.subtitle + item.name
       })
-      console.log(res, 'item');
+
       this.data.total = res.total
 
       // list.push(res.datas)
-      console.log(res.datas.length);
+
 
 
       if (res.datas.length == 0) {
@@ -237,42 +306,51 @@
       const list = [...res.datas]
 
       this.setData({
-        bookExhibitionList: list
+        bookExhibitionList: list,
+        totalSize: res.total
       })
-      // 鍒ゆ柇鏁版嵁闀垮害
-      console.log(list.length, 'list.length');
+
 
 
       //鍙栨秷
       wx.hideLoading()
-      // console.log(this.data.bookExhibitionList, '鏁版嵁');
+
+
+      this.setData({
+        loading: false,
+        hidden: false,
+      })
     })
 
   },
   //閲嶇偣椤圭洰鎺ュ彛
   keyProjectsGet(newPrice) {
-    // console.log(newPrice, 'newPrice');
+
+    this.setData({
+      loading: true,
+      hidden: true,
+    })
+
     let parms = {
       refCodes: ['bookClassification']
     }
     app.MG.store.getProductTypeField(parms).then(res => {
-
       const checkData = JSON.parse(res[0].config)
-
-
       checkData.option.forEach(item => {
         if (newPrice == item.value) {
-
           this.setData({
             filteredItems: item.child || [] // 濡傛灉瀛樺湪瀛愰」鍒欒祴鍊硷紝鍚﹀垯璧嬪�间负绌烘暟缁�
           });
-
-          // console.log(this.data.filteredItems);
 
         }
       })
 
       this.onLoad();
+
+      this.setData({
+        loading: false,
+        hidden: false,
+      })
     })
   },
 
@@ -282,23 +360,29 @@
   // 鎬诲垎绫�
   // 鎬诲垎绫�
   onChange(e) {
-
     this.data.page.size = 16 //鏇存敼鏄剧ず鐨勫��
     const newValue = e.detail.value;
     const selectedOption = this.data.product.options.find(option => option.value === newValue);
     const newPrice = selectedOption ? selectedOption.price : null;
-    console.log(newValue, 'newValue');
-    console.log(newPrice, 'newPrice');
+
+
+    // const bookExhibitionListsubsidiary = []
+    // this.setData({
+    //   bookExhibitionListsubsidiary: this.data.bookExhibitionList
+    // })
+
+
     if (newPrice) {
       this.setData({
         keynoteDisabled: false
       })
-
-    } else {
+    }
+    if (!newPrice) {
       this.setData({
         keynoteDisabled: true
       })
     }
+
     this.setData({
       'product.value': newValue,
       'product.price': newPrice, // 灏嗛�変腑鐨� price 鍊间繚瀛樺湪鏁版嵁涓�
@@ -316,6 +400,11 @@
 
 
 
+
+
+
+    // e.stopImmediatePropagation()
+
   },
 
   // 閲嶇偣椤圭洰
@@ -323,29 +412,26 @@
     this.setData({
       'multipleSelect.value': e.detail.value,
     });
-
   },
   handleConfirm(event) {
-
-    const { value } = event.detail;
+    const {
+      value
+    } = event.detail;
     // 纭鎿嶄綔鐨勫鐞嗛�昏緫
 
-    console.log('纭鎿嶄綔锛岄�変腑鐨勫�间负锛�', value);
+
     this.data.keynoteValue = value
     this.bookExhibitionGet()
   },
-  handleReset() {
+
+
+  handleReset(e) {
 
     // 閲嶇疆鎿嶄綔鐨勫鐞嗛�昏緫
     this.data.keynoteValue = []
-    console.log('閲嶇疆鎿嶄綔');
     this.bookExhibitionGet()
   },
   onSwapRight() {
-    // console.log('xxxxxx');
-    // this.data.nameSort = 'Asc'
-
-
     if (!this.data.nameSort) {
       this.setData({
         nameSort: 'Desc',
@@ -365,25 +451,36 @@
   },
   onSwapLeft() {
     this.data.nameSort = 'Desc'
-    // console.log('sssssss');
     this.bookExhibitionGet()
   },
   onBookExhibitionDetails: function (event) {
+
     const item = event.currentTarget.dataset.item;
-    console.log(item);
+
     wx.navigateTo({
       url: '/pages/bookExhibitionDetails/index?id=' + item.id + '&bookName=' + item.name + '&subtitleName=' + item.subtitleName // 鍋囪璺宠浆鍒拌鎯呴〉闈紝骞朵紶閫掍簡id鍙傛暟
     });
   },
+
   // 鎼滅储妗�
   onSearchSubmit(e) {
     this.setData({
       keyword: e.detail.value
     })
-    console.log(this.data.keyword, 'keyword');
+
     this.bookExhibitionGet()
   },
   goBack() {
     wx.navigateBack();
   },
+  onSort(e) {
+    this.setData({
+      'product.value': e.detail.value,
+    });
+
+    this.bookExhibitionGet()
+  },
+  onOpend() {
+
+  }
 })
\ No newline at end of file

--
Gitblit v1.9.1