From c476915fdcb57387459ce6da1b43a502f4168628 Mon Sep 17 00:00:00 2001
From: yiming <m13691596795@163.com>
Date: 星期一, 29 四月 2024 09:38:54 +0800
Subject: [PATCH] 标题

---
 packageBookService/pages/bookServices/detail/components/tree/index.js |   31 ++++++++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js
index ef5aa5a..08238f8 100644
--- a/packageBookService/pages/bookServices/detail/components/tree/index.js
+++ b/packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -132,7 +132,6 @@
     goPlayer(e) {
       // 妫�鏌ョ櫥褰曠姸鎬�
       const token = wx.getStorageSync(app.config.tokenKey);
-
       if (token) {
         const item = e.currentTarget.dataset.item;
         const parent = e.currentTarget.dataset.parent;
@@ -162,20 +161,42 @@
               "璇峰厛璐拱璇ヨ祫婧�" : "璇峰厛鐐瑰嚮棰嗗彇鏌ョ湅鎸夐挳",
           });
         }
+        if (item.saleMethod.length == 0 && item.sysType == 'CmsItem' && this.properties.tab == "jsek_cloudLearning") {
+          return wx.showToast({
+            icon: 'error',
+            title: '鏆傛湭寮�濮嬮攢鍞紝璇疯仈绯荤鐞嗗憳',
+          })
+        }
+        if (this.properties.tab == "jsek_teachingResources" && item.fileMap) {
+          if (item.file && item.fileMap[item.file].protectType !== "Public") {
+            return wx.showToast({
+              icon: 'error',
+              title: '璧勬簮涓嶅彲鐢紝璇疯仈绯荤鐞嗗憳',
+            })
+          } else if (item.freeFile && item.fileMap[item.freeFile].protectType !== "Public") {
+            return wx.showToast({
+              icon: 'error',
+              title: '璧勬簮涓嶅彲鐢紝璇疯仈绯荤鐞嗗憳',
+            })
+          }
+        }
         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}`,
         });
 
 
         if (item.selectType == "document" || item.selectType == "pdf") {
-          const fileLink =
-            app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.file;
+          // freeFile
+          console.log(item);
+          const fileLink = item.file ?
+            app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.file : app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.freeFile
           console.log(fileLink, "fileLink");
           //鎻愮ず鍔犺浇涓�
           util.showLoading();
           // 鍗曟涓嬭浇鍏佽鐨勬渶澶ф枃浠朵负 200MB
           wx.downloadFile({
             url: fileLink,
+            filePath: wx.env.USER_DATA_PATH + `/${item.name}.${item.selectType}`,
             success: function (res) {
               console.log(res, "wx.downloadFile success res");
               if (res.statusCode != 200) {
@@ -183,8 +204,9 @@
                 return false;
               }
               var Path = res.tempFilePath; //杩斿洖鐨勬枃浠朵复鏃跺湴鍧�锛岀敤浜庡悗闈㈡墦寮�鏈湴棰勮鎵�鐢�
+              let data = res.filePath;
               wx.openDocument({
-                filePath: Path,
+                filePath: data,
                 showMenu: true,
                 success: function (res) {
                   console.log("鎵撳紑鎴愬姛");
@@ -600,7 +622,6 @@
           item.isShopCar = false
           this.triggerEvent("updateCloudLearning")
         }
-
       }
     },
     sadd() {

--
Gitblit v1.9.1