From c99f9976a5ef9d8974105feb8fc0580a10adf98c Mon Sep 17 00:00:00 2001
From: QYF-GitLab1 <1940665526@qq.com>
Date: 星期一, 23 十二月 2024 14:58:49 +0800
Subject: [PATCH] 111

---
 packageBookService/pages/bookServices/detail/buyResource/index.js |  112 ++++++++++++++-----------------------------------------
 1 files changed, 29 insertions(+), 83 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/buyResource/index.js b/packageBookService/pages/bookServices/detail/buyResource/index.js
index aa65579..cec5617 100644
--- a/packageBookService/pages/bookServices/detail/buyResource/index.js
+++ b/packageBookService/pages/bookServices/detail/buyResource/index.js
@@ -258,8 +258,7 @@
       itemFields: {
         SysType: 'CmsFolder',
         // 璧勬簮绫诲瀷锛岃瘯璇绘枃浠讹紝鏄惁鍏佽涓嬭浇绛夊弬鏁�
-        // learnSelectType: [],
-        // selectType: [],
+        learnSelectType: [],
         // freeFile: [],
         // file: [],
         // protectedFile: [],
@@ -501,87 +500,30 @@
     // 淇敼鍚庢柟娉�
     const checkData = this.handleTreeData(this.data.learn).filter(item => item.checked == true)
     console.log('閫変腑', checkData);
-    // let saleMethodIds = [];
-    // let requests = [];
-    // let item = [];
-    // let selectAllId = [];
-    // const child = this.selectComponent("#tree");
-    // item = child.data.superiorPurchaseSaleMethodId;
-    // const sonItem = child.data.sonPurchaseSaleMethodId;
-    // let selectAll = child.data.selectAll;
-    // if (selectAll.length) {
-    //   selectAll.forEach((item) => {
-    //     if (item.saleMethod != 0) {
-    //       selectAllId.push(item.saleMethod[0].Id);
-    //     }
-    //   });
-    //   app.MG.store
-    //     .initOrder({
-    //       requests: selectAllId.map((id) => ({
-    //         saleMethodId: id,
-    //         count: 1,
-    //       })),
-    //     })
-    //     .then((res) => {
-    //       if (res) {
-    //         wx.navigateTo({
-    //           url: "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber,
-    //         });
-    //         selectAllId = [];
-    //         child.setData({
-    //           selectAll: [],
-    //         });
-    //       }
-    //     });
-    // }
-    // if (item) {
-    //   // 鎷垮埌id
-    //   item.forEach((items) => {
-    //     if (items.saleMethod != 0) {
-    //       saleMethodIds.push(items.saleMethod[0].Id);
-    //     }
-    //   });
-    //   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,
-    //         });
-
-    //         child.setData({
-    //           superiorPurchaseSaleMethodId: [], // 浣跨敤setData鏂规硶娓呯┖sonPurchaseSaleMethodId鏁版嵁
-    //         });
-    //       }
-    //     });
-    // }
-    // 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,
-    //         });
-    //         child.setData({
-    //           sonPurchaseSaleMethodId: [], // 浣跨敤setData鏂规硶娓呯┖sonPurchaseSaleMethodId鏁版嵁
-    //         });
-    //       }
-    //     });
-    // }
+    if (!checkData.length) return wx.showToast({
+      icon: 'error',
+      title: '璇峰嬀閫夎祫婧�',
+    })
+    let saleMethodIds = [];
+    checkData.forEach((items) => {
+      if (items.saleMethod.length) {
+        saleMethodIds.push(items.saleMethod.find(citem => citem.SaleType == 'Normal').Id);
+      }
+    });
+    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,
+          });
+        }
+      });
   },
 
   // 绔犺妭鍕鹃�夋柟娉�
@@ -627,6 +569,8 @@
     const updated = this.findAndUpdateItemsByIds(this.data.learn, ids, state)
     this.setData({
       learn: updated
+    }, () => {
+      wx.hideLoading()
     })
   },
   // 鍗曚釜鍕鹃�変簨浠�
@@ -635,6 +579,8 @@
     const updated = this.checkResoucrceInfo(this.data.learn, id)
     this.setData({
       learn: updated
+    }, () => {
+      wx.hideLoading()
     })
   },
   upDateShopCar(id, tree) {

--
Gitblit v1.9.1