yiming
2024-03-21 47462dc6c323cc4ac7b32b93051947d351799c1f
pages/cart/index.js
@@ -20,7 +20,11 @@
    });
    this.shoppingCartGet();
  },
  onShow() {
    this.shoppingCartGet();
    this.setData({ totalPrice: 0.00, selectedCount: 0, checkAll: false, })
  },
  onDelete(e) {
    const item = e.currentTarget.dataset.item;
    app.MG.store.delShoppingCart({
@@ -39,6 +43,7 @@
      searchList: []
    };
    app.MG.store.getShoppingCartProductList(query).then(res => {
      console.log(res, 'res');
      res.datas.forEach(item => {
        item.imgUrl = getPublicImage(item.productMonWithLinkDto.product.icon, '', '160');
        console.log(item);
@@ -76,12 +81,9 @@
      if (eitem.id == item.id) {
        eitem.checked = e.detail.checked
      }
    })
    const data = items.filter(item => item.checked)
    const checkAll = data.length == this.data.shoppingCartData.length
    this.setData({
      shoppingCartData: items,
      checkAll
@@ -106,24 +108,19 @@
    });
  },
  goPaymentPage() {
    const selectedItems = this.data.shoppingCartData.filter(item => item.checked);
    // console.log(selectedItems, 789);
    const selectedIds = selectedItems.map(item => item.id);
    console.log('选中的商品 id:', selectedIds);
    if (selectedIds.length) {
      app.MG.store.shoppingCartCreateOrder({ linkIds: selectedIds }).then(res => {
        console.log(res.orderNumber, 456);
        console.log(res, 456);
        const url = '/pages/cart/paymentPage/index?orderNumber=' + res.orderNumber
        wx.navigateTo({
          url
        });
      })
    } else {
      Toast({
        context: this,
        selector: '#t-toast',
@@ -132,8 +129,10 @@
        direction: 'column',
      });
    }
  },
  onLogin() {
    wx.navigateTo({
      url: '/pages/testLogin/index'
    });
  }
});