From 90f83bf13fd0d6b97897deadc4a9e6a204b530aa Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期二, 26 三月 2024 10:50:11 +0800
Subject: [PATCH] 图书详情页、答题器bug修改

---
 packageBookService/pages/bookServices/detail/index.js |   57 +++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js
index bc9ec6c..59b00c4 100644
--- a/packageBookService/pages/bookServices/detail/index.js
+++ b/packageBookService/pages/bookServices/detail/index.js
@@ -53,7 +53,6 @@
       mockList: [] // 鐢ㄦ埛缁勫嵎鎻愪氦淇℃伅
     },
     flag: true,
-    applyResourceLoading: false,
     noResources: false,
     selectedIds: "",//鍟嗗搧鎴栧瓙鍟嗗搧閿�鍞柟寮�
     bookBuy: false, //鍟嗗搧鎴栧瓙鍟嗗搧鏄惁璐拱
@@ -180,7 +179,7 @@
   // 鏍煎紡鍖栨棩鏈�
   formatDate(dateString) {
     if (!dateString) {
-      return 'Invalid date';
+      return '';
     }
     const match = dateString.match(/^(\d{4})\/(\d{1,2})\/(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/);
     if (!match) {
@@ -281,9 +280,12 @@
       });
       this.getSubTtem();
       // 鑾峰彇鍥句功鍒嗙被
-      const iconType = JSON.parse(res.datas.bookClassification)[0][0];
-      const classType = JSON.parse(res.datas.bookClassification)[0][1];
-      const className = await this.getBookClass(iconType, classType)
+      let className = ''
+      if (Array.isArray(res.datas.bookClassification) && res.datas.bookClassification.length) {
+        const iconType = JSON.parse(res.datas.bookClassification)[0][0];
+        const classType = JSON.parse(res.datas.bookClassification)[0][1];
+        className = await this.getBookClass(iconType, classType)
+      }
       // 鑾峰彇缁勫嵎閿�鍞甶d
       if (res.datas.saleMethod && res.datas.saleMethod.length) {
         res.datas.saleMethod.forEach((item) => {
@@ -589,22 +591,26 @@
               item.checked = false
             })
             const list = await this.getAllResource(res.datas.cmsDatas[0].datas)
+            let result = []
             if (type.refCode == 'jsek_teachingResources') {
+              this.findChildIds(list, result)
               this.setData({
                 teach: list,
-                loading: false
+                loading: false,
+                openTeachids: result
               })
-              this.findChildIds(this.data.teach, this.data.openTeachids = [])
+              console.log('鏁欏璧勬簮', this.data.teach);
             } else if (type.refCode == 'jsek_cloudLearning') {
-              res.datas.cmsDatas[0].datas.forEach(item => {
-                item.checked = false
-              })
-              const list = await this.getAllResource(res.datas.cmsDatas[0].datas)
+              // res.datas.cmsDatas[0].datas.forEach(item => {
+              //   item.checked = false
+              // })
+              // const list = await this.getAllResource(res.datas.cmsDatas[0].datas)
+              this.findChildIds(list, result)
               this.setData({
                 learn: list,
-                loading: false
+                loading: false,
+                openLearnids: result
               })
-              this.findChildIds(this.data.learn, this.data.openLearnids = [])
             }
           } else {
             // 鏃犳暟鎹�
@@ -654,7 +660,8 @@
         isDownload: [],
         jsek_resourceBrief: [],
         jsek_link: [],
-        accessType: []
+        accessType: [],
+        learnSelectType: []
       },
       pading: {
         start: 0,
@@ -900,14 +907,12 @@
         })
       }
     })
-    this.setData({
-      applyResourceLoading: false
-    })
+    wx.hideLoading()
   },
   // 鐢宠鏁欏璧勬簮
   applyResource() {
-    this.setData({
-      applyResourceLoading: true
+    wx.showLoading({
+      title: '鍔犺浇涓�',
     })
     // let role = userStore.userInfo ? userStore.userInfo.role : null
     // if (role) {
@@ -1301,7 +1306,6 @@
         keys: [this.data.bookId]
       })
       .then((res) => {
-        console.log(JSON.parse(res[0].value));
         if (res && res.length) {
           const mock = JSON.parse(res[0].value)
           mock.forEach(item => {
@@ -1426,6 +1430,7 @@
   appplyElectronicBook() {
     console.log(this.data.bookDetail)
     if (this.data.bookDetail.isApplyBook == 2 || this.data.bookDetail.isApplyBook == 4) {
+
       let role = this.data.userInfo != null ? this.data.userInfo.role : null
       if (role) {
         if (role == 'Teacher') {
@@ -1453,6 +1458,12 @@
           })
         }
       }
+    } else {
+      wx.showToast({
+        title: "璇ヤ功涓嶈兘鐢宠鐢靛瓙鏍蜂功",
+        icon: 'none',
+        duration: 1000,
+      })
     }
   },
   //鐢宠绾歌川鏍蜂功
@@ -1477,6 +1488,12 @@
           })
         }
       }
+    } else {
+      wx.showToast({
+        title: "璇ヤ功涓嶈兘鐢宠绾歌川鏍蜂功",
+        icon: 'none',
+        duration: 1000,
+      })
     }
   },
   //鑾峰彇褰撳墠宸茬敵璇锋鏁帮紙绾歌川锛�

--
Gitblit v1.9.1