From aa2c08b3be23a01d44205b2c19d21a2bf53f944f Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期一, 01 四月 2024 16:15:38 +0800
Subject: [PATCH] 图书服务列表、详情页bug修改

---
 packageBookService/pages/bookServices/list/index.js |  215 ++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 171 insertions(+), 44 deletions(-)

diff --git a/packageBookService/pages/bookServices/list/index.js b/packageBookService/pages/bookServices/list/index.js
index 5cd1be5..944f48b 100644
--- a/packageBookService/pages/bookServices/list/index.js
+++ b/packageBookService/pages/bookServices/list/index.js
@@ -34,10 +34,32 @@
       options: [],
       disabled: false,
     },
-    disabledSecondList: false,
     majorProjectList: {
       value: [],
       options: [],
+    },
+    sortList: {
+      value: 'default',
+      options: [{
+          value: 'default',
+          label: '榛樿鎺掑簭',
+        }, {
+          value: 'name-asc',
+          label: '鍚嶇О姝e簭'
+        },
+        {
+          value: 'name-desc',
+          label: '鍚嶇О鍊掑彊'
+        },
+        {
+          value: 'time-asc',
+          label: '鍑虹増鏃堕棿姝e簭'
+        },
+        {
+          value: 'time-desc',
+          label: '鍑虹増鏃堕棿鍊掑彊'
+        }
+      ],
     },
     newTextBook: {
       value: [],
@@ -53,6 +75,12 @@
     loading: false,
     noData: false,
     showDropdown: false,
+    isRequesting: false,
+    disabledStair: false,
+    disabledSecondList: false,
+    disabledProject: false,
+    disabledNewForms: false,
+    triggered: false,
   },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
