From 2c1a13eae201887fdee0a7e0007b7dccdfb4e1db Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期二, 11 三月 2025 10:28:28 +0800
Subject: [PATCH] 云学习资源扫码判断购买

---
 packageDomain/pages/resourceDetails/document/index.js                 |  264 +++++++++++++++++++++++++-
 packageBookService/pages/bookServices/detail/components/tree/index.js |   10 
 packageDomain/pages/resourceDetails/myVideo/index.js                  |  168 ++++++++++------
 packageDomain/pages/resourceDetails/myAudio/index.js                  |  129 +++++++++---
 4 files changed, 450 insertions(+), 121 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js
index cf3f46c..223f666 100644
--- a/packageBookService/pages/bookServices/detail/components/tree/index.js
+++ b/packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -237,10 +237,10 @@
         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 (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 (file && file.protectType !== "Public") {
@@ -266,7 +266,7 @@
         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: `${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}&source=qrcode`,
       });
     },
 
diff --git a/packageDomain/pages/resourceDetails/document/index.js b/packageDomain/pages/resourceDetails/document/index.js
index ab77867..65a8977 100644
--- a/packageDomain/pages/resourceDetails/document/index.js
+++ b/packageDomain/pages/resourceDetails/document/index.js
@@ -26,6 +26,7 @@
     parentName: '',
     parentProductLinkPath: '',
     productLinkPath: '',
+    isBuy: false,
     showData: '',
     titleName: '',
     selectType: '',
@@ -36,13 +37,23 @@
     pdfDatA: [],
     startTime: "", //杩涘叆椤甸潰褰撳墠鏃堕棿
     pauseTime: 0, //鏆傚仠鏃堕棿
+    formPath: '',
     applyState: '',
     deadline: '',
     lzoomFlag: false, //瀹氫箟 缂╂斁浜嬩欢 鑺傛祦闃�,闃叉涓�娆$缉鏀捐Е鍙戜袱娆$缉鏀句簨浠�
     distance: 0, //璁板綍鎵嬫寚绉诲姩璺濈
     scale: 1, //瀹氫箟鍒濆鍖栫殑椤甸潰缂╂斁澶у皬
     newScale: 1, //璁板綍鏂扮殑椤甸潰缂╂斁澶у皬
-    pdfSrc: ''
+    pdfSrc: '',
+    buyIdList: [],
+    buyList: [],
+    learnClassData: null,
+    isLearnDataBuy: false,
+    bookDetail: null,
+    learnStartTime: 0,
+    learnTimeList: [],
+    learnTimeData: 0,
+    threeLeveData: []
   },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
@@ -66,19 +77,34 @@
       parentProductLinkPath: options.parentProductLinkPath,
       productLinkPath: options.productLinkPath,
       applyState: options.applyState,
-      deadline: options.deadline
+      deadline: options.deadline,
+      formPath: options.formPath,
     })
     const token = wx.getStorageSync(app.config.tokenKey)
     if (!token) {
       loginInfo(app, (data) => {
-        if (data) {
-          this.resourceDetailsData()
-        } else {
-          this.resourceDetailsData()
+        if (options.formPath == 'jsek_cloudLearning') {
+          this.setData({
+            learnStartTime: Date.now(),
+          })
+          this.getLearnTime()
         }
+        this.getBookInfo(this.data.bookId)
+        // if (data) {
+        //   this.resourceDetailsData()
+        // } else {
+        //   this.resourceDetailsData()
+        // }
       })
     } else {
-      this.resourceDetailsData()
+      if (options.formPath == 'jsek_cloudLearning') {
+        this.setData({
+          learnStartTime: Date.now(),
+        })
+        this.getLearnTime()
+      }
+      this.getBookInfo(this.data.bookId)
+      // this.resourceDetailsData()
     }
   },
 
@@ -108,6 +134,10 @@
     if (wx.getStorageSync(app.config.tokenKey)) {
       let duration = this.data.pauseTime - this.data.startTime
       this.count(duration)
+      if (this.data.formPath == 'jsek_cloudLearning') {
+        let cloudDuration = this.data.pauseTime - this.data.learnStartTime
+        this.cloudCount(cloudDuration)
+      }
     }
   },
 
