From 51ad1f2614bc1f976aad98254649bb3c207332ee Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期三, 11 九月 2024 16:50:35 +0800
Subject: [PATCH] 转换树结构方法优化

---
 packageBookService/pages/bookServices/detail/components/tree/index.js |  154 ++++++++++++++++++++++++--------------------------
 1 files changed, 74 insertions(+), 80 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js
index fd3b476..4194ed3 100644
--- a/packageBookService/pages/bookServices/detail/components/tree/index.js
+++ b/packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -137,88 +137,82 @@
     goPlayer(e) {
       // 妫�鏌ョ櫥褰曠姸鎬�
       const token = wx.getStorageSync(app.config.tokenKey);
-      if (token) {
-        const item = e.currentTarget.dataset.item;
-        const parent = e.currentTarget.dataset.parent;
-        const parentProductLinkPath = parent ?
-          parent.productLinkPath :
-          wx.getStorageSync("teachResourcesPath");
-        const parentName = parent ? parent.name : "鏁欏璧勬簮";
-        if (this.properties.isShowCheck && this.resourceIsBuy(item)) {
-          return false;
-        }
-
-        if (
-          this.properties.tab == "jsek_cloudLearning" &&
-          this.resourceIsBuy(item)
-        ) {
-          return wx.showToast({
-            icon: "error",
-            title: item.saleMethod[0].Price > 0 ?
-              "璇峰厛璐拱璇ヨ祫婧�" : "璇峰厛鐐瑰嚮棰嗗彇鏌ョ湅鎸夐挳",
-          });
-        }
-
-
-        if (this.properties.tab == "jsek_teachingResources" && (item.file || item.freeFile)) {
-          let file = item.fileMap[item.file] ? item.fileMap[item.file] : item.fileMap[item.freeFile]
-          if (file && file.protectType !== "Public") {
-            return wx.showToast({
-              icon: "error",
-              title: "璧勬簮涓嶅彲鐢紝璇疯仈绯荤鐞嗗憳",
-            });
-          }
-        } else if ((this.properties.tab == "jsek_teachingResources" || this.properties.tab == "jsek_cloudLearning") && (!item.file && !item.freeFile && !item.protectedFile)) {
-          return wx.showToast({
-            icon: 'error',
-            title: '鏆傛棤璧勬簮',
-          })
-        }
-
-        if (item.selectType == 'zip') {
-          if (this.properties.applyState == 'Normal') {
-            return wx.showToast({
-              icon: 'error',
-              title: '璇峰墠寰�PC绔笅杞�',
-            })
-          } else {
-            return wx.showToast({
-              icon: 'error',
-              title: '璇峰厛鐢宠涓嬭浇',
-            })
-          }
-        }
-
-        let url;
-        if (item.selectType == "webpage") {
-          // 缃戦〉绫诲瀷璺宠浆鍒扮綉鍧�澶嶅埗椤碉紝鍥犱负url浼犲弬涓嶈兘浼� 甯﹀弬鏁扮殑缃戠粶鍦板潃锛屾墍浠ユ澶勮鎶婄綉缁滃湴鍧�閲岀殑浼犲弬鎽樺嚭鏉ワ紝鏀惧埌url閲�
-          let urlData = ''
-          const flags = item.jsek_link.indexOf("?")
-          if (flags > -1) {
-            urlData = item.jsek_link.slice(flags + 1, item.jsek_link.length)
-          }
-          url = '/packageBookService/pages/bookServices/linkPage/index'
-          return wx.navigateTo({
-            url: urlData ? url + `?path=${item.jsek_link.slice(0,flags)}` + '&' + urlData : url + `?path=${item.jsek_link}`
-          })
-        }
-
-        if (item.selectType == "video" || item.learnSelectType == "video") {
-          url = "/packageDomain/pages/resourceDetails/myVideo/index";
-        }
-        if (
-          item.selectType == "audio" ||
-          item.learnSelectType == "audio"
-        ) {
-          url = "/packageDomain/pages/resourceDetails/myAudio/index";
-        }
-        if (item.selectType == "picture") {
-          url = "/packageDomain/pages/resourceDetails/document/index";
-        }
-        wx.navigateTo({
-          url: `${url}?productLinkPath=${item.productLinkPath}&parentProductLinkPath=${parentProductLinkPath}&parentName=${parentName}&activeId=${item.id}&bookId=${this.properties.bookInfo.id}&bookName=${this.properties.bookInfo.name}&cmsId=${this.properties.bookInfo.rootCmsItemId}&formPath=${this.properties.tab}&applyState=${this.properties.applyState}&deadline=${this.properties.deadline}`,
+      if (!token) return false
+      const item = e.currentTarget.dataset.item;
+      const parent = e.currentTarget.dataset.parent;
+      const parentProductLinkPath = parent ?
+        parent.productLinkPath :
+        wx.getStorageSync("teachResourcesPath");
+      const parentName = parent ? parent.name : "鏁欏璧勬簮";
+      // 璧勬簮璐拱椤甸潰(鍙睍绀烘湭璐拱璧勬簮) 鐐瑰嚮涓嶈烦杞�
+      if (this.properties.isShowCheck) return false;
+      if (
+        this.properties.tab == "jsek_cloudLearning" &&
+        this.resourceIsBuy(item)
+      ) {
+        return wx.showToast({
+          icon: "error",
+          title: item.saleMethod[0].Price > 0 ?
+            "璇峰厛璐拱璇ヨ祫婧�" : "璇峰厛鐐瑰嚮棰嗗彇鏌ョ湅鎸夐挳",
         });
       }
+      if (this.properties.tab == "jsek_teachingResources" && (item.file || item.freeFile)) {
+        let file = item.fileMap[item.file] ? item.fileMap[item.file] : item.fileMap[item.freeFile]
+        if (file && file.protectType !== "Public") {
+          return wx.showToast({
+            icon: "error",
+            title: "璧勬簮涓嶅彲鐢紝璇疯仈绯荤鐞嗗憳",
+          });
+        }
+      }
+      if (!item.file && !item.freeFile && !item.protectedFile) {
+        return wx.showToast({
+          icon: 'error',
+          title: '鏆傛棤璧勬簮',
+        })
+      }
+      if (item.selectType == 'zip') {
+        if (this.properties.applyState == 'Normal') {
+          return wx.showToast({
+            icon: 'error',
+            title: '璇峰墠寰�PC绔笅杞�',
+          })
+        } else {
+          return wx.showToast({
+            icon: 'error',
+            title: '璇峰厛鐢宠涓嬭浇',
+          })
+        }
+      }
+      let url;
+      if (item.selectType == "webpage") {
+        // 缃戦〉绫诲瀷璺宠浆鍒扮綉鍧�澶嶅埗椤碉紝鍥犱负url浼犲弬涓嶈兘浼� 甯﹀弬鏁扮殑缃戠粶鍦板潃锛屾墍浠ユ澶勮鎶婄綉缁滃湴鍧�閲岀殑浼犲弬鎽樺嚭鏉ワ紝鏀惧埌url閲�
+        let urlData = ''
+        const flags = item.jsek_link.indexOf("?")
+        if (flags > -1) {
+          urlData = item.jsek_link.slice(flags + 1, item.jsek_link.length)
+        }
+        url = '/packageBookService/pages/bookServices/linkPage/index'
+        return wx.navigateTo({
+          url: urlData ? url + `?path=${item.jsek_link.slice(0,flags)}` + '&' + urlData : url + `?path=${item.jsek_link}`
+        })
+      }
+
+      if (item.selectType == "video" || item.learnSelectType == "video") {
+        url = "/packageDomain/pages/resourceDetails/myVideo/index";
+      }
+      if (
+        item.selectType == "audio" ||
+        item.learnSelectType == "audio"
+      ) {
+        url = "/packageDomain/pages/resourceDetails/myAudio/index";
+      }
+      if (item.selectType == "picture") {
+        url = "/packageDomain/pages/resourceDetails/document/index";
+      }
+      wx.navigateTo({
+        url: `${url}?productLinkPath=${item.productLinkPath}&parentProductLinkPath=${parentProductLinkPath}&parentName=${parentName}&activeId=${item.id}&bookId=${this.properties.bookInfo.id}&bookName=${this.properties.bookInfo.name}&cmsId=${this.properties.bookInfo.rootCmsItemId}&formPath=${this.properties.tab}&applyState=${this.properties.applyState}&deadline=${this.properties.deadline}`,
+      });
     },
 
     // 鎷垮埌鎵�鏈夐」

--
Gitblit v1.9.1