From f6088ce5e3086edc3bd669265f07c7624475d0f7 Mon Sep 17 00:00:00 2001
From: QYF-GitLab1 <1940665526@qq.com>
Date: 星期五, 01 八月 2025 14:35:32 +0800
Subject: [PATCH] 优化提示语,填空题渲染,不再加入班级

---
 packageBookService/pages/bookServices/detail/components/tree/index.js |  251 +++++++++++++++++++++++++------------------------
 1 files changed, 128 insertions(+), 123 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js
index cf3f46c..d4979ca 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) {
@@ -83,9 +109,9 @@
         }
       });
       const flag = list.findIndex((item) => item.checked == true);
+      console.log(this.properties.treeList)
     },
   },
-
   methods: {
     handleList(tree) {
       for (let index = 0; index < tree.length; index++) {
@@ -136,140 +162,120 @@
       }; // 瑙﹀彂浜嬩欢鐨勯�夐」
       this.triggerEvent("downloadTeach", myEventDetail, myEventOption);
     },
-    // 鍒ゆ柇璧勬簮鏄惁璐拱
-    resourceIsBuy(data) {
-      if (data.saleMethod && data.saleMethod.length) {
-        const saleData = data.saleMethod.find((item) => item.SaleType == 'Normal')
-        if (saleData.State == 'Disable') return false
-        const isSHow = this.properties.buyIds.some(
-          (item) => item == saleData.Id
-        );
-        // 宸茬粡璐拱
-        if (isShow) return false
-        // 鏈喘涔帮紝鏌ョ湅閿�鍞柟寮忔槸鍚﹁繃鏈�
-        if (!isShow) {
-          const flag = new Date(saleData.EndDate).getTime() >= new Date().getTime() &&
-            new Date(saleData.BeginDate).getTime() <= new Date().getTime()
-          if (flag) {
-            // 涓鸿繃鏈� 锛岄渶瑕佽喘涔�
-            return true
-          } else {
-            // 宸茶繃鏈� 鏃犻渶璐拱
-            return false
-          }
-        }
-      } else {
-        return false;
-      }
-    },
+
     // 璺宠浆闊宠棰戞挱鏀惧櫒
     goPlayer(e) {
       // 妫�鏌ョ櫥褰曠姸鎬�
-      console.log(e.currentTarget.dataset.item)
-      const token = wx.getStorageSync(app.config.tokenKey);
-      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 (item.selectType == "webpage" || item.learnSelectType == "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)
+      // if (this.properties.bookInfo.IsTextbook) return
+      const goPlayerFun = async () => {
+        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 (item.selectType == "webpage" || item.learnSelectType == "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}`
+          })
         }
-        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.file && !item.freeFile && !item.protectedFile) {
-        return wx.showToast({
-          icon: 'error',
-          title: '鏆傛棤璧勬簮',
-        })
-      }
-      if (item.selectType == 'zip' || item.learnSelectType == 'zip') {
-        // if (this.properties.applyState == 'Normal') {
-        return wx.showToast({
-          icon: 'error',
-          title: '璇峰墠寰�PC绔笅杞�',
-        })
-        // } else {
-        //   return wx.showToast({
-        //     icon: 'error',
-        //     title: '璇峰厛鐢宠涓嬭浇',
-        //   })
-        // }
-      }
-      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") {
+        if (!item.file && !item.freeFile && !item.protectedFile) {
           return wx.showToast({
-            icon: "none",
-            title: "璧勬簮涓嶅彲鐢紝璇疯仈绯荤鐞嗗憳",
-          });
+            icon: 'error',
+            title: '鏆傛棤璧勬簮',
+          })
         }
-      }
-      if (this.properties.tab == "jsek_cloudLearning") {
-
-        // 1.鎵惧嚭鎵�鏈夌埗绾х洰褰曞拰鏈韩(鏈夐攢鍞柟寮�) 鍜� 浜戝涔犳湰韬�(鏈夐攢鍞柟寮�) 鏀惧埌涓�涓暟缁�  涓虹┖鍒欐殏鏈紑鏀鹃攢鍞�
-        let learn = []
-        if (this.properties.isCloundHaveSaleMethod) {
-          // 1.1 浜戝涔犳湁閿�鍞柟寮忥紝鍔犲叆鐖剁骇鏁扮粍
-          learn.push(this.properties.learnMenu)
-        } else {
-          // 1.2 浜戝涔犳棤閿�鍞柟寮忥紝灏嗙埗绾х洰褰曞拰鏈韩鍔犲叆鏁扮粍
-          learn = this.handleTreeData(this.properties.learnList).filter(
-            (citem) => citem.saleMethod &&
-            citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal' && ditem.Price > 0) &&
-            new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').EndDate).getTime() >= new Date().getTime() &&
-            new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime() &&
-            item.productLinkPath.includes(citem.productLinkPath)
-          )
+        if (item.selectType == 'zip' || item.learnSelectType == 'zip') {
+          return wx.showToast({
+            icon: 'error',
+            title: '璇峰墠寰�PC绔笅杞�',
+          })
         }
-        // 2.鎵惧嚭杩欎釜鏁扮粍閲屽凡璐拱鐨� 褰㈡垚鏂版暟缁�     涓虹┖鍒欐湭璐拱
-        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({
-          icon: 'error',
-          title: '璇峰厛璐拱璇ヨ祫婧�',
-        })
-        if (item.protectedFile || item.freeFile) {
-          let file = item.fileMap[item.protectedFile] ? item.fileMap[item.protectedFile] : item.fileMap[item.freeFile]
+        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: 'none',
+              icon: "none",
               title: "璧勬簮涓嶅彲鐢紝璇疯仈绯荤鐞嗗憳",
             });
           }
         }