@@ -121,6 +151,10 @@
     if (wx.getStorageSync(app.config.tokenKey)) {
       let duration = this.data.pauseTime - this.data.startTime
       this.count(duration)
+      if (this.data.formPath == 'jsek_cloudLearning') {
+        let cloudDuration = this.data.pauseTime - this.data.learnStartTime
+        this.cloudCount(cloudDuration)
+      }
     }
   },
 
@@ -142,6 +176,47 @@
     }
     app.MG.job.newJobWithApiNewEvent(data).then((res) => {})
   },
+  getLearnTime() {
+    app.MG.identity
+      .getUserKey({
+        domain: 'cloudLearningTime',
+        keys: [this.data.bookId]
+      })
+      .then((res) => {
+        if (res.length > 0) {
+          if (JSON.parse(res[0].value) && JSON.parse(res[0].value).length > 0) {
+            this.setData({
+              learnTimeList: JSON.parse(res[0].value),
+              learnTimeData: JSON.parse(res[0].value)[0].learnTime,
+            })
+          } else {
+            this.setData({
+              learnTimeList: [],
+              learnTimeData: 0
+            })
+          }
+        }
+      })
+  },
+  cloudCount(timeStr) {
+    let time = Number(this.data.learnTimeData) + Number(timeStr)
+    this.setData({
+      learnTimeList: [{
+        learnTime: time
+      }],
+    })
+    app.MG.identity
+      .setUserKey({
+        setKeyRequests: [{
+          domain: 'cloudLearningTime',
+          key: this.data.bookId,
+          value: JSON.stringify(this.data.learnTimeList)
+        }]
+      })
+      .then((res) => {
+        console.log(timeStr, '瀛︿範鏃堕暱')
+      })
+  },
   /**
    * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
    */
