From ebfc641a1a1bc6c40b8010f31f7a836f09308b6e Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期三, 27 三月 2024 11:04:19 +0800
Subject: [PATCH] 样式修改

---
 packageDomain/pages/sampleBookList/index.js |  191 ++++++++++++++++++++++++++++++++---------------
 1 files changed, 131 insertions(+), 60 deletions(-)

diff --git a/packageDomain/pages/sampleBookList/index.js b/packageDomain/pages/sampleBookList/index.js
index 30be704..4634442 100644
--- a/packageDomain/pages/sampleBookList/index.js
+++ b/packageDomain/pages/sampleBookList/index.js
@@ -63,6 +63,7 @@
     electronicBookList: [], //鏍蜂功鍗曠數瀛愪功
     paperBookCount: 0, //绾歌川涔﹀墿浣欐鏁�
     ebookCount: 0, //鐢靛瓙涔﹀墿浣欐鏁�
+    num: 0,
   },
 
   /**
@@ -117,7 +118,7 @@
       })
     }
     this.getIconTypeList();
-    this.getBookList(false);
+
     // 鑾峰彇閲嶇偣椤圭洰
     this.getProjectList('bookClassification');
     //鏂板舰鎬佹暀鏉�
@@ -131,16 +132,7 @@
         userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey))
       })
     }
-    if (wx.getStorageSync("paperBookList")) {
-      this.setData({
-        paperBookList: wx.getStorageSync("paperBookList")
-      })
-    }
-    if (wx.getStorageSync("electronicBookList")) {
-      this.setData({
-        electronicBookList: wx.getStorageSync("electronicBookList")
-      })
-    }
+
   },
 
   /**
@@ -154,7 +146,20 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
    */
   onShow() {
-
+    if (wx.getStorageSync("paperBookList")) {
+      this.setData({
+        paperBookList: wx.getStorageSync("paperBookList"),
+      })
+    }
+    if (wx.getStorageSync("electronicBookList")) {
+      this.setData({
+        electronicBookList: wx.getStorageSync("electronicBookList"),
+      })
+    }
+    this.setData({
+      num: this.data.paperBookList.length + this.data.electronicBookList.length
+    })
+    this.getBookList(false);
   },
   goBack() {
     wx.navigateBack();
@@ -299,7 +304,6 @@
         this.setData({
           'newTextBook.options': options,
         });
-        console.log('閲嶇偣椤圭洰', this.data.newTextBook);
       }
     });
   },
@@ -348,9 +352,6 @@
         },
       ],
       sort,
-      coverSize: {
-        height: 145,
-      },
       paging: {
         start: that.data.page * that.data.limit - that.data.limit,
         size: that.data.limit
@@ -389,6 +390,7 @@
                 })
               })
             }
