From cb2fcaef30cc26ed6273eff93f918ea702fa5957 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期四, 19 九月 2024 13:36:06 +0800
Subject: [PATCH] yangshu

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

diff --git a/packageDomain/pages/sampleBookList/index.js b/packageDomain/pages/sampleBookList/index.js
index 86387b0..66082cd 100644
--- a/packageDomain/pages/sampleBookList/index.js
+++ b/packageDomain/pages/sampleBookList/index.js
@@ -153,6 +153,7 @@
           // 鑾峰彇鐢宠娆℃暟
           that.getSelectPaperBookCount()
           that.getSelectBookCount()
+
         }
       })
     } else {
@@ -165,6 +166,7 @@
         num: paperBookList + electronicBookList
       })
     }
+    that.getBookList(false)
   },
 
   /**
@@ -179,11 +181,11 @@
    */
   onShow() {
     let that = this;
-    that.setData({
-      page: 1,
-      paperBookList: [],
-      electronicBookList: []
-    })
+    // that.setData({
+    //   page: 1,
+    //   paperBookList: [],
+    //   electronicBookList: []
+    // })
     that.getAlreadyPBookList()
     that.getAlreadyEBookList()
     // 鑾峰彇鐢宠娆℃暟
@@ -204,7 +206,8 @@
         num: Number(that.data.paperBookList.length) + Number(that.data.electronicBookList.length)
       })
     }
-    that.getBookList(false);
+    // that.getBookList(false);
+    that.dataRebuild(that.data.bookList)
   },
   onHide() {
     const query = wx.createSelectorQuery()
@@ -447,59 +450,7 @@
     app.MG.store.getProductList(query).then((res) => {
       try {
         if (res.datas.length > 0) {
-          res.datas.forEach((item) => {
-            item.paperDisabled = false
-            item.paperChecked = false
-            item.electronDisabled = false
-            item.electronChecked = false
-            if (item.purchasedSaleMethodIdList.indexOf(item.defaultSaleMethodId) > -1) {
-              item.electronDisabled = true
-              item.electronChecked = true
-            }
-            if (that.data.alreadyPaperBookList.length > 0) {
-              that.data.alreadyPaperBookList.forEach((pBook) => {
-                if (pBook.content.length > 0) {
-                  pBook.content.forEach((pBookItem) => {
-                    if (pBookItem.id === item.id && pBook.state == 'WaitAudit') {
-                      item.paperDisabled = true
-                      item.paperChecked = true
-                    }
-                    if (pBookItem.id === item.id && pBook.state == 'Normal') {
-                      item.paperDisabled = false
-                    }
-                  })
-                }
-              })
-            }
-
-            if (that.data.alreadyElectronicBookList.length > 0) {
-              that.data.alreadyElectronicBookList.forEach((eBook) => {
-                if (eBook.content.length > 0) {
-                  eBook.content.forEach((eBookItem) => {
-                    if (eBookItem.id === item.id && !eBook.isExpiry && eBook.state != 'Reject') {
-                      item.electronDisabled = true
-                      item.electronChecked = true
-                    }
-                  })
-                }
-              })
-            }
-            if (that.data.paperBookList.length > 0) {
-              for (let i = 0; i < that.data.paperBookList.length; i++) {
-                if (that.data.paperBookList[i].id == item.id) {
-                  item.paperChecked = true
-                }
-              }
-            }
-            if (that.data.electronicBookList.length > 0) {
-              for (let i = 0; i < that.data.electronicBookList.length; i++) {
-                if (that.data.electronicBookList[i].id == item.id) {
-                  item.electronChecked = true
-                }
-              }
-            }
-          });
-          let list = res.datas;
+          let list = this.dataRebuild(res.datas);
           //瑙﹀簳鍔犺浇鏂版暟鎹苟淇濈暀鑰佹暟鎹�
           if (isReachBottom) {
             list = [...this.data.bookList, ...list] //灏嗘柊鏁版嵁鍔犲叆鑰佹暟鎹腑
@@ -521,6 +472,65 @@
       }
     });
   },
+  dataRebuild(list) {
+    let that = this;
+    console.log(list, 123)
+    list.forEach((item) => {
+      item.paperDisabled = false
+      item.paperChecked = false
+      item.electronDisabled = false
+      item.electronChecked = false
+      if (item.purchasedSaleMethodIdList.indexOf(item.defaultSaleMethodId) > -1) {
+        item.electronDisabled = true
+        item.electronChecked = true
+      }
+      if (that.data.alreadyPaperBookList.length > 0) {
+        that.data.alreadyPaperBookList.forEach((pBook) => {
+          if (pBook.content.length > 0) {
+            pBook.content.forEach((pBookItem) => {
+              if (pBookItem.id === item.id && pBook.state == 'WaitAudit') {
+                item.paperDisabled = true
+                item.paperChecked = true
+              }
+              if (pBookItem.id === item.id && pBook.state == 'Normal') {
+                item.paperDisabled = false
+              }
+            })
+          }
+        })
+      }
+
+      if (that.data.alreadyElectronicBookList.length > 0) {
+        that.data.alreadyElectronicBookList.forEach((eBook) => {
+          if (eBook.content.length > 0) {
+            eBook.content.forEach((eBookItem) => {
+              if (eBookItem.id === item.id && !eBook.isExpiry && eBook.state != 'Reject') {
+                item.electronDisabled = true
+                item.electronChecked = true
+              }
+            })
+          }
+        })
+      }
+      if (that.data.paperBookList.length > 0) {
+        for (let i = 0; i < that.data.paperBookList.length; i++) {
+          if (that.data.paperBookList[i].id == item.id) {
+            item.paperChecked = true
+          }
+        }
+      }
+      if (that.data.electronicBookList.length > 0) {
+        for (let i = 0; i < that.data.electronicBookList.length; i++) {
+          if (that.data.electronicBookList[i].id == item.id) {
+            item.electronChecked = true
+          }
+        }
+      }
+    });
+    return list
+  },
+
+
   //楂樼骇鍒嗙被閫夋嫨
   onChangeIcon(e) {
     this.setData({
@@ -679,9 +689,6 @@
         this.setData({
           alreadyElectronicBookList: list,
         });
-        if (wx.getStorageSync(app.config.tokenKey)) {
-          this.getBookList(false);
-        }
       }
     })
   },

--
Gitblit v1.9.1