-
+        if (this.properties.tab == "jsek_cloudLearning") {
+          // // 1.鎵惧嚭鎵�鏈夌埗绾х洰褰曞拰鏈韩(鏈夐攢鍞柟寮�) 鍜� 浜戝涔犳湰韬�(鏈夐攢鍞柟寮�) 鏀惧埌涓�涓暟缁�  涓虹┖鍒欐殏鏈紑鏀鹃攢鍞�
+          // let learn = []
+          // if (this.properties.isCloundHaveSaleMethod) {
+          //   // 1.1 浜戝涔犳湁閿�鍞柟寮忥紝鍔犲叆鐖剁骇鏁扮粍
+          //   learn.push(this.properties.learnMenu)
+          // } else {
+          //   // 1.2 浜戝涔犳棤閿�鍞柟寮忥紝灏嗙埗绾х洰褰曞拰鏈韩鍔犲叆鏁扮粍
+          //   learn = this.handleTreeData(this.properties.learnList).filter(
+          //     (citem) => citem.saleMethod &&
+          //     citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal' && ditem.Price > 0) &&
+          //     new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').EndDate).getTime() >= new Date().getTime() &&
+          //     new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime() &&
+          //     item.productLinkPath.includes(citem.productLinkPath)
+          //   )
+          // }
+          // // 2.鎵惧嚭杩欎釜鏁扮粍閲屽凡璐拱鐨� 褰㈡垚鏂版暟缁�     涓虹┖鍒欐湭璐拱
+          // let buyList = []
+          // if (learn.length) buyList = learn.filter((item) => this.properties.buyIds.includes(item.saleMethod.find((citem) => citem.SaleType == 'Normal').Id))
+          // // 鏈夌埗绾�(鍖呭惈閿�鍞柟寮�)锛屼笖鏈喘涔�
+          if (!item.isbuy && !item.freeFile) return wx.showToast({
+            icon: 'error',
+            title: '璇峰厛婵�娲绘垨璐拱璧勬簮',
+          })
+          // if (!item.isbuy && item.freeFile) {
+          //   let file = item.fileMap[item.freeFile]
+          //   if (file && file.protectType !== "Public") {
+          //     if (!item.isbuy) {
+          //       return wx.showToast({
+          //         icon: 'error',
+          //         title: '璇峰厛璐拱璇ヨ祫婧�',
+          //       });
+          //     }
+          //   }
+          // }
+        }
+        let url;
+        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" || item.selectType == 'document' || item.selectType == 'pdf' || item.learnSelectType == "picture" || item.learnSelectType == 'document' || item.learnSelectType == 'pdf') {
+          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}`,
+          // url: '/packageDomain/pages/resourceDetails/myVideo/index?formPath=jsek_cloudLearning&parentName=YDHYD&cmsId=161974&productLinkPath=161974\\161976\\162006&activeId=162006&parentProductLinkPath=161976&source=qrcode&bookName=fffff&bookId=7136'
+        });
       }
-      let url;
-      if (item.selectType == "video" || item.learnSelectType == "video") {
-        url = "/packageDomain/pages/resourceDetails/myVideo/index";
+      const token = wx.getStorageSync(app.config.tokenKey);
+      if (!token && this.data.tab != 'jsek_teachingResources') {
+        loginInfo(app, (data) => {
+          if (data) {
+            wx.redirectTo({
+              url: '/packageBookService/pages/bookServices/detail/index?id=' + this.data.bookInfo.id + '&name=' + encodeURI(this.data.bookInfo.name),
+            })
+          }
+        })
+      } else {
+        goPlayerFun()
       }
-      if (
-        item.selectType == "audio" ||
-        item.learnSelectType == "audio"
-      ) {
-        url = "/packageDomain/pages/resourceDetails/myAudio/index";
-      }
-      if (item.selectType == "picture" || item.selectType == 'document' || item.selectType == 'pdf' || item.learnSelectType == "picture" || item.learnSelectType == 'document' || item.learnSelectType == 'pdf') {
-        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}`,
-      });
     },
-
     // 鎷垮埌鎵�鏈夐」
     getAllChildren(id) {
       let result = [];
@@ -300,8 +306,10 @@
     // 鎷垮埌褰撳墠椤瑰瓙椤�
     flattenTree(tree) {
       let result = [];
+      let that = this
 
       function flatten(node) {
+
         result.push(node);
         if (node.children && node.children.length > 0) {
           node.children.forEach((child) => {
@@ -314,7 +322,6 @@
       });
       return result;
     },
-
     // 鍙樹负true
     findAndUpdateItemsByIds(tree, ids, state) {
       function findAndUpdate(node) {
@@ -332,7 +339,6 @@
       }
       return tree; // 杩斿洖淇敼鍚庣殑瀹屾暣鏁扮粍
     },
-
     // 鍏ㄩ��
     checkAll() {
       wx.showLoading()
@@ -369,7 +375,6 @@
       this.triggerEvent("changeCheckAll", myEventDetail, myEventOption);
       wx.hideLoading()
     },
-
     // 绔犺妭鍕鹃��
     checkResourceTitle(e) {
       wx.showLoading()

--
Gitblit v1.9.1