From dc934dfd63fecff84d0bf996418e041b9bd4ea59 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期二, 30 四月 2024 18:16:13 +0800
Subject: [PATCH] bug修改

---
 packageDomain/pages/sampleBookList/index.js |  207 +++++++++++++++++++++++++--------------------------
 1 files changed, 102 insertions(+), 105 deletions(-)

diff --git a/packageDomain/pages/sampleBookList/index.js b/packageDomain/pages/sampleBookList/index.js
index 6861e0e..afec91a 100644
--- a/packageDomain/pages/sampleBookList/index.js
+++ b/packageDomain/pages/sampleBookList/index.js
@@ -14,7 +14,6 @@
     userInfo: null,
     path: '*',
     pathList: [],
-
     bookList: [],
     //楂樼骇鍒嗙被
     iconList: {
@@ -24,20 +23,13 @@
     //涓�绾у垎绫�
     stairList: {
       value: '',
-      options: [],
+      options: [{
+        value: "",
+        label: "涓�绾у垎绫�",
+      }],
     },
     //浜岀骇鍒嗙被
     secondList: {
-      value: [],
-      options: [],
-    },
-    //閲嶇偣椤圭洰
-    majorProjectList: {
-      value: [],
-      options: [],
-    },
-    //鏂板舰鎬佹暀鏉�
-    newTextBook: {
       value: [],
       options: [],
     },
@@ -46,7 +38,6 @@
       name: '',
       code: '',
     },
-
     stairCode: '', // 涓�绾у垎绫婚�変腑椤�
     secondCode: '', // 浜岀骇鍒嗙被閫変腑椤�
     sort: '', // 鎺掑簭
@@ -91,28 +82,31 @@
     paperBookCount: 0, //绾歌川涔﹀墿浣欐鏁�
     ebookCount: 0, //鐢靛瓙涔﹀墿浣欐鏁�
     num: 0,
