yiming
2024-03-28 8f1835f66ef83bbd752e080178afb98632a6970d
packageBookService/pages/bookServices/detail/buyResource/index.js
@@ -34,7 +34,10 @@
    });
    this.getResourceClass()
    console.log(options);
    this.getResourceData({ productLinkPath: options.productLinkPath, refCode: options.refCode })
    this.getResourceData({
      productLinkPath: options.productLinkPath,
      refCode: options.refCode
    })
    this.getShoppingCartProductGet()
    this.getBookInfo(options.bookId)
  },
@@ -369,19 +372,52 @@
  checkAll() {
    const child = this.selectComponent('#tree')
    child.checkAll()
  },
  //购买按钮
  batchPurchase() {
    let saleMethodIds = []
    let requests = []
    let item = []
    let selectAllId = []
    const child = this.selectComponent('#tree')
    console.log(child.data.superiorPurchaseSaleMethodId, 'superiorPurchaseSaleMethodId');
    console.log(child.data.sonPurchaseSaleMethodId, 'child.data');
    // console.log(child.data.selectAll, 'selectAll');
    item = child.data.superiorPurchaseSaleMethodId
    const sonItem = child.data.sonPurchaseSaleMethodId
    let selectAll = child.data.selectAll
    if (selectAll) {
      // console.log(selectAll);
      selectAll.forEach(item => {
        if (item.saleMethod != 0) {
          // console.log(item, 'item');
          selectAllId.push(item.saleMethod[0].Id)
        }
      })
      console.log(selectAllId);
      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) {
      console.log(item, 'sadsdasd');
      // 拿到id
@@ -402,22 +438,14 @@
          wx.navigateTo({
            url: '/pages/cart/paymentPage/index?orderNumber=' + res.orderNumber,
          })
          this.setData({
            superior: true
          })
          child.setData({
            superiorPurchaseSaleMethodId: [] // 使用setData方法清空sonPurchaseSaleMethodId数据
          })
        }
      })
    }
    if (item.length == 0 && sonItem) {
      app.MG.store.initOrder({
        requests: sonItem.map(id => ({
          saleMethodId: id,
@@ -431,7 +459,9 @@
          this.setData({
            paymentPage: true
          })
          child.setData({
            sonPurchaseSaleMethodId: [] // 使用setData方法清空sonPurchaseSaleMethodId数据
          })
        }
      })
    }