From 960c49a8b3ac11dff27cad71137f986f90f00923 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期五, 26 四月 2024 19:16:32 +0800
Subject: [PATCH] 样书申请、详情页资源显示bug修改

---
 packageBookService/pages/bookServices/detail/index.js |   76 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 74 insertions(+), 2 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js
index f4d5cd8..110d42b 100644
--- a/packageBookService/pages/bookServices/detail/index.js
+++ b/packageBookService/pages/bookServices/detail/index.js
@@ -726,6 +726,44 @@
     });
   },
 
+  // 鑾峰彇鎵�鏈夊瓙椤规暟閲�
+  getChildrenItem(data) {
+    let num = 0
+
+    function getNum(data) {
+      for (let index = 0; index < data.length; index++) {
+        const item = data[index];
+        if (item.sysType == 'CmsItem') {
+          num += 1
+        } else if (item.sysType == 'CmsFolder') {
+          if (item.children && item.children.length)
+            getNum(item.children)
+        }
+      }
+    }
+    getNum(data)
+    return num
+  },
+
+  // 缁櫬风洰褰曟坊鍔犲瓙椤规暟閲�
+  changeResourceChildren(list) {
+    const changeList = (list) => {
+      for (let index = 0; index < list.length; index++) {
+        const item = list[index];
+        if (item.sysType == 'CmsFolder' && item.children && item.children.length) {
+          item.childrenItem = this.getChildrenItem([item])
+          changeList(item.children)
+        } else if (item.sysType == 'CmsFolder' && item.children && !item.children.length) {
+          item.childrenItem = 0
+        } else if (item.sysType == 'CmsFolder' && !item.children) {
+          item.childrenItem = 0
+        }
+      }
+    }
+    changeList(list)
+    return list
+  },
+
   // 鎵佸钩鍖栨暟鎹浆鎹ree
   getTreeList(rootList, pathLength, newArr, path) {
     for (const item of rootList) {
@@ -861,6 +899,7 @@
         });
         this.getTreeList(res.datas.cmsDatas[0].datas, 17, list, '\\')
         list = this.ensureTreeConsistency(list)
+        list = this.changeResourceChildren(list)
         console.log('淇敼鍚庝簯', list);
         let result = [];
         if (type.refCode == "jsek_teachingResources") {
@@ -2083,6 +2122,23 @@
 
   //鐢宠鐢靛瓙鏍蜂功
   appplyElectronicBook() {
+    // 鍏堝垽鏂笅鏁欏笀璁よ瘉锛屾湭瀵瑰師鏈夐�昏緫淇敼
+    let role = this.data.userInfo != null ? this.data.userInfo.role : null;
+    if (role && role == "Teacher") {} else {
+      return wx.showModal({
+        title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰�
+        content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹�
+        confirmColor: "#ff6c00",
+        cancelColor: "#949494",
+        success: function (res) {
+          if (res.confirm) {
+            wx.navigateTo({
+              url: "/packageDomain/pages/teacherCertification/index",
+            });
+          } else if (res.cancel) {}
+        },
+      });
+    }
     if (
       this.data.bookDetail.isApplyBook == 2 ||
       this.data.bookDetail.isApplyBook == 4
@@ -2162,6 +2218,22 @@
   },
   //鐢宠绾歌川鏍蜂功
   appplyPaperBook() {
+    let role = this.data.userInfo != null ? this.data.userInfo.role : null;
+    if (role && role == "Teacher") {} else {
+      return wx.showModal({
+        title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰�
+        content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹�
+        confirmColor: "#ff6c00",
+        cancelColor: "#949494",
+        success: function (res) {
+          if (res.confirm) {
+            wx.navigateTo({
+              url: "/packageDomain/pages/teacherCertification/index",
+            });
+          } else if (res.cancel) {}
+        },
+      });
+    }
     if (
       this.data.bookDetail.isApplyBook == 3 ||
       this.data.bookDetail.isApplyBook == 4
@@ -2254,13 +2326,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