@@ -134,7 +162,13 @@
    * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
    */
   onPullDownRefresh() {
-    console.log('涓嬫媺');
+    this.setData({
+      triggered: true
+    })
+    this.setData({
+      'pageCount.page': 1
+    })
+    this.getBookList(this.data.path);
   },
 
   /**
@@ -143,11 +177,13 @@
   onReachBottom(e) {
     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)
+      if (!this.data.isRequesting) {
+        this.setData({
+          isMore: true,
+          "pageCount.page": this.data.pageCount.page + 1
+        })
+        this.getBookList(this.data.path)
+      }
     } else {
       this.setData({
         isMore: true,
@@ -170,6 +206,9 @@
   },
   // 鑾峰彇涓�绾у垪琛�
   getStairList(path) {
+    this.setData({
+      disabledStair: false
+    })
     const query = {
       path,
       filterList: [],
@@ -199,6 +238,11 @@
         'stairList.options': options,
         'stairList.value': this.data.stairCode,
       });
+      if (!options.length) {
+        this.setData({
+          disabledStair: true
+        })
+      }
     });
   },
   // 鑾峰彇涓�绾у垎绫讳笅浜岀骇鍒嗙被
@@ -236,6 +280,10 @@
   },
   // 鑾峰彇閲嶇偣椤圭洰
   getProjectList(type) {
+    this.setData({
+      disabledProject: false,
+      disabledNewForms: false
+    })
     const options = [];
     const arr = [];
     let array = [];
@@ -243,7 +291,7 @@
       refCodes: [type],
     };
     app.MG.store.getProductTypeField(query).then((res) => {
-      array = JSON.parse(res[0].config).option;
+      array = JSON.parse(res[0].config).option.filter(item => item.value == this.data.assortCheck.code);
       for (let index = 0; index < array.length; index++) {
         const element = array[index];
         if (element.child) {
@@ -261,6 +309,11 @@
             label: element.name,
           });
         }
+        if (!options.length) {
+          this.setData({
+            disabledProject: true
+          })
+        }
         this.setData({
           'majorProjectList.options': options,
         });
@@ -272,6 +325,11 @@
             label: element.name,
           });
         }
+        if (!options.length) {
+          this.setData({
+            disabledNewForms: true
+          })
+        }
         this.setData({
           'newTextBook.options': options,
         });
@@ -281,9 +339,13 @@
   },
   // 鑾峰彇鍥句功鍒楄〃
   getBookList(path) {
+    if (this.data.isRequesting) {
+      return false;
+    }
     this.setData({
       loading: true,
-      noData: false
+      noData: false,
+      isRequesting: true
     })
     let sort;
     let pathObj = {};
@@ -297,17 +359,44 @@
         queryType: '*',
       };
     }
-    if (this.data.sort) {
+    if (this.data.sortList.value == 'name-asc') {
       sort = {
-        Name: this.data.sort,
-        BaseType: '',
-      };
-    } else {
+        Name: 'Asc',
+        BaseType: ''
+      }
+    } else if (this.data.sortList.value == 'name-desc') {
       sort = {
-        type: 'Desc',
-        field: 'ViewCount',
-      };
+        Name: 'Desc',
+        BaseType: ''
+      }
+    } else if (this.data.sortList.value == 'time-asc') {
+      sort = {
+        PublicationDate: 'Asc',
+        BaseType: 'DateTime'
+      }
+    } else if (this.data.sortList.value == 'time-desc') {
+      debugger
+      sort = {
+        PublicationDate: 'Desc',
+        BaseType: 'DateTime'
+      }
+    } else if (this.data.sortList.value == 'default') {
+      sort = {
+        field: 'order',
+        type: 'Desc'
+      }
     }
+    // if (this.data.sort) {
+    //   sort = {
+    //     Name: this.data.sort,
+    //     BaseType: '',
+    //   };
+    // } else {
+    //   sort = {
+    //     type: 'Desc',
+    //     field: 'ViewCount',
+    //   };
+    // }
     // 鎼滅储
     let searchObj = {};
     if (this.data.searchValue) {
@@ -342,11 +431,30 @@
         bookList: res.datas,
         enable: false,
         "pageCount.total": res.total,
-        loading: false
+        loading: false,
+        isRequesting: false
       });
       if (!res.datas.length) {
         this.setData({
           noData: true,
+        })
+        if (!this.data.pathList.length) {
+          // 鏈�夋嫨浜岀骇鍒嗙被锛屼笖鏃犲浘涔�
+          this.setData({
+            disabledSecondList: true
+          })
+        } else {
+          this.setData({
+            disabledSecondList: false
+          })
+        }
+      }
+      if (this.data.triggered) {
+        this.setData({
+          triggered: false
+        })
+        wx.showToast({
+          title: '鍒锋柊鎴愬姛',
         })
       }
     });
@@ -411,33 +519,12 @@
     });
     this.getBookList(this.data.path);
   },
-  changeNewText(e) {
+  // 鎺掑簭鍒囨崲
+  onSortChange(e) {
     this.setData({
-      'newTextBook.value': e.detail.value,
-    });
-    this.getBookList(this.data.path);
-  },
-  resetNewText() {
-    this.setData({
-      'newTextBook.value': [],
-    });
-    this.getBookList(this.data.path);
-  },
-  // 鎺掑簭鎸夐挳
-  sortClick() {
-    if (!this.data.sort.length) {
-      this.setData({
-        sort: 'Desc',
-      });
-    } else if (this.data.sort == 'Desc') {
-      this.setData({
-        sort: 'Asc',
-      });
-    } else if (this.data.sort == 'Asc') {
-      this.setData({
-        sort: '',
-      });
-    }
+      'sortList.value': e.detail.value
+    })
+
     let path;
     if (this.data.secondCode) {
       path = this.data.secondCode;
@@ -451,6 +538,46 @@
     });
     this.getBookList(path);
   },
+  changeNewText(e) {
+    this.setData({
+      'newTextBook.value': e.detail.value,
+    });
+    this.getBookList(this.data.path);
+  },
+  resetNewText() {
+    this.setData({
+      'newTextBook.value': [],
+    });
+    this.getBookList(this.data.path);
+  },
+  // 鎺掑簭鎸夐挳
+  // sortClick() {
+  //   if (!this.data.sort.length) {
+  //     this.setData({
+  //       sort: 'Desc',
+  //     });
+  //   } else if (this.data.sort == 'Desc') {
+  //     this.setData({
+  //       sort: 'Asc',
+  //     });
+  //   } else if (this.data.sort == 'Asc') {
+  //     this.setData({
+  //       sort: '',
+  //     });
+  //   }
+  //   let path;
+  //   if (this.data.secondCode) {
+  //     path = this.data.secondCode;
+  //   } else if (this.data.stairCode) {
+  //     path = `${this.data.assortCheck.code}\\${this.data.stairCode}`;
+  //   } else {
+  //     path = this.data.assortCheck.code;
+  //   }
+  //   this.setData({
+  //     path: path,
+  //   });
+  //   this.getBookList(path);
+  // },
   // 鎼滅储鍥句功
   searchBook(e) {
     console.log(e.detail.value);

--
Gitblit v1.9.1