@@ -161,6 +236,82 @@
   onShareTimeline() {},
   goBack() {
     wx.navigateBack()
+  },
+
+  // 鑾峰彇鍥句功璇︽儏
+  getBookInfo(id) {
+    const query = {
+      path: "*",
+      queryType: "*",
+      productId: id,
+      favoriteTypes: "FavoriteBookCity",
+      itemFields: {
+        "SysType=": "CmsFolder",
+      },
+      coverSize: {
+        height: 1,
+      },
+      fields: {},
+    };
+    if (this.data.storeInfo) query['storeInfo'] = this.data.storeInfo
+    app.MG.store.getProductDetail(query).then(async (res) => {
+      try {
+        this.setData({
+          bookDetail: res.datas,
+          buyIdList: res.datas.purchasedSaleMethodIdList,
+          learnClassData: res.datas.cmsDatas[0].datas.length > 0 ? res.datas.cmsDatas[0].datas.find(item => item.refCode == "jsek_cloudLearning") : null
+        })
+      } catch (error) {}
+      if (this.data.learnClassData) {
+        this.getResourceDataList(this.data.learnClassData)
+      } else {
+        this.resourceDetailsData()
+      }
+    });
+  },
+  // 鏁欏璧勬簮 浜戝涔� 鑾峰彇
+  getResourceDataList(type) {
+    let query = {
+      path: '*',
+      queryType: '*',
+      productId: this.data.bookDetail.id,
+      cmsPath: type.productLinkPath,
+      cmsType: '*',
+      itemFields: {
+        SysType: 'CmsFolder',
+      },
+      pading: {
+        start: 0,
+        size: 999
+      },
+    }
+    app.MG.store.getProductDetailNoChildren(query).then((res) => {
+      const buyList = res.datas.cmsDatas[0].datas.filter(item => item.saleMethod.length && this.data.buyIdList.includes(item.saleMethod.find(citem => citem.SaleType == 'Normal').Id))
+      if (this.data.learnClassData && this.data.learnClassData.saleMethod.length) {
+        const learnSaleMethod = this.data.learnClassData.saleMethod.find(citem => citem.SaleType == 'Normal')
+        if (this.data.buyIdList.includes(learnSaleMethod.Id)) {
+          buyList.push(this.data.learnClassData)
+        } else {
+          if (new Date().getTime() > new Date(learnSaleMethod.EndDate).getTime() || learnSaleMethod.Price == 0) {
+            this.setData({
+              isLearnDataBuy: true
+            })
+          } else {
+            this.setData({
+              isLearnDataBuy: false
+            })
+          }
+        }
+      } else {
+        this.setData({
+          isLearnDataBuy: true
+        })
+      }
+      this.setData({
+        buyList: buyList
+      })
+      this.resourceDetailsData()
+    })
   },
 
   resourceDetailsData() {
@@ -195,16 +346,100 @@
       query.storeInfo = this.data.storeInfo
     }
     app.MG.store.getProductDetail(query).then((res) => {
+      this.setData({
+        isBuy: res.datas.purchasedSaleMethodIdList.includes(res.datas.defaultSaleMethodId)
+      })
       res.datas.cmsDatas[0].datas.forEach((item) => {
-        if (this.data.productLinkPath == item.productLinkPath) {
-          this.handleTeachData(item)
-          this.setData({
-            titleName: item.name,
-            selectType: item.selectType,
-            learnSelectType: item.learnSelectType
-          })
+        // if (this.data.productLinkPath == item.productLinkPath) {
+        //   this.handleTeachData(item)
+        //   this.setData({
+        //     titleName: item.name,
+        //     selectType: item.selectType,
+        //     learnSelectType: item.learnSelectType
+        //   })
+        // } else {
+        //   return wx.showToast({
+        //     icon: 'none',
+        //     title: '鏆傛棤璧勬簮',
+        //   })
+        // }
+        if (this.data.storeInfo == 'jsek_digitalCourses') {
+          if (this.data.isBuy) {
+            if (this.data.productLinkPath == item.productLinkPath) {
+              this.data.threeLeveData.push(item)
+            }
+          } else {
+            if (this.data.productLinkPath == item.productLinkPath && item.freeFile) {
+              this.data.threeLeveData.push(item)
+            }
+          }
+        } else {
+          // 涔颁簡
+          if (this.data.buyList.length) {
+            if (this.data.buyList.some(citem => item.productLinkPath.includes(citem.productLinkPath))) {
+              if (this.data.productLinkPath == item.productLinkPath) {
+                this.data.threeLeveData.push(item)
+              }
+            }
+          } else {
+            if (!item.saleMethod.length) {
+              // 娌′拱涓旀棤閿�鍞柟寮�
+              if (this.data.productLinkPath == item.productLinkPath) {
+                this.data.threeLeveData.push(item)
+              }
+            } else {
+              // 娌′拱涓旈攢鍞柟寮忚繃鏈�//娌′拱锛岄攢鍞柟寮忎环鏍间负0
+              const itemSaleMethod = item.saleMethod.find(citem => citem.SaleType == 'Normal')
+              if (new Date().getTime() > new Date(itemSaleMethod.EndDate).getTime() || itemSaleMethod.Price == 0) {
+                if (this.data.productLinkPath == item.productLinkPath) {
+                  this.data.threeLeveData.push(item)
+                }
+              }
+              //  娌′拱涓斿彧鏈夎瘯璇昏祫婧�
+              if (!item.file && item.freeFile) {
+                if (this.data.productLinkPath == item.productLinkPath) {
+                  this.data.threeLeveData.push(item)
+                }
+              }
+            }
+          }
         }
       })
+      if (this.data.source == 'qrcode') {
+        let qrData = this.data.threeLeveData.find(ditem => ditem.id == this.data.activeId)
+        if (qrData && this.data.isLearnDataBuy) {
+          if (qrData) {
+            this.setData({
+              threeLeveData: [qrData]
+            })
+          }
+        } else {
+          this.setData({
+            threeLeveData: []
+          })
+        }
+      } else {
+        this.setData({
+          threeLeveData: this.data.threeLeveData
+        })
+      }
+      if (this.data.threeLeveData.length > 0) {
+        let item = this.data.threeLeveData[0]
+        this.handleTeachData(item)
+        this.setData({
+          titleName: item.name,
+          selectType: item.selectType,
+          learnSelectType: item.learnSelectType,
+        })
+      } else {
+        wx.showToast({
+          icon: 'none',
+          title: '璇峰厛杩斿洖璧勬簮鎵�鍦ㄥ浘涔﹁鎯呰喘涔拌棰戣祫婧�',
+        })
+        wx.navigateTo({
+          url: `/packageBookService/pages/bookServices/detail/index?id=${this.data.bookDetail.id}&name=${this.data.bookDetail.name}&tabValue=jsek_cloudLearning`,
+        });
+      }
     })
   },
   //zpi鏂囦欢涓嬭浇
