From 9ba507bed7688a1a9eee31255e40add8bf1a8689 Mon Sep 17 00:00:00 2001
From: yiming <m13691596795@163.com>
Date: 星期日, 28 四月 2024 18:54:33 +0800
Subject: [PATCH] 书展bug

---
 pages/bookExhibitionList/index.js |  363 +++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 261 insertions(+), 102 deletions(-)

diff --git a/pages/bookExhibitionList/index.js b/pages/bookExhibitionList/index.js
index c1e3eaa..2731d08 100644
--- a/pages/bookExhibitionList/index.js
+++ b/pages/bookExhibitionList/index.js
@@ -1,6 +1,6 @@
 // pages/bookExhibitionList/index.js
 import Toast from 'tdesign-miniprogram/toast/index';
-
+import watch from './watch/watch'
 const app = getApp()
 Page({
 
@@ -8,6 +8,14 @@
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
+    name: "娴嬭瘯watch",
+    newPrice: '',
+    loading: true,
+    hidden: true,
+    totalSize: '',
+    start: 0,
+    isMore: null,
+    keynoteDisabled: true,
     value: '',
     keyword: '',
     nameSort: null,
@@ -25,50 +33,64 @@
     },
     product: {
       value: '*',
-
-      options: [
-        {
+      options: [{
           value: '*',
           label: '鎬诲垎绫�',
         },
         {
           value: 'jsek_bFHigherEducation',
-          //閲嶇偣椤圭洰
-          price: 'jsek_higherEducation',
           label: '楂樼瓑鏁欒偛',
         },
         {
           value: 'jsek_bFVocationalEducation',
-          //閲嶇偣椤圭洰
-          price: 'jsek_vocationalEducation',
           label: '鑱屼笟鏁欒偛',
         },
         {
           value: 'jsek_bFTeacherEducation',
-          //閲嶇偣椤圭洰
-          price: 'jsek_teacherEducation',
           label: '鏁欏笀鏁欒偛',
         },
-
       ],
-
     },
     multipleSelect: {
-      value: [],
+      // value: [],
       options: [],
     },
     navBarHeight: '',
-    barHeight: ''
-
+    barHeight: '',
+    windowHeight: '',
+    sorter: {
+      value: 'timeAsc',
+      options: [{
+          value: 'nameAsc',
+          label: '鍚嶇О姝e簭',
+        },
+        {
+          value: 'nameDesc',
+          label: '鍚嶇О鍊掑簭',
+        },
+        {
+          value: 'timeAsc',
+          label: '鍑虹増鏃堕棿姝e簭',
+        },
+        {
+          value: 'timeDesc',
+          label: '鍑虹増鏃堕棿鍊掑簭',
+        },
+      ],
+    },
+    newValue: ''
   },
 
 
 
   /**
-    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
-    */
+   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
+   */
   onLoad(options) {
-    // console.log(this.data.filteredItems, 88888);
+    console.log(this.data.multipleSelect.options.length, '44444');
+    // this.setData({
+    //   'product.value': '*',
+    // });
     const systInfo = wx.getSystemInfoSync();
     const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅
     const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴�
@@ -77,36 +99,23 @@
       barHeight: systInfo.statusBarHeight,
     })
 
-    // 鍗曞垪閫夋嫨鍣ㄩ�夐」
-    const singleSelectOptions = this.data.filteredItems.map(item => ({
-      label: item.name,
-      value: item.value,
-      disabled: false,
-    }))
 
-    if (this.data.filteredItems = []) {
-      console.log(11111);
-      singleSelectOptions.push({
-        label: '绂佺敤閫夐」',
-        value: 'disabled',
-        disabled: true,
-      });
-    }
-
-    // singleSelectOptions.push({
-    //   label: '绂佺敤閫夐」',
-    //   value: 'disabled',
-    //   disabled: true,
-    // });
-
-
-    // 鏇存柊鏁版嵁
-    this.setData({
-      'multipleSelect.options': singleSelectOptions,
-    });
-
+    // watch.setWatcher(this);
+    // let that = this;
+    // setTimeout(function () {
+    //   that.data.name = "娴嬭瘯watch鍙樺寲浜�"
+    // }, 5000)
+    // 
   },
-
+  watch: {
+    name: function (newVal, oldVal) {
+      //杩欓噷鐨則his鍜宱nLoad閲岀殑this鎸囧悜涓�鏍� 
+      console.log(newVal, oldVal);
+    },
+    newPrice: function (newVal, oldVal) {
+      console.log(newVal, oldVal);
+    }
+  },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
    */
