From 4ef1826180997bac879913bf17867bd3e390c29d Mon Sep 17 00:00:00 2001
From: yiming <m13691596795@163.com>
Date: 星期四, 28 三月 2024 09:24:46 +0800
Subject: [PATCH] 微信支付修改

---
 packageBookService/pages/bookServices/detail/buyResource/index.js |  109 ++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 69 insertions(+), 40 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/buyResource/index.js b/packageBookService/pages/bookServices/detail/buyResource/index.js
index 77e65ca..c0e5b0d 100644
--- a/packageBookService/pages/bookServices/detail/buyResource/index.js
+++ b/packageBookService/pages/bookServices/detail/buyResource/index.js
@@ -14,7 +14,9 @@
     loading: false,
     shoppingList: [],
     shoppingCartGetId: [],
-    methodId: []
+    methodId: [],
+    paymentPage: false,
+    superior: false
   },
 
   /**
@@ -36,46 +38,7 @@
     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)
-
-
-  },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
    */
@@ -407,5 +370,71 @@
     const child = this.selectComponent('#tree')
     child.checkAll()
   },
+  //璐拱鎸夐挳
+  batchPurchase() {
+    let saleMethodIds = []
+    let requests = []
+    let item = []
+    const child = this.selectComponent('#tree')
+
+    console.log(child.data.superiorPurchaseSaleMethodId, 'superiorPurchaseSaleMethodId');
+    console.log(child.data.sonPurchaseSaleMethodId, 'child.data');
+    item = child.data.superiorPurchaseSaleMethodId
+    const sonItem = child.data.sonPurchaseSaleMethodId
+
+    if (item) {
+      console.log(item, 'sadsdasd');
+      // 鎷垮埌id
+      item.forEach(items => {
+        if (items.saleMethod != 0) {
+          saleMethodIds.push(items.saleMethod[0].Id)
+        }
+      })
+      console.log(saleMethodIds, 'saleMethodIds');
+
+      app.MG.store.initOrder({
+        requests: saleMethodIds.map(id => ({
+          saleMethodId: id,
+          count: 1,
+        })),
+      }).then(res => {
+        if (res) {
+          wx.navigateTo({
+            url: '/pages/cart/paymentPage/index?orderNumber=' + res.orderNumber,
+          })
+          this.setData({
+            superior: true
+          })
+
+        }
+      })
+
+
+    }
+
+
+
+
+    if (item.length == 0 && sonItem) {
+
+
+      app.MG.store.initOrder({
+        requests: sonItem.map(id => ({
+          saleMethodId: id,
+          count: 1,
+        })),
+      }).then(res => {
+        if (res) {
+          wx.navigateTo({
+            url: '/pages/cart/paymentPage/index?orderNumber=' + res.orderNumber,
+          })
+          this.setData({
+            paymentPage: true
+          })
+
+        }
+      })
+    }
+  },
 
 })
\ No newline at end of file

--
Gitblit v1.9.1