From f770361fd6ac7476043188be37cf9efb17fe8a0e Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期三, 27 三月 2024 16:35:36 +0800
Subject: [PATCH] css

---
 packageBookService/pages/bookServices/detail/buyResource/index.js |  118 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 104 insertions(+), 14 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/buyResource/index.js b/packageBookService/pages/bookServices/detail/buyResource/index.js
index 39062f7..77e65ca 100644
--- a/packageBookService/pages/bookServices/detail/buyResource/index.js
+++ b/packageBookService/pages/bookServices/detail/buyResource/index.js
@@ -12,12 +12,16 @@
     openLearnids: [],
     bookId: '',
     loading: false,
+    shoppingList: [],
+    shoppingCartGetId: [],
+    methodId: []
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad(options) {
+
     const systInfo = wx.getSystemInfoSync();
     const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅
     const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴�
@@ -29,8 +33,49 @@
     this.getResourceClass()
     console.log(options);
     this.getResourceData({ productLinkPath: options.productLinkPath, refCode: options.refCode })
+    this.getShoppingCartProductGet()
+    this.getBookInfo(options.bookId)
   },
+  batchPurchase() {
+    let saleMethodIds = []
+    let requests = []
+    const child = this.selectComponent('#tree')
 
+    console.log(child.data.superiorPurchaseSaleMethodId, 'superiorPurchaseSaleMethodId');
+    const item = child.data.superiorPurchaseSaleMethodId
+    if (item) {
+      item.forEach(item => {
+        if (item.saleMethod != 0) {
+          saleMethodIds = item.saleMethod[0].Id
+          requests.push({ saleMethodIds, count: 1 })
+        }
+      })
+      console.log(requests, 'saleMethodId');
+      let query = {
+        remarks: '浜戝涔�',
+        requests,
+
+
+
+      }
+
+      // 鍙戣捣璁㈠崟鍒濆鍖栬姹傚苟绛夊緟缁撴灉
+      const res = app.MG.store.initOrder(query)
+      let bookOrdersId = res.orderNumber
+      // 妫�鏌ヨ鍗曞彿鏄惁瀛樺湪
+      if (bookOrdersId) {
+        const url = '/pages/cart/paymentPage/index?orderNumber=' + bookOrdersId
+        wx.navigateTo({
+          url
+        })
+      }
+    }
+
+    // console.log(child.data.sonPurchaseSaleMethodId, 'child.data.');
+    // this.data.methodId.push(child.data.sonPurchaseSaleMethodId)
+
+
+  },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
    */
@@ -123,7 +168,8 @@
         if (type.refCode == 'jsek_teachingResources' || type.refCode == 'jsek_cloudLearning') {
           if (res.datas.cmsDatas[0].datas.length > 0) {
             res.datas.cmsDatas[0].datas.forEach(item => {
-              item.checked = false
+              item.checked = false,
+                item.checkAll = true
             })
             const list = await this.getAllResource(res.datas.cmsDatas[0].datas)
             if (type.refCode == 'jsek_teachingResources') {
@@ -133,15 +179,17 @@
               })
               this.findChildIds(this.data.teach, this.data.openTeachids = [])
             } else if (type.refCode == 'jsek_cloudLearning') {
+              const result = []
               res.datas.cmsDatas[0].datas.forEach(item => {
                 item.checked = false
               })
-              const list = await this.getAllResource(res.datas.cmsDatas[0].datas)
+              this.findChildIds(list, result)
               this.setData({
                 learn: list,
-                loading: false
+                loading: false,
+                openLearnids: result
               })
-              this.findChildIds(this.data.learn, this.data.openLearnids = [])
+              console.log('鏁欏璧勬簮', list);
             }
           } else {
             // 鏃犳暟鎹�
@@ -270,27 +318,64 @@
     });
 
   },
-    // 鍒ゆ柇璧勬簮鏄惁璐拱
-    resourceIsBuy(data) {
-      if (data.saleMethod && data.saleMethod.length) {
-        const isSHow = this.data.buyIdList.some((item) => item == data.saleMethod[0].Id)
-        return !isSHow
-      } else {
+  // 鑾峰彇宸茶喘涔板晢鍝�
+  getShoppingCartProductGet() {
+    let query = {
+      start: 0,
+      size: 999,
+      filterList: [],
+      searchList: []
+    }
+    app.MG.store.getShoppingCartProductList(query).then((res) => {
+      const list = []
+      res.datas.forEach((item) => {
+        list.push(item.saleMethod.id)
+      })
+      this.setData({
+        shoppingList: res.datas,
+        shoppingCartGetId: list
+      })
+    })
+  },
+  // 鍒ゆ柇璧勬簮鏄惁璐拱
+  resourceIsBuy(data) {
+    if (data.saleMethod && data.saleMethod.length) {
+      const isSHow = this.data.buyIdList.some((item) => item == data.saleMethod[0].Id)
+      return !isSHow
+    } else {
+      return false
+    }
+  },
+  // 鍒ゆ柇璧勬簮鍔犲叆璐墿杞︽寜閽槸鍚︽樉绀�
+  isShoppingCart(data) {
+    if (data.saleMethod && data.saleMethod.length) {
+      if (data.saleMethod[0].Price <= 0) return false
+      // 鍐嶅垽鏂槸鍚﹁喘涔�
+      const isBuy = this.data.buyIdList.some((item) => item == data.saleMethod[0].Id)
+      if (isBuy) {
+        // 璐拱浜�
         return false
+      } else {
+        // 鍒ゆ柇鏄惁鍔犲叆璐墿杞�
+        const isSHow = this.data.shoppingCartGetId.some((item) => item == data.saleMethod[0].Id)
+        return !isSHow
       }
-    },
+    } else {
+      return false
+    }
+  },
   // 鑾峰彇灞曞紑椤�
   findChildIds(data, result) {
     let index = 0
     for (let i = 0; i < data.length; i++) {
       if (index < 3) {
         const item = data[i]
-        if (item.childrenFolderCount > 0) {
+        if (item.children && item.children.length > 0) {
           result.push(item.id)
           for (let j = 0; j < item.children.length; j++) {
             if (index < 3) {
               const childrenItme = item.children[j]
-              if (item.childrenCount > 0) {
+              if (item.children && item.children.length > 0) {
                 result.push(childrenItme.id)
                 index += 1
               }
@@ -298,7 +383,7 @@
               break
             }
           }
-        } else if (item.childrenCount > 0) {
+        } else if (item.children && item.children.length > 0) {
           result.push(item.id)
           index += 1
         }
@@ -318,4 +403,9 @@
       })
     })
   },
+  checkAll() {
+    const child = this.selectComponent('#tree')
+    child.checkAll()
+  },
+
 })
\ No newline at end of file

--
Gitblit v1.9.1