@@ -284,6 +519,7 @@
   },
   //鍒氳繘鏉ョ殑鏃跺�欒皟鐢�
   handleTeachData(item) {
+
     //鍥剧墖
     if (item.selectType == 'picture' || item.learnSelectType == 'picture') {
       let file = item.file ? item.file : item.protectedFile ? item.protectedFile : item.freeFile
diff --git a/packageDomain/pages/resourceDetails/myAudio/index.js b/packageDomain/pages/resourceDetails/myAudio/index.js
index 0fd23bd..1f9723c 100644
--- a/packageDomain/pages/resourceDetails/myAudio/index.js
+++ b/packageDomain/pages/resourceDetails/myAudio/index.js
@@ -57,10 +57,11 @@
     buyIdList: [],
     buyList: [],
     learnClassData: null,
+    isLearnDataBuy: false,
     bookDetail: null,
     learnStartTime: 0,
     learnTimeList: [],
-    learnTimeData: 0
+    learnTimeData: 0,
   },
 
   format(time) {
@@ -279,7 +280,6 @@
     };
     if (this.data.storeInfo) query['storeInfo'] = this.data.storeInfo
     app.MG.store.getProductDetail(query).then(async (res) => {
-      console.log('鍥句功璇︽儏', res);
       this.setData({
         bookDetail: res.datas,
         buyIdList: res.datas.purchasedSaleMethodIdList,
@@ -308,12 +308,24 @@
       const buyList = res.datas.cmsDatas[0].datas.filter(item => item.saleMethod.length && this.data.buyIdList.includes(item.saleMethod.find(citem => citem.SaleType == 'Normal').Id))
       if (this.data.learnClassData && this.data.learnClassData.saleMethod.length) {
         const learnSaleMethod = this.data.learnClassData.saleMethod.find(citem => citem.SaleType == 'Normal')
-        if (this.data.buyIdList.includes(learnSaleMethod.Id)) buyList.push(learnClassData)
+        // if (this.data.buyIdList.includes(learnSaleMethod.Id)) buyList.push(learnClassData)
+        if (this.data.buyIdList.includes(learnSaleMethod.Id)) {
+          buyList.push(this.data.learnClassData)
+        } else {
+          if (new Date().getTime() > new Date(learnSaleMethod.EndDate).getTime() || learnSaleMethod.Price == 0) {
+            this.setData({
+              isLearnDataBuy: true
+            })
+          } else {
+            this.setData({
+              isLearnDataBuy: false
+            })
+          }
+        }
       }
       this.setData({
         buyList
       })
-      console.log('浜戝涔�', buyList);
     })
   },
 
@@ -373,53 +385,93 @@
       let selectedId = -1; // 鍒濆鍖栭�変腑椤圭储寮�
       let showDataUrl = '';
       let titleName = '';
-      console.log(res.datas.cmsDatas[0].datas, 1)
       res.datas.cmsDatas[0].datas.forEach((item, index) => {
-        if (this.data.source == 'qrcode') {
-          if (item.id == this.data.activeId) {
-            this.data.threeLeveData.push(item);
-          }
-        } else {
-          if (item.selectType === "audio" || item.learnSelectType === "audio") {
-            if (this.data.storeInfo == 'jsek_digitalCourses') {
-              if (item.sysType == 'CmsItem') {
-                this.data.threeLeveData.push(item)
-              }
-              if (item.sysType == 'CmsItem' && item.freeFile) {
+        // if (this.data.source == 'qrcode') {
+        //   if (item.id == this.data.activeId) {
+        //     this.data.threeLeveData.push(item);
+        //   }
+        // } else {
+        if (item.selectType === "audio" || item.learnSelectType === "audio") {
+          if (this.data.storeInfo == 'jsek_digitalCourses') {
+            if (item.sysType == 'CmsItem') {
+              this.data.threeLeveData.push(item)
+            }
+            if (item.sysType == 'CmsItem' && item.freeFile) {
+              this.data.threeLeveData.push(item)
+            }
+          } else {
+            if (this.data.buyList.length) {
+              if (this.data.buyList.some(citem => item.productLinkPath.includes(citem.productLinkPath))) {
                 this.data.threeLeveData.push(item)
               }
             } else {
-              if (this.data.buyList.length) {
-                if (this.data.buyList.some(citem => item.productLinkPath.includes(citem.productLinkPath))) this.data.threeLeveData.push(item)
+              // if (!item.saleMethod.length) this.data.threeLeveData.push(item)
+              if (!item.saleMethod.length) {
+                // 娌′拱涓旀棤閿�鍞柟寮�
+                this.data.threeLeveData.push(item)
               } else {
-                if (!item.saleMethod.length) this.data.threeLeveData.push(item)
+                // 娌′拱涓旈攢鍞柟寮忚繃鏈�//娌′拱锛岄攢鍞柟寮忎环鏍间负0
+                const itemSaleMethod = item.saleMethod.find(citem => citem.SaleType == 'Normal')
+                if (new Date().getTime() > new Date(itemSaleMethod.EndDate).getTime() || itemSaleMethod.Price == 0) {
+                  this.data.threeLeveData.push(item)
+                }
+                //  娌′拱涓斿彧鏈夎瘯璇昏祫婧�
+                if (!item.file && item.freeFile) this.data.threeLeveData.push(item)
               }
             }
           }
         }
+        // }
       });
-      selectedId = this.data.threeLeveData.findIndex(items => items.productLinkPath == this.data.productLinkPath)
-      if (selectedId !== -1) {
-        let datas = this.data.threeLeveData[selectedId];
-        if (this.data.formPath == 'jsek_cloudLearning') {
-          let file = datas.protectedFile ? datas.protectedFile : datas.freeFile
-          showDataUrl = app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + file + '&token=' + wx.getStorageSync(app.config.tokenKey);
+      if (this.data.source == 'qrcode') {
+        let qrData = this.data.threeLeveData.find(ditem => ditem.id == this.data.activeId)
+        if (qrData && this.data.isLearnDataBuy) {
+          if (qrData) {
+            this.setData({
+              threeLeveData: [qrData]
+            })
+          }
         } else {
-          showDataUrl = datas.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + datas.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + datas.freeFile
+          this.setData({
+            threeLeveData: []
+          })
         }
-        titleName = datas.name;
+      } else {
+        this.setData({
+          threeLeveData: this.data.threeLeveData
+        })
       }
+      if (this.data.threeLeveData.length > 0) {
+        selectedId = this.data.threeLeveData.findIndex(items => items.productLinkPath == this.data.productLinkPath)
+        if (selectedId !== -1) {
+          let datas = this.data.threeLeveData[selectedId];
+          if (this.data.formPath == 'jsek_cloudLearning') {
+            let file = datas.protectedFile ? datas.protectedFile : datas.freeFile
+            showDataUrl = app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + file + '&token=' + wx.getStorageSync(app.config.tokenKey);
+          } else {
+            showDataUrl = datas.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + datas.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + datas.freeFile
+          }
+          titleName = datas.name;
+        }
 
-      this.setData({
-        threeLeveData: this.data.threeLeveData,
-        selectedId: selectedId,
-        showData: showDataUrl,
-        titleName: titleName,
-        loading: false,
-        hidden: false
-      });
-      console.log(1, this.data);
-      this.pubulicPlayFun();
+        this.setData({
+          threeLeveData: this.data.threeLeveData,
+          selectedId: selectedId,
+          showData: showDataUrl,
+          titleName: titleName,
+          loading: false,
+          hidden: false
+        });
+        this.pubulicPlayFun();
+      } else {
+        wx.showToast({
+          icon: 'none',
+          title: '璇峰厛杩斿洖璧勬簮鎵�鍦ㄥ浘涔﹁鎯呰喘涔拌棰戣祫婧�',
+        })
+        wx.navigateTo({
+          url: `/packageBookService/pages/bookServices/detail/index?id=${this.data.bookDetail.id}&name=${this.data.bookDetail.name}&tabValue=jsek_cloudLearning`,
+        });
+      }
     });
   },
 
@@ -440,7 +492,7 @@
       })
       if (item.selectType == "audio" || item.learnSelectType === "audio") {
         if (this.data.formPath == 'jsek_cloudLearning') {
-          let file = item.protectedFile ? item.protectedFile : item.file
+          let file = item.protectedFile ? item.protectedFile : item.freeFile
           // 杩欓噷澶勭悊浜戝涔犵殑
           this.setData({
             showData: app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + file + '&token=' + wx.getStorageSync(app.config.tokenKey)
@@ -450,7 +502,6 @@
           this.setData({
             showData: item.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.freeFile
           })
-          console.log(2, this.data);
           this.pubulicPlayFun()
         }
       }
diff --git a/packageDomain/pages/resourceDetails/myVideo/index.js b/packageDomain/pages/resourceDetails/myVideo/index.js
index 0dc2e7f..b69445c 100644
--- a/packageDomain/pages/resourceDetails/myVideo/index.js
+++ b/packageDomain/pages/resourceDetails/myVideo/index.js
@@ -55,6 +55,7 @@
     buyIdList: [],
     buyList: [],
     learnClassData: null,
+    isLearnDataBuy: false,
     bookDetail: null,
     learnStartTime: 0,
     learnTimeList: [],
@@ -260,13 +261,28 @@
       const buyList = res.datas.cmsDatas[0].datas.filter(item => item.saleMethod.length && this.data.buyIdList.includes(item.saleMethod.find(citem => citem.SaleType == 'Normal').Id))
       if (this.data.learnClassData && this.data.learnClassData.saleMethod.length) {
         const learnSaleMethod = this.data.learnClassData.saleMethod.find(citem => citem.SaleType == 'Normal')
-        if (this.data.buyIdList.includes(learnSaleMethod.Id)) buyList.push(this.data.learnClassData)
+        if (this.data.buyIdList.includes(learnSaleMethod.Id)) {
+          buyList.push(this.data.learnClassData)
+        } else {
+          if (new Date().getTime() > new Date(learnSaleMethod.EndDate).getTime() || learnSaleMethod.Price == 0) {
+            this.setData({
+              isLearnDataBuy: true
+            })
+          } else {
+            this.setData({
+              isLearnDataBuy: false
+            })
+          }
+        }
+      } else {
+        this.setData({
+          isLearnDataBuy: true
+        })
       }
       this.setData({
         buyList: buyList
       })
       this.resourceDetailsData()
-      console.log('浜戝涔�', this.data.buyList);
     })
   },
   count(timeStr) {
@@ -353,74 +369,100 @@
         isBuy: res.datas.purchasedSaleMethodIdList.includes(res.datas.defaultSaleMethodId)
       })
       res.datas.cmsDatas[0].datas.forEach((item) => {
-        if (this.data.source == 'qrcode') {
-          if (item.id == this.data.activeId) {
-            this.data.threeLeveData.push(item);
-          }
-        } else {
-          if (item.selectType === "video" || item.learnSelectType === "video") {
-            if (this.data.storeInfo == 'jsek_digitalCourses') {
-              // if (item.sysType == 'CmsItem') this.data.threeLeveData.push(item)
-              if (this.data.isBuy) {
-                if (item.sysType == 'CmsItem') {
-                  this.data.threeLeveData.push(item)
-                }
-              } else {
-                if (item.sysType == 'CmsItem' && item.freeFile) {
-                  this.data.threeLeveData.push(item)
-                }
+        // if (this.data.source == 'qrcode') {
+        //   if (item.id == this.data.activeId) {
+        //     this.data.threeLeveData.push(item);
+        //   }
+        // } else {
+        if (item.selectType === "video" || item.learnSelectType === "video") {
+          if (this.data.storeInfo == 'jsek_digitalCourses') {
+            // if (item.sysType == 'CmsItem') this.data.threeLeveData.push(item)
+            if (this.data.isBuy) {
+              if (item.sysType == 'CmsItem') {
+                this.data.threeLeveData.push(item)
               }
             } else {
-              // 涔颁簡
-              if (this.data.buyList.length) {
-                if (this.data.buyList.some(citem => item.productLinkPath.includes(citem.productLinkPath))) {
-                  this.data.threeLeveData.push(item)
-                }
-              } else {
-                if (!item.saleMethod.length) {
-                  // 娌′拱涓旀棤閿�鍞柟寮�
-                  this.data.threeLeveData.push(item)
-                } else {
-                  // 娌′拱涓旈攢鍞柟寮忚繃鏈�//娌′拱锛岄攢鍞柟寮忎环鏍间负0
-                  const itemSaleMethod = item.saleMethod.find(citem => citem.SaleType == 'Normal')
-                  if (new Date().getTime() > new Date(itemSaleMethod.EndDate).getTime() || itemSaleMethod.Price == 0) {
-                    this.data.threeLeveData.push(item)
-                  }
-                  //  娌′拱涓斿彧鏈夎瘯璇昏祫婧�
-                  if (!item.file && item.freeFile) this.data.threeLeveData.push(item)
-                }
+              if (item.sysType == 'CmsItem' && item.freeFile) {
+                this.data.threeLeveData.push(item)
               }
             }
-            this.setData({
-              threeLeveData: this.data.threeLeveData
-            })
-          }
-        }
-      })
-      console.log(1, this.data.threeLeveData);
-      this.data.threeLeveData.forEach((items, index) => { // 淇敼姝ゅ娣诲姞index鍙傛暟
-        if (this.data.productLinkPath == items.productLinkPath) {
-          if (this.data.formPath === "jsek_cloudLearning") {
-            let file
-            items.protectedFile || items.file ? file = items.protectedFile || items.file : file = items.freeFile
-            this.setData({
-              showData: app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + file + '&token=' + wx.getStorageSync(app.config.tokenKey),
-              titleName: items.name
-            })
-            this.aliVod(file, this.data.showData)
           } else {
-            this.setData({
-              showData: items.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + items.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + items.freeFile,
-              titleName: items.name
-            })
-            this.aliVod(items.file, this.data.showData)
+            // 涔颁簡
+            if (this.data.buyList.length) {
+              if (this.data.buyList.some(citem => item.productLinkPath.includes(citem.productLinkPath))) {
+                this.data.threeLeveData.push(item)
+              }
+            } else {
+              if (!item.saleMethod.length) {
+                // 娌′拱涓旀棤閿�鍞柟寮�
+                this.data.threeLeveData.push(item)
+              } else {
+                // 娌′拱涓旈攢鍞柟寮忚繃鏈�//娌′拱锛岄攢鍞柟寮忎环鏍间负0
+                const itemSaleMethod = item.saleMethod.find(citem => citem.SaleType == 'Normal')
+                if (new Date().getTime() > new Date(itemSaleMethod.EndDate).getTime() || itemSaleMethod.Price == 0) {
+                  this.data.threeLeveData.push(item)
+                }
+                //  娌′拱涓斿彧鏈夎瘯璇昏祫婧�
+                if (!item.file && item.freeFile) this.data.threeLeveData.push(item)
+              }
+            }
           }
-          let selectedIndex = index; // 瀛樺偍閫変腑椤圭殑绱㈠紩
-          this.setData({
-            selectedId: selectedIndex // 璁剧疆閫変腑椤圭殑绱㈠紩
-          });
+
         }
-      });
+        // }
+      })
+      if (this.data.source == 'qrcode') {
+        let qrData = this.data.threeLeveData.find(ditem => ditem.id == this.data.activeId)
+        if (qrData && this.data.isLearnDataBuy) {
+          if (qrData) {
+            this.setData({
+              threeLeveData: [qrData]
+            })
+          }
+        } else {
+          this.setData({
+            threeLeveData: []
+          })
+        }
+      } else {
+        this.setData({
+          threeLeveData: this.data.threeLeveData
+        })
+      }
+      if (this.data.threeLeveData.length > 0) {
+        this.data.threeLeveData.forEach((items, index) => { // 淇敼姝ゅ娣诲姞index鍙傛暟
+          if (this.data.productLinkPath == items.productLinkPath) {
+            if (this.data.formPath === "jsek_cloudLearning") {
+              let file
+              items.protectedFile || items.file ? file = items.protectedFile || items.file : file = items.freeFile
+              this.setData({
+                showData: app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' + file + '&token=' + wx.getStorageSync(app.config.tokenKey),
+                titleName: items.name
+              })
+              this.aliVod(file, this.data.showData)
+            } else {
+              this.setData({
+                showData: items.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + items.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + items.freeFile,
+                titleName: items.name
+              })
+              this.aliVod(items.file, this.data.showData)
+            }
+            let selectedIndex = index; // 瀛樺偍閫変腑椤圭殑绱㈠紩
+            this.setData({
+              selectedId: selectedIndex // 璁剧疆閫変腑椤圭殑绱㈠紩
+            });
+          }
+        });
+      } else {
+        wx.showToast({
+          icon: 'none',
+          title: '璇峰厛杩斿洖璧勬簮鎵�鍦ㄥ浘涔﹁鎯呰喘涔拌棰戣祫婧�',
+        })
+        wx.navigateTo({
+          url: `/packageBookService/pages/bookServices/detail/index?id=${this.data.bookDetail.id}&name=${this.data.bookDetail.name}&tabValue=jsek_cloudLearning`,
+        });
+
+      }
       this.setData({
         loading: false,
         hidden: false,

--
Gitblit v1.9.1