+
             if (that.data.alreadyElectronicBookList.length > 0) {
               that.data.alreadyElectronicBookList.forEach((eBook) => {
                 eBook.content.forEach((eBookItem) => {
@@ -546,7 +548,6 @@
   },
   // 鎼滅储鍥句功
   searchBook(e) {
-    console.log(e.detail.value);
     this.setData({
       searchValue: e.detail.value,
     });
@@ -572,13 +573,15 @@
       }
     }
     app.MG.ugc.getTopicMessageList(data).then((res) => {
+      let list = [];
       res.datas.map((item) => {
         if (item.content) {
           item.content = JSON.parse(item.content)
         }
+        list.push(item)
       })
       this.setData({
-        alreadyPaperBookList: res.datas,
+        alreadyPaperBookList: list,
       });
     })
   },
@@ -596,27 +599,29 @@
     }
     app.MG.ugc.getTopicMessageList(data).then((res) => {
       let list = []
-      res.datas.map((item) => {
-        if (item.feedBack) {
-          item.feedBack = JSON.parse(item.feedBack)
-          if (item.feedBack.endDate) {
-            let times = new Date(item.feedBack.endDate + ' 23:59:59').getTime()
-            let currentDate = new Date().getTime()
-            if (times < currentDate) {
-              item.isExpiry = true
+      if (res.datas.length > 0) {
+        res.datas.map((item) => {
+          if (item.feedBack) {
+            item.feedBack = JSON.parse(item.feedBack)
+            if (item.feedBack.endDate) {
+              let times = new Date(item.feedBack.endDate + ' 23:59:59').getTime()
+              let currentDate = new Date().getTime()
+              if (times < currentDate) {
+                item.isExpiry = true
+              }
             }
           }
-        }
-        if (item.content) {
-          item.content = JSON.parse(item.content)
-        }
-        if (item.state != 'Reject') {
-          list.push(item)
-        }
-      })
-      this.setData({
-        alreadyElectronicBookList: list,
-      });
+          if (item.content) {
+            item.content = JSON.parse(item.content)
+          }
+          if (item.state != 'Reject') {
+            list.push(item)
+          }
+        })
+        this.setData({
+          alreadyElectronicBookList: list,
+        });
+      }
     })
   },
 
@@ -681,12 +686,12 @@
         })
         return
       }
-
       if (item.paperChecked) {
-        if (this.data.paperBookList.length > 0) {
-          this.data.paperBookList.forEach((obj, index) => {
+        let pList = this.data.paperBookList;
+        if (pList.length > 0) {
+          pList.forEach((obj, index) => {
             if (obj.id == item.id) {
-              this.data.paperBookList.splice(index, 1);
+              pList.splice(index, 1);
             }
           })
         }
@@ -703,7 +708,11 @@
           icon: 'none',
           duration: 1000,
         })
-        wx.setStorageSync("paperBookList", JSON.stringify(this.data.paperBookList));
+        this.setData({
+          paperBookList: pList,
+          num: pList.length + this.data.electronicBookList.length
+        })
+        wx.setStorageSync("paperBookList", JSON.stringify(pList));
         return
       }
       if (role == 'Teacher') {
@@ -757,10 +766,11 @@
         return
       }
       if (item.electronChecked) {
-        if (this.data.electronicBookList) {
-          this.data.electronicBookList.forEach((obj, index) => {
+        let eList = this.data.electronicBookList;
+        if (eList.length > 0) {
+          eList.forEach((obj, index) => {
             if (obj.id == item.id) {
-              this.data.electronicBookList.splice(index, 1);
+              eList.splice(index, 1);
             }
           })
         }
@@ -777,7 +787,11 @@
           icon: 'none',
           duration: 1000,
         })
-        wx.setStorageSync("electronicBookList", JSON.stringify(this.data.electronicBookList));
+        this.setData({
+          electronicBookList: eList,
+          num: eList.length + this.data.paperBookList.length
+        })
+        wx.setStorageSync("electronicBookList", eList);
         return
       }
       if (role == 'Teacher') {
@@ -830,6 +844,8 @@
           }
         })
       }
