From c3c07ebe21562b737cf80cb484df7d9174bf4901 Mon Sep 17 00:00:00 2001
From: QYF-GitLab1 <1940665526@qq.com>
Date: 星期一, 14 七月 2025 10:38:46 +0800
Subject: [PATCH] 云学习-公私有文件处理

---
 packageBookService/pages/bookServices/detail/components/tree/index.js |   84 +++++++++++++++++++++++++++++++++++-------
 1 files changed, 70 insertions(+), 14 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js
index 8a0515a..2717a1e 100644
--- a/packageBookService/pages/bookServices/detail/components/tree/index.js
+++ b/packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -59,6 +59,12 @@
     },
     isCloundHaveSaleMethod: {
       type: Boolean
+    },
+    activeId: {
+      type: String
+    },
+    source: {
+      type: String
     }
   },
   data: {
@@ -71,7 +77,27 @@
     canExecute: true,
     purchaseList: []
   },
-  ready() {},
+  ready() {
+    var query = this.createSelectorQuery()
+    const that = this
+    try {
+      if (this.data.activeId)
+        setTimeout(() => {
+          query.select('.cms-' + this.data.activeId).boundingClientRect(function (res) {
+            if (res && res.top > 0) {
+              var myEventDetail = {
+                top: res.top
+              };
+              var myEventOption = {
+                bubbles: true,
+                composed: true,
+              };
+              that.triggerEvent("handleScrollTop", myEventDetail, myEventOption);
+            }
+          }).exec()
+        }, 500)
+    } catch (err) {}
+  },
   onLoad() {},
   observers: {
     treeList: function (newValue) {
@@ -85,7 +111,6 @@
       const flag = list.findIndex((item) => item.checked == true);
     },
   },
-
   methods: {
     handleList(tree) {
       for (let index = 0; index < tree.length; index++) {
@@ -162,10 +187,41 @@
         return false;
       }
     },
+
+
+    // 鍒ゆ柇褰撳墠鐩爣鏄惁宸茶喘涔�
+    async getCmsDataByQrcode(item) {
+      let query = {
+        path: '*',
+        queryType: '*',
+        productId: this.properties.bookInfo.id,
+        itemId: item.id,
+        itemFields: {
+          // 璧勬簮绫诲瀷锛岃瘯璇绘枃浠讹紝鏄惁鍏佽涓嬭浇绛夊弬鏁�
+          selectType: [],
+          freeFile: [],
+          file: [],
+          protectedFile: [],
+          resourcesClassification: [],
+          isDownload: [],
+          jsek_resourceBrief: [],
+          jsek_link: [],
+          jsek_questionBank: [],
+          learnSelectType: []
+        },
+        pading: {
+          start: 0,
+          size: 999
+        }
+      }
+      const data = await app.MG.store.getProductDetail(query)
+      return data?.datas ?? []
+    },
+
     // 璺宠浆闊宠棰戞挱鏀惧櫒
     goPlayer(e) {
       // 妫�鏌ョ櫥褰曠姸鎬�
-      const goPlayerFun = () => {
+      const goPlayerFun = async () => {
         const item = e.currentTarget.dataset.item;
         const parent = e.currentTarget.dataset.parent;
         const parentProductLinkPath = parent ?
@@ -227,17 +283,21 @@
           let buyList = []
           if (learn.length) buyList = learn.filter((item) => this.properties.buyIds.includes(item.saleMethod.find((citem) => citem.SaleType == 'Normal').Id))
           // 鏈夌埗绾�(鍖呭惈閿�鍞柟寮�)锛屼笖鏈喘涔�
-          if (learn.length && !buyList.length) return wx.showToast({
+          if (learn.length && !buyList.length && !item.freeFile) return wx.showToast({
             icon: 'error',
             title: '璇峰厛璐拱璇ヨ祫婧�',
           })
           if (item.protectedFile || item.freeFile) {
+            const currentSaleMaths = await this.getCmsDataByQrcode(item)
             let file = item.fileMap[item.protectedFile] ? item.fileMap[item.protectedFile] : item.fileMap[item.freeFile]
             if (file && file.protectType !== "Public") {
-              return wx.showToast({
-                icon: 'none',
-                title: "璧勬簮涓嶅彲鐢紝璇疯仈绯荤鐞嗗憳",
-              });
+              const isBuyData = currentSaleMaths.purchasedSaleMethodIdList?.includes(item.saleMethod[0]?.Id)
+              if (!isBuyData) {
+                return wx.showToast({
+                  icon: 'error',
+                  title: '璇峰厛璐拱璇ヨ祫婧�',
+                });
+              }
             }
           }
         }
@@ -256,19 +316,18 @@
         }
         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}`,
+          // url: '/packageDomain/pages/resourceDetails/myVideo/index?formPath=jsek_cloudLearning&parentName=mingxing&cmsId=161796&productLinkPath=161796\\161798\\165396\\162299&activeId=162299&parentProductLinkPath=161798\\165396&source=qrcode&bookName=&bookId=7129'
         });
       }
       const token = wx.getStorageSync(app.config.tokenKey);
       if (!token && this.data.tab != 'jsek_teachingResources') {
         loginInfo(app, (data) => {
-          if (data) goPlayerFun()
+          if (data) {}
         })
       } else {
         goPlayerFun()
       }
-
     },
-
     // 鎷垮埌鎵�鏈夐」
     getAllChildren(id) {
       let result = [];
@@ -313,7 +372,6 @@
       });
       return result;
     },
-
     // 鍙樹负true
     findAndUpdateItemsByIds(tree, ids, state) {
       function findAndUpdate(node) {
@@ -331,7 +389,6 @@
       }
       return tree; // 杩斿洖淇敼鍚庣殑瀹屾暣鏁扮粍
     },
-
     // 鍏ㄩ��
     checkAll() {
       wx.showLoading()
@@ -368,7 +425,6 @@
       this.triggerEvent("changeCheckAll", myEventDetail, myEventOption);
       wx.hideLoading()
     },
-
     // 绔犺妭鍕鹃��
     checkResourceTitle(e) {
       wx.showLoading()

--
Gitblit v1.9.1