From 4df5e250646fa201c08f38dfb77cfb49e53706fc Mon Sep 17 00:00:00 2001
From: QYF-GitLab1 <1940665526@qq.com>
Date: 星期四, 10 七月 2025 19:15:11 +0800
Subject: [PATCH] ---资源购买处理

---
 packageDomain/pages/resourceDetails/document/index.js |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/packageDomain/pages/resourceDetails/document/index.js b/packageDomain/pages/resourceDetails/document/index.js
index 999ad4c..70a9293 100644
--- a/packageDomain/pages/resourceDetails/document/index.js
+++ b/packageDomain/pages/resourceDetails/document/index.js
@@ -336,7 +336,7 @@
     if (this.data.storeInfo) {
       query.storeInfo = this.data.storeInfo
     }
-    app.MG.store.getProductDetail(query).then((res) => {
+    app.MG.store.getProductDetail(query).then(async (res) => {
       wx.hideLoading();
       const list = res.datas.cmsDatas[0]?.datas
       if (this.data.source == 'qrcode') {
@@ -354,7 +354,7 @@
       this.setData({
         isBuy: res.datas.purchasedSaleMethodIdList.includes(res.datas.defaultSaleMethodId)
       })
-      list?.forEach(async (item) => {
+      for (const item of list) {
         if (this.data.storeInfo == 'jsek_digitalCourses') {
           if (this.data.isBuy) {
             if (this.data.productLinkPath == item.productLinkPath) {
@@ -369,16 +369,17 @@
           const isBuyCms = await app.MG.file.checkCmsItem({
             cmsItemId: Number(item.id)
           })
-          if (isBuyCms && this.data.productLinkPath == item.productLinkPath) {
-            this.data.threeLeveData(item)
+          item.isBuyCms = isBuyCms
+          if (isBuyCms) {
+            this.data.threeLeveData.push(item)
           } else {
-            if (item.freeFile && this.data.productLinkPath == item.productLinkPath) {
-              this.data.threeLeveData(item)
+            if (item.freeFile) {
+              this.data.threeLeveData.push(item)
             } else {
               wx.showModal({
                 icon: 'error',
                 title: '娓╅Θ鎻愮ず',
-                content: '璇疯喘涔伴搴擄紝鍗冲皢杩斿洖璐拱椤�',
+                content: '璇疯喘涔拌祫婧愶紝鍗冲皢杩斿洖璐拱椤�',
                 confirmText: '纭畾',
                 showCancel: false, // 鍏抽棴鍙栨秷鎸夐挳
                 success: (cres) => {
@@ -393,7 +394,7 @@
             }
           }
         }
-      })
+      }
       if (this.data.threeLeveData.length > 0) {
         let item = this.data.threeLeveData[0]
         this.handleTeachData(item)
@@ -485,7 +486,7 @@
     let that = this
     //鍥剧墖
     if (item.selectType == 'picture' || item.learnSelectType == 'picture') {
-      const isBuy = this.cmsItemIsBuy(item)
+      const isBuy = item.isBuyCms
       let file = isBuy ? item.protectedFile || item.file : item.freeFile
       this.setData({
         showData: app.config.requestCtx + '/file/api/ApiDownload?md5=' + file,
@@ -508,7 +509,7 @@
     }
     //鏂囨。绛�
     if (item.selectType == 'document' || item.selectType == 'pdf' || item.learnSelectType == 'document' || item.learnSelectType == 'pdf') {
-      const isBuy = this.cmsItemIsBuy(item)
+      const isBuy = item.isBuyCms
       let md5 = isBuy ? item.protectedFile || item.file || item.freeFile : item.freeFile
       if (item.fileMap[md5]?.extension == 'xlsx' || item.fileMap[md5]?.extension == 'xls') {
         this.setData({

--
Gitblit v1.9.1