+    } else {
+      item.electronChecked = false
     }
   },
   getSelectBookCount(item) {
@@ -868,7 +884,14 @@
       if (this.data.ebookCount > 0) {
         const eBookData = this.data.electronicBookList
         if (eBookData.length == 2) {
-          item.electronChecked = false
+          if (this.data.bookList.length > 0) {
+            this.data.bookList.forEach(i => {
+              if (i.id == item.id) {
+                i.electronChecked = false;
+              }
+            })
+          }
+          item.electronChecked = false;
           wx.showToast({
             title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�",
             icon: 'none',
@@ -889,16 +912,30 @@
               duration: 1000,
             })
             this.setData({
-              electronicBookList: [...this.data.electronicBookList, ...[item]]
+              electronicBookList: [...this.data.electronicBookList, ...[itemAttr]],
             })
-            wx.setStorageSync("electronicBookList", JSON.stringify(this.data.electronicBookList));
+            wx.setStorageSync("electronicBookList", this.data.electronicBookList);
+            this.setData({
+              num: this.data.electronicBookList.length + this.data.paperBookList.length
+            })
           } else {
+            let list = this.data.electronicBookList;
+            list.forEach((obj, index) => {
+              if (obj.id == item.id) {
+                list.splice(index, 1);
+              }
+            })
             item.electronChecked = false
             wx.showToast({
-              title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�",
+              title: "宸蹭粠鏍蜂功鐢宠鍗曠Щ闄�",
               icon: "none",
               duration: 1000,
             })
+            this.setData({
+              electronicBookList: list,
+              num: list.length + this.data.paperBookList.length
+            })
+            wx.setStorageSync("electronicBookList", list);
           }
         } else {
           wx.showToast({
@@ -907,9 +944,10 @@
             duration: 1000,
           })
           this.setData({
-            electronicBookList: [...this.data.electronicBookList, ...[item]]
+            electronicBookList: [itemAttr],
+            num: 1 + this.data.paperBookList.length
           })
-          wx.setStorageSync("electronicBookList", JSON.stringify(this.data.electronicBookList));
+          wx.setStorageSync("electronicBookList", [itemAttr]);
         }
       } else {
         item.electronChecked = false
@@ -923,6 +961,13 @@
       if (this.data.paperBookCount > 0) {
         const pBookData = this.data.paperBookList
         if (pBookData.length == 2) {
+          if (this.data.bookList.length > 0) {
+            this.data.bookList.forEach(i => {
+              if (i.id == item.id) {
+                i.paperChecked = false;
+              }
+            })
+          }
           item.paperChecked = false
           wx.showToast({
             title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�",
@@ -945,17 +990,30 @@
               duration: 1000,
             })
             this.setData({
-              paperBookList: [...this.data.paperBookList, ...[item]]
+              paperBookList: [...this.data.paperBookList, ...[itemAttr]],
             })
-            wx.setStorageSync("paperBookList", JSON.stringify(this.data.paperBookList));
-            console.log(this.data.paperBookList, "3")
+            wx.setStorageSync("paperBookList", this.data.paperBookList);
+            this.setData({
+              num: this.data.paperBookList.length + this.data.electronicBookList.length
+            })
           } else {
+            let list = this.data.paperBookList;
+            list.forEach((obj, index) => {
+              if (obj.id == item.id) {
+                list.splice(index, 1);
+              }
+            })
             item.paperChecked = false
             wx.showToast({
-              title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�",
-              icon: 'none',
+              title: "宸蹭粠鏍蜂功鐢宠鍗曠Щ闄�",
+              icon: "none",
               duration: 1000,
             })
+            this.setData({
+              paperChecked: list,
+              num: list.length + this.data.electronicBookList.length
+            })
+            wx.setStorageSync("paperBookList", list);
           }
         } else {
           item.paperChecked = true;
@@ -965,10 +1023,10 @@
             duration: 1000,
           })
           this.setData({
-            paperBookList: [item]
+            paperBookList: [itemAttr],
+            num: 1 + this.data.electronicBookList.length
           })
-          wx.setStorageSync("paperBookList", JSON.stringify(this.data.paperBookList));
-          console.log(this.data.paperBookList, "4")
+          wx.setStorageSync("paperBookList", [itemAttr]);
         }
       } else {
         item.paperChecked = false
@@ -986,6 +1044,19 @@
       url: "/packageDomain/pages/sampleBookList/applicationForm/index",
     });
   },
+
+  // 鐩戝惉婊氬姩璺濈
+  onPageScroll(e) {
+    if (e && e.scrollTop >= 1000) {
+      this.setData({
+        isBackTop: true
+      })
+    } else {
+      this.setData({
+        isBackTop: false
+      })
+    }
+  },
   /**
    * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
    */

--
Gitblit v1.9.1