+    x: 280,
+    y: 300,
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad(options) {
+    let that = this;
     const systInfo = wx.getSystemInfoSync();
     const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅
     const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴�
-    this.setData({
+    that.setData({
       barHeight: systInfo.statusBarHeight,
       navBarHeight: navBarHeight,
     });
     // 鎼滅储璧嬪��
     if (options && options.searchValue) {
-      this.setData({
+      that.setData({
         searchValue: options.searchValue,
       });
     }
     // 楂樼骇鍒嗙被璧嬪��
     if (options && options.assortCode) {
-      this.setData({
+      that.setData({
         assortCheck: {
           name: options.assorName,
           code: options.assortCode,
@@ -120,13 +114,13 @@
         },
       });
     }
-    if (this.data.assortCheck.code) {
+    if (that.data.assortCheck.code) {
       // 鑾峰彇涓�绾у垎绫�
-      this.getStairList(this.data.assortCheck.code);
+      ththatis.getStairList(that.data.assortCheck.code);
     }
     // 涓�绾у垎绫诲拰path璧嬪��
     if (options && options.assortCode && options.stairCode) {
-      this.setData({
+      that.setData({
         'stairList.value': options.stairCode,
         stairCode: options.stairCode,
         path: `${options.assortCode}\\${options.stairCode}`,
@@ -134,7 +128,7 @@
     }
     // 浜岀骇鍒嗙被璧嬪��
     if (options && options.secondCode) {
-      this.setData({
+      that.setData({
         secondCode: options.secondCode,
         pathList: [{
           Path: options.secondCode,
@@ -143,33 +137,32 @@
         }],
       })
     }
-    this.getIconTypeList();
-    // 鑾峰彇閲嶇偣椤圭洰
-    this.getProjectList('bookClassification');
-    //鏂板舰鎬佹暀鏉�
-    this.getProjectList('newFormsTextbooks');
+    that.getIconTypeList();
 
     // 妫�鏌ョ櫥褰曠姸鎬�
     const token = wx.getStorageSync(app.config.tokenKey)
     if (!token) {
       loginInfo(app, (data) => {
         if (data) {
-          this.setData({
+          that.setData({
             userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey))
           })
-          this.getAlreadyPBookList()
-          this.getAlreadyEBookList()
+          that.getAlreadyPBookList()
+          that.getAlreadyEBookList()
           // 鑾峰彇鐢宠娆℃暟
-          this.getSelectPaperBookCount()
-          this.getSelectBookCount()
-
+          that.getSelectPaperBookCount()
+          that.getSelectBookCount()
         }
       })
     } else {
-      this.setData({
+      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
+      })
     }
   },
 
@@ -184,32 +177,33 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
    */
   onShow() {
-    this.setData({
+    let that = this;
+    that.setData({
       page: 1,
       paperBookList: [],
       electronicBookList: []
     })
-    this.getAlreadyPBookList()
-    this.getAlreadyEBookList()
+    that.getAlreadyPBookList()
+    that.getAlreadyEBookList()
     // 鑾峰彇鐢宠娆℃暟
-    this.getSelectPaperBookCount()
-    this.getSelectBookCount()
+    that.getSelectPaperBookCount()
+    that.getSelectBookCount()
     if (wx.getStorageSync("paperBookList") || wx.getStorageSync("electronicBookList")) {
       if (wx.getStorageSync("paperBookList")) {
-        this.setData({
-          paperBookList: wx.getStorageSync("paperBookList"),
+        that.setData({
+          paperBookList: JSON.parse(wx.getStorageSync("paperBookList")),
         })
       }
       if (wx.getStorageSync("electronicBookList")) {
-        this.setData({
-          electronicBookList: wx.getStorageSync("electronicBookList"),
+        that.setData({
+          electronicBookList: JSON.parse(wx.getStorageSync("electronicBookList")),
         })
       }
-      this.setData({
-        num: this.data.paperBookList.length + this.data.electronicBookList.length
+      that.setData({
+        num: Number(that.data.paperBookList.length) + Number(that.data.electronicBookList.length)
       })
     }
-    this.getBookList(false);
+    that.getBookList(false);
   },
   goBack() {
     wx.navigateBack();
@@ -260,7 +254,10 @@
       }
     }
     app.MG.store.getStoreChannelList(query).then((res) => {
-      let list = [];
+      let list = [{
+        value: "",
+        label: "鎬诲垎绫�",
+      }];
       if (res.datas.length > 0)(
         res.datas.forEach((item) => {
           item.value = item.refCode;
@@ -276,7 +273,7 @@
       )
       this.setData({
         'iconList.options': list,
-        'iconList.value': this.data.assortCode,
+        'iconList.value': this.data.assortCheck.code,
       });
     })
   },
@@ -296,7 +293,10 @@
       },
     };
     app.MG.store.getStoreChannelList(query).then(async (res) => {
-      let options = [];
+      let options = [{
+        value: "",
+        label: "涓�绾у垎绫�",
+      }];
       if (res.datas.length > 0) {
         for (let index = 0; index < res.datas.length; index++) {
           let item = res.datas[index];
@@ -347,50 +347,7 @@
       })
     });
   },
-  // 鑾峰彇閲嶇偣椤圭洰
-  getProjectList(type) {
-    const options = [];
-    const arr = [];
-    let array = [];
-    const query = {
-      refCodes: [type],
-    };
-    app.MG.store.getProductTypeField(query).then((res) => {
-      array = JSON.parse(res[0].config).option;
-      for (let index = 0; index < array.length; index++) {
-        const element = array[index];
-        if (element.child) {
-          for (let index = 0; index < element.child.length; index++) {
-            const item = element.child[index];
-            arr.push(item);
-          }
-        }
-      }
-      if (type == 'bookClassification') {
-        for (let index = 0; index < arr.length; index++) {
-          const element = arr[index];
-          options.push({
-            value: element.value,
-            label: element.name,
-          });
-        }
-        this.setData({
-          'majorProjectList.options': options,
-        });
-      } else if (type == 'newFormsTextbooks') {
-        for (let index = 0; index < arr.length; index++) {
-          const element = arr[index];
-          options.push({
-            value: element.value,
-            label: element.name,
-          });
-        }
-        this.setData({
-          'newTextBook.options': options,
-        });
-      }
-    });
-  },
+
   // 鑾峰彇鍥句功鍒楄〃
   getBookList(isReachBottom) {
     let that = this;
@@ -468,6 +425,8 @@
         author: [],
         isbn: [],
         publicationDate: [],
+        pdf: [],
+        protectedEpub: [],
         isApplyBook: [],
         'isApplyBook>': ['1'],
         ...searchObj,
@@ -539,14 +498,10 @@
             bottomLoading: false,
             isMoreData: list.length > 0 ? false : true,
             skeletonLoding: false,
-            loading: false
           })
         } else {
           that.setData({
-            bookList: [],
-            pageTotalCount: 0,
             skeletonLoding: false,
-            loading: false
           })
         }
       } catch (error) {
@@ -557,11 +512,14 @@
   //楂樼骇鍒嗙被閫夋嫨
   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);
@@ -573,17 +531,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];
@@ -594,17 +555,15 @@
       });
     }
     this.setData({
+      skeletonLoding: true,
       pathList: pathList,
       'secondList.value': e.detail.value,
     });
-
-  },
-  // 
-  onConfirmSecond() {
     this.getBookList(false);
   },
   onResetSecond() {
     this.setData({
+      pathList: [],
       'secondList.value': [],
     });
     this.getBookList(false);
@@ -829,7 +788,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
@@ -837,6 +796,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: "鎮ㄧ殑鐢靛瓙鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒",
@@ -916,13 +913,13 @@
       this.setData({
         electronicBookList: eList,
       })
-      wx.setStorageSync("electronicBookList", eList);
+      wx.setStorageSync("electronicBookList", JSON.stringify(eList));
     } else {
       pList.push(itemAttr)
       this.setData({
         paperBookList: pList,
       })
-      wx.setStorageSync("paperBookList", pList);
+      wx.setStorageSync("paperBookList", JSON.stringify(pList));
     }
     this.setData({
       num: this.data.num + 1

--
Gitblit v1.9.1