From 338ad19ee45b5380a0d8433cbbce2a727a576dfa Mon Sep 17 00:00:00 2001
From: yiming <m13691596795@163.com>
Date: 星期五, 19 四月 2024 17:34:36 +0800
Subject: [PATCH] bug2

---
 packageBookService/pages/bookServices/detail/buyResource/index.js |   46 +++++++++++++++++++++++++++++++++++++---------
 1 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/buyResource/index.js b/packageBookService/pages/bookServices/detail/buyResource/index.js
index 34db152..8c61ce1 100644
--- a/packageBookService/pages/bookServices/detail/buyResource/index.js
+++ b/packageBookService/pages/bookServices/detail/buyResource/index.js
@@ -10,19 +10,23 @@
     learn: [],
     openLearnids: [],
     bookId: "",
-    loading: false,
+    loading: true,
     shoppingList: [],
     shoppingCartGetId: [],
     methodId: [],
     paymentPage: false,
     superior: false,
     checkAllState: true,
+    productLinkPath: '',
+    refCode: '',
+    haider: false
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad(options) {
+    this.getBookInfo(options.bookId);
     const systInfo = wx.getSystemInfoSync();
     const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅
     const navBarHeight =
@@ -31,14 +35,11 @@
       barHeight: systInfo.statusBarHeight,
       navBarHeight: navBarHeight,
       bookId: options.bookId,
+      productLinkPath: options.productLinkPath,
+      refCode: options.refCode
     });
     this.getResourceClass();
-    this.getResourceData({
-      productLinkPath: options.productLinkPath,
-      refCode: options.refCode,
-    });
     this.getShoppingCartProductGet();
-    this.getBookInfo(options.bookId);
   },
 
   /**
@@ -118,6 +119,7 @@
           return this.setData({
             noResources: true,
             loading: false,
+            haider: true
           });
         }
         //鏁欏璧勬簮 浜戝涔�
@@ -134,6 +136,7 @@
               this.setData({
                 teach: list,
                 loading: false,
+                haider: true
               });
               this.findChildIds(this.data.teach, (this.data.openTeachids = []));
             } else if (type.refCode == "jsek_cloudLearning") {
@@ -146,8 +149,10 @@
                 learn: list,
                 loading: false,
                 openLearnids: result,
+                haider: true
               });
             }
+            console.log(list, '浜戝缈�');
           } else {
             // 鏃犳暟鎹�
           }
@@ -156,6 +161,7 @@
           this.setData({
             test: res.datas.cmsDatas[0].datas,
             loading: false,
+            haider: true
           });
         } else {
           console.log("鍏朵粬");
@@ -197,6 +203,7 @@
         jsek_resourceBrief: [],
         jsek_link: [],
         accessType: [],
+        learnSelectType: [],
       },
       pading: {
         start: 0,
@@ -226,12 +233,12 @@
     });
     data.datas.cmsDatas[0].datas.forEach((item) => {
       item.checked = false;
-      item.isbuy = this.resourceIsBuy(item);
+      item.isbuy = this.isShowNeedBuy(item);
       item.isShopCar = this.isShoppingCart(item);
     });
     return data.datas.cmsDatas[0].datas;
   },
-  getBookInfo(id) {
+  async getBookInfo(id) {
     this.setData({
       "mockData'.id": 0,
       "mockData.price": 0,
@@ -269,12 +276,17 @@
         freeEpubPage: [], //epub璇曡鐧惧垎姣�
       },
     };
-    app.MG.store.getProductDetail(query).then(async (res) => {
+    await app.MG.store.getProductDetail(query).then(async (res) => {
       this.setData({
         bookDetail: res.datas,
         buyIdList: res.datas.purchasedSaleMethodIdList,
       });
+      this.getResourceData({
+        productLinkPath: this.data.productLinkPath,
+        refCode: this.data.refCode,
+      });
     });
+
   },
   // 鑾峰彇宸茶喘涔板晢鍝�
   getShoppingCartProductGet() {
@@ -306,6 +318,22 @@
       return false;
     }
   },
+
+  isShowNeedBuy(data) {
+    if (data.saleMethod && data.saleMethod.length) {
+      const isSHow = this.data.buyIdList.some(
+        (item) => item == data.saleMethod[0].Id
+      );
+      if (isSHow) {
+        return false;
+      } else {
+        return data.saleMethod[0].price > 0 ? true : false;
+      }
+      return !isSHow;
+    } else {
+      return false;
+    }
+  },
   // 鍒ゆ柇璧勬簮鍔犲叆璐墿杞︽寜閽槸鍚︽樉绀�
   isShoppingCart(data) {
     if (data.saleMethod && data.saleMethod.length) {

--
Gitblit v1.9.1