@@ -118,9 +127,12 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
    */
   onShow() {
+    // debugger
     this.bookExhibitionGet()
 
-    this.keyProjectsGet()
+    this.keyProjectsGet(this.data.newPrice)
+
+
   },
 
   /**
@@ -135,6 +147,8 @@
    */
   onUnload() {
 
+
+
   },
 
   /**
@@ -143,15 +157,37 @@
   onPullDownRefresh() {
 
   },
+  // 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',
@@ -168,10 +204,7 @@
         // 'page.start': currentPage,
         'page.size': newSize
       });
-      this.bookExhibitionGet(); // 璋冪敤鏂规硶鍔犺浇鏇村鏁版嵁
-      console.log(1111);
-
-
+      // this.bookExhibitionGet(); // 璋冪敤鏂规硶鍔犺浇鏇村鏁版嵁
     }
   },
 
@@ -192,13 +225,34 @@
       '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,
+      path: this.data.newValue,
       queryType: '*',
       fields: {
         jsek_link: [],
@@ -206,56 +260,144 @@
         '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)
+      // list.push(res.datas)
+
+
+
+      if (res.datas.length == 0) {
+        this.setData({
+          // keynoteDisabled: true
+        })
+      }
+
       const list = [...res.datas]
 
       this.setData({
-        bookExhibitionList: list
+        bookExhibitionList: list,
+        totalSize: res.total
       })
+
+
 
       //鍙栨秷
       wx.hideLoading()
-      // console.log(this.data.bookExhibitionList, '鏁版嵁');
+
+
+      this.setData({
+        loading: false,
+        hidden: false,
+      })
     })
 
   },
   //閲嶇偣椤圭洰鎺ュ彛
-  keyProjectsGet(newPrice) {
-    // console.log(newPrice, 'newPrice');
+  keyProjectsGet() {
+    // debugger
+    if (this.data.multipleSelect.options.length !== 0) {
+      console.log('寮犱竴楦�');
+      this.setData({
+        'multipleSelect.options': [],
+      });
+    }
+    //楠ㄦ灦灞�
+    this.setData({
+      loading: true,
+      hidden: true,
+    })
+
+    // 鍙傛暟
     let parms = {
       refCodes: ['bookClassification']
     }
+    //璇锋眰鏁版嵁
     app.MG.store.getProductTypeField(parms).then(res => {
 
+      // 鏍煎紡鍖栨暟鎹�
       const checkData = JSON.parse(res[0].config)
+      console.log(checkData);
 
-
+      // 寰幆鐒跺悗鍒ゆ柇鐩稿尮閰嶇殑鏁版嵁璧嬪�肩粰filteredItems
       checkData.option.forEach(item => {
-        if (newPrice == item.value) {
+        if (this.data.newPrice == item.value) {
+
+          if (this.data.filteredItems.length !== 0) {
+            this.setData({
+              filteredItems: [] // 濡傛灉瀛樺湪瀛愰」鍒欒祴鍊硷紝鍚﹀垯璧嬪�间负绌烘暟缁�
+            });
+          }
+
 
           this.setData({
             filteredItems: item.child || [] // 濡傛灉瀛樺湪瀛愰」鍒欒祴鍊硷紝鍚﹀垯璧嬪�间负绌烘暟缁�
           });
-
-          // console.log(this.data.filteredItems);
-
         }
       })
 
-      this.onLoad();
+      this.setData({
+        'multipleSelect.options': [],
+      });
+
+      const singleSelectOptions = []
+      console.log(this.data.multipleSelect.options, 'multipleSelect.options');
+      console.log(singleSelectOptions, 'singleSelectOptions');
+      // 鍗曞垪閫夋嫨鍣ㄩ�夐」
+      // 鍗曞垪閫夋嫨鍣ㄩ�夐」
+      this.data.filteredItems.forEach(item => {
+        singleSelectOptions.push({
+          label: item.name,
+          value: item.value,
+        });
+      });
+
+
+
+      if (singleSelectOptions.length === 0) {
+        singleSelectOptions.push({
+          label: '鏆傛棤鏁版嵁',
+
+        });
+
+      }
+
+      // 鏇存柊鏁版嵁
+      this.setData({
+        'multipleSelect.options': singleSelectOptions,
+      });
+
+      // 鍙栨秷楠ㄦ灦灞�
+      this.setData({
+        loading: false,
+        hidden: false,
+      })
     })
+    // if (newPrice) {
+    //   this.setData({
+    //     keynoteDisabled: false
+    //   })
+    // }
+    // if (!newPrice) {
+    //   this.setData({
+    //     keynoteDisabled: true
+    //   })
+    // }
   },
 
 
@@ -265,58 +407,66 @@
   // 鎬诲垎绫�
   onChange(e) {
 
-    this.data.page.size = 16 //鏇存敼鏄剧ず鐨勫��
+    this.setData({
+      'multipleSelect.options': [],
+    });
+    console.log(this.data.multipleSelect.options);
     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);
     this.setData({
       'product.value': newValue,
-      'product.price': newPrice, // 灏嗛�変腑鐨� price 鍊间繚瀛樺湪鏁版嵁涓�
+      newValue: newValue
     });
-    this.bookExhibitionGet(newValue);
-    this.keyProjectsGet(newPrice);
-    // 璋冪敤鏇存柊椤甸潰鏁版嵁鐨勫嚱鏁帮紝浼犲叆鏂扮殑 value 鍜� price 鍊�
 
+    // let newPrice = ''
+    if (newValue == 'jsek_bFHigherEducation') {
+      this.setData({
+        newPrice: 'jsek_higherEducation'
+      })
+    } else if (newValue == 'jsek_bFVocationalEducation') {
+      this.setData({
+        newPrice: 'jsek_vocationalEducation'
+      })
+    } else if (newValue == 'jsek_bFTeacherEducation') {
+      this.setData({
+        newPrice: 'jsek_teacherEducation'
+      })
+    }
+
+    this.keyProjectsGet(this.data.newPrice)
+    this.bookExhibitionGet(newValue);
     if (this.data.keynoteValue) {
       //濡傛灉鏈夋暟鎹氨娓呯┖骞跺埛鏂伴〉闈�
       this.data.keynoteValue = []
-
       this.bookExhibitionGet(newValue)
-      this.onLoad()
-      console.log('true');
-    } else {
-      // this.bookExhibitionGet(newValue);
-      // this.keyProjectsGet(newPrice);
-      console.log('fals');
     }
-
+    this.onLoad()
   },
 
   // 閲嶇偣椤圭洰
   handleMultipleSelect(e) {
+    console.log(e);
     this.setData({
       'multipleSelect.value': e.detail.value,
     });
   },
   handleConfirm(event) {
-    const { value } = event.detail;
+    console.log(event);
+    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',
@@ -336,27 +486,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 // 鍋囪璺宠浆鍒拌鎯呴〉闈紝骞朵紶閫掍簡id鍙傛暟
+      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