From 253245731d2b0c5ea4994a9c4e17ad6b60136f2c Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期二, 09 四月 2024 15:38:26 +0800
Subject: [PATCH] 答题器提交功能优化

---
 packageDomain/pages/sampleBookList/index.js |  158 ++++++++++++++++++++++------------------------------
 1 files changed, 67 insertions(+), 91 deletions(-)

diff --git a/packageDomain/pages/sampleBookList/index.js b/packageDomain/pages/sampleBookList/index.js
index eb4db74..6861e0e 100644
--- a/packageDomain/pages/sampleBookList/index.js
+++ b/packageDomain/pages/sampleBookList/index.js
@@ -50,6 +50,30 @@
     stairCode: '', // 涓�绾у垎绫婚�変腑椤�
     secondCode: '', // 浜岀骇鍒嗙被閫変腑椤�
     sort: '', // 鎺掑簭
+    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: "鍑虹増鏃堕棿鍊掑彊",
+        },
+      ],
+    },
     //鍒嗛〉
     page: 1,
     limit: 10,
@@ -170,7 +194,6 @@
     // 鑾峰彇鐢宠娆℃暟
     this.getSelectPaperBookCount()
     this.getSelectBookCount()
-    console.log(this.data.electronicBookList.length, this.data.paperBookList.length, 1)
     if (wx.getStorageSync("paperBookList") || wx.getStorageSync("electronicBookList")) {
       if (wx.getStorageSync("paperBookList")) {
         this.setData({
@@ -287,7 +310,6 @@
         'stairList.options': options,
         'stairList.value': this.data.stairCode,
       });
-      console.log(this.data.stairList.options)
     });
   },
   // 鑾峰彇涓�绾у垎绫讳笅浜岀骇鍒嗙被
@@ -384,17 +406,43 @@
         queryType: '*',
       };
     }
-    if (that.data.sort) {
+    if (this.data.sortList.value == "name-asc") {
       sort = {
-        Name: that.data.sort,
-        BaseType: '',
+        Name: "Asc",
+        BaseType: "",
       };
-    } else {
+    } 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") {
+      sort = {
+        PublicationDate: "Desc",
+        BaseType: "DateTime",
+      };
+    } else if (this.data.sortList.value == "default") {
+      sort = {
+        field: "order",
+        type: "Desc",
       };
     }
+    // if (that.data.sort) {
+    //   sort = {
+    //     Name: that.data.sort,
+    //     BaseType: '',
+    //   };
+    // } else {
+    //   sort = {
+    //     type: 'Desc',
+    //     field: 'ViewCount',
+    //   };
+    // }
     // 鎼滅储
     let searchObj = {};
     if (that.data.searchValue) {
@@ -420,8 +468,6 @@
         author: [],
         isbn: [],
         publicationDate: [],
-        pdf: [],
-        protectedEpub: [],
         isApplyBook: [],
         'isApplyBook>': ['1'],
         ...searchObj,
@@ -499,7 +545,6 @@
           that.setData({
             bookList: [],
             pageTotalCount: 0,
-            bottomLoading: false,
             skeletonLoding: false,
             loading: false
           })
@@ -558,60 +603,32 @@
   onConfirmSecond() {
     this.getBookList(false);
   },
-  // 閲嶇偣椤圭洰鏀瑰彉
-  changeMajorProject(e) {
+  onResetSecond() {
     this.setData({
-      'majorProjectList.value': e.detail.value,
+      'secondList.value': [],
     });
     this.getBookList(false);
   },
-  // 閲嶇偣椤圭洰閲嶇疆
-  resetMajorProject() {
+
+  // 鎺掑簭鍒囨崲
+  onSortChange(e) {
     this.setData({
-      'majorProjectList.value': [],
+      backTop: "#assort-title",
+      "sortList.value": e.detail.value,
     });
-    this.getBookList(false);
-  },
-  changeNewText(e) {
-    this.setData({
-      'newTextBook.value': e.detail.value,
-    });
-    this.getBookList(false);
-  },
-  resetNewText() {
-    this.setData({
-      'newTextBook.value': [],
-    });
-    this.getBookList(false);
-  },
-  // 鎺掑簭鎸夐挳
-  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}`;
+      path = `${this.data.assortCheck.code}\\${this.data.stairCode}`;
     } else {
       path = this.data.assortCheck.code;
     }
     this.setData({
       path: path,
     });
-    this.getBookList(false);
+    this.getBookList(path);
   },
   // 鎼滅储鍥句功
   searchBook(e) {
@@ -812,55 +829,14 @@
   },
 
   //閫夋嫨鐢靛瓙鏍蜂功
-  async onChangeElectron(e) {
+  onChangeElectron(e) {
     const item = e.currentTarget.dataset.book;
-    console.log(item)
     const index = this.data.bookList.findIndex(citem => citem.id == item.id)
     let role = this.data.userInfo != null ? this.data.userInfo.role : null
     if (role && role == 'Teacher') {
       // 鏄暀甯�
       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: "鎮ㄧ殑鐢靛瓙鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒",

--
Gitblit v1.9.1