| | |
| | | activeValues: [1, 2], |
| | | webpageSrc: '', |
| | | cloudShoppingCart: [], |
| | | selectAll: [] |
| | | selectAll: [], |
| | | shoppingCart: true |
| | | }, |
| | | ready() { |
| | | this.setData({ |
| | |
| | | }) |
| | | } |
| | | }) |
| | | // this.onCloudShoppingCart() |
| | | }, |
| | | // 子项勾选 |
| | | checkResource(e) { |
| | |
| | | }) |
| | | }, |
| | | // 加入购物车 |
| | | async onCloudShoppingCart() { |
| | | let requests = [] |
| | | const item = this.data.cloudShoppingCart |
| | | console.log(item, 'item'); |
| | | item.forEach((items) => { |
| | | if (items.saleMethod.length) { |
| | | requests.push({ |
| | | saleMethodId: items.saleMethod[0].Id, |
| | | count: 1 |
| | | }) |
| | | } |
| | | }) |
| | | async onCloudShoppingCart(e) { |
| | | |
| | | let shoppingCartGetId = [] |
| | | const saleMethodId = e.currentTarget.dataset.item.saleMethod[0].Id |
| | | console.log(saleMethodId); |
| | | let query = { |
| | | remarks: '云学习', |
| | | requests |
| | | start: 0, |
| | | size: 999, |
| | | filterList: [], |
| | | searchList: [] |
| | | } |
| | | // 查询订单 |
| | | let initOrderRes = await app.MG.store.initOrder(query) |
| | | let parameter = { |
| | | orderNum: initOrderRes.orderNumber |
| | | |
| | | const res = await app.MG.store.getShoppingCartProductList(query) |
| | | res.datas.forEach(item => { |
| | | shoppingCartGetId.push(item.saleMethod.id) |
| | | }) |
| | | if (shoppingCartGetId.includes(saleMethodId)) { |
| | | console.log(111); |
| | | |
| | | wx.showToast({ |
| | | icon: 'error', |
| | | title: '已添加', |
| | | }) |
| | | this.setData({ |
| | | shoppingCart: false |
| | | }) |
| | | } else { |
| | | let query = { |
| | | requests: [{ |
| | | saleMethodId: saleMethodId, |
| | | storeEventId: null, |
| | | // agentCode: '电子书' |
| | | }] |
| | | } |
| | | const addRes = await app.MG.store.addShoppingCart(query) |
| | | console.log(addRes, 'addRes'); |
| | | wx.showToast({ |
| | | icon: 'success', |
| | | title: '添加成功', |
| | | }) |
| | | } |
| | | const confirmOrderRes = await app.MG.store.confirmOrder(parameter) |
| | | // if (confirmOrderRes.orderNumber) { |
| | | // wx.navigateTo({ |
| | | // url: `/pages/cart/paymentPage/index?orderNumber=${confirmOrderRes.orderNumber}`, |
| | | // }) |
| | | // requests = [] |
| | | // } |
| | | |
| | | }, |
| | | }, |
| | | onCheckAllChange(e) { |
| | |
| | | // this.setData({ |
| | | // checkAllValues: event.detail, |
| | | // }); |
| | | } |
| | | }, |
| | | }) |