From 5b19b0e39a91e566a835460bf1213e7b3a0582b9 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期一, 17 三月 2025 14:27:14 +0800
Subject: [PATCH] 图

---
 packageDomain/pages/sampleBookList/index.js |  212 ++++++++++++++++++++++++++++++++++------------------
 1 files changed, 139 insertions(+), 73 deletions(-)

diff --git a/packageDomain/pages/sampleBookList/index.js b/packageDomain/pages/sampleBookList/index.js
index 4264802..66082cd 100644
--- a/packageDomain/pages/sampleBookList/index.js
+++ b/packageDomain/pages/sampleBookList/index.js
@@ -84,6 +84,7 @@
     num: 0,
     x: 280,
     y: 300,
+    scrollTop: 0
   },
 
   /**
@@ -159,8 +160,13 @@
       that.setData({
         userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey))
       })
-
+      const paperBookList = wx.getStorageSync('paperBookList') ? JSON.parse(wx.getStorageSync('paperBookList')).length : 0
+      const electronicBookList = wx.getStorageSync('electronicBookList') ? JSON.parse(wx.getStorageSync('electronicBookList')).length : 0
+      this.setData({
+        num: paperBookList + electronicBookList
+      })
     }
+    that.getBookList(false)
   },
 
   /**
@@ -175,11 +181,11 @@
    */
   onShow() {
     let that = this;
-    that.setData({
-      page: 1,
-      paperBookList: [],
-      electronicBookList: []
-    })
+    // that.setData({
+    //   page: 1,
+    //   paperBookList: [],
+    //   electronicBookList: []
+    // })
     that.getAlreadyPBookList()
     that.getAlreadyEBookList()
     // 鑾峰彇鐢宠娆℃暟
@@ -200,7 +206,19 @@
         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()
+    query.select('#scrollView').scrollOffset(res => {
+      console.log(1, res);
+      this.setData({
+        scrollTop: res.scrollTop
+      })
+      console.log('闅愯棌', this.data.scrollTop);
+    }).exec()
+
   },
   goBack() {
     wx.navigateBack();
@@ -422,6 +440,8 @@
         author: [],
         isbn: [],
         publicationDate: [],
+        pdf: [],
+        protectedEpub: [],
         isApplyBook: [],
         'isApplyBook>': ['1'],
         ...searchObj,
@@ -430,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] //灏嗘柊鏁版嵁鍔犲叆鑰佹暟鎹腑
@@ -504,14 +472,76 @@
       }
     });
   },
+  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({
+      skeletonLoding: true,
+      bookList: [],
       'assortCheck.code': e.detail.value,
       stairCode: '',
       secondCode: '',
       path: `${e.detail.value}`,
       'iconList.value': e.detail.value,
+
     });
     this.getBookList(false);
     this.getStairList(this.data.assortCheck.code);
@@ -523,17 +553,20 @@
       `${this.data.assortCheck.code}\\${e.detail.value}` :
       this.data.assortCheck.code;
     this.setData({
+      skeletonLoding: true,
+      bookList: [],
       pathList: [],
       stairCode: e.detail.value,
       secondCode: '',
       path: path,
       'stairList.value': e.detail.value,
+      'secondList.value': ""
     });
     this.getBookList(false);
     this.getSecondList(path);
   },
-  // 浜岀骇鍒嗙被鍒囨崲
-  onChangeSecond(e) {
+  // 浜岀骇鍒嗙被鍒囨崲 
+  onConfirmSecond(e) {
     const pathList = [];
     for (let index = 0; index < e.detail.value.length; index++) {
       const element = e.detail.value[index];
@@ -544,17 +577,16 @@
       });
     }
     this.setData({
+      skeletonLoding: true,
       pathList: pathList,
       'secondList.value': e.detail.value,
     });
-
-  },
-  // 
-  onConfirmSecond() {
     this.getBookList(false);
   },
   onResetSecond() {
     this.setData({
+      skeletonLoding: true,
+      pathList: [],
       'secondList.value': [],
     });
     this.getBookList(false);
@@ -657,9 +689,6 @@
         this.setData({
           alreadyElectronicBookList: list,
         });
-        if (wx.getStorageSync(app.config.tokenKey)) {
-          this.getBookList(false);
-        }
       }
     })
   },
@@ -779,7 +808,7 @@
   },
 
   //閫夋嫨鐢靛瓙鏍蜂功
-  onChangeElectron(e) {
+  async onChangeElectron(e) {
     const item = e.currentTarget.dataset.book;
     const index = this.data.bookList.findIndex(citem => citem.id == item.id)
     let role = this.data.userInfo != null ? this.data.userInfo.role : null
@@ -787,6 +816,44 @@
       // 鏄暀甯�
       if (e.detail.checked) {
         // 鐐瑰嚮閫変腑
+        //鍟嗗搧鏈夋棤鐢靛瓙涔� 
+        const obj = {
+          path: '*',
+          queryType: 'SubProduct',
+          sort: {
+            type: 'Desc',
+            field: 'CreateDate'
+          },
+          paging: {
+            start: 0,
+            size: 1
+          },
+          mainProductId: item.id,
+          fields: {
+            bookshelf_pdf: [],
+            bookshelf_protectedEpub: [],
+          }
+        }
+        const res = await app.MG.store.getProductList(obj)
+        if (res.datas.length > 0) {
+          if (!res.datas[0].bookshelf_pdf && !res.datas[0].bookshelf_protectedEpub) {
+            wx.showToast({
+              title: "鏆傛棤鐢靛瓙涔︽枃浠�,璇疯仈绯荤鐞嗗憳!",
+              icon: 'none',
+              duration: 1000,
+            })
+            return false;
+          }
+        } else {
+          if (!item.pdf && !item.protectedEpub) {
+            wx.showToast({
+              title: "鏆傛棤鐢靛瓙涔︽枃浠�,璇疯仈绯荤鐞嗗憳!",
+              icon: 'none',
+              duration: 1000,
+            })
+            return false;
+          }
+        }
         if (this.data.ebookCount == 0) {
           wx.showToast({
             title: "鎮ㄧ殑鐢靛瓙鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒",
@@ -905,7 +972,6 @@
   /**
    * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
    */
-  onShareAppMessage() {
-
-  }
+  onShareAppMessage() {},
+  onShareTimeline() {},
 })
\ No newline at end of file

--
Gitblit v1.9.1