|
@@ -53,35 +53,64 @@ Component({
|
|
|
})
|
|
|
},
|
|
|
buyMore(e) {
|
|
|
- const item = e.currentTarget.dataset.item.item[0];
|
|
|
- const item1 = e.currentTarget.dataset.item;
|
|
|
- wx.showModal({
|
|
|
- title: '提示',
|
|
|
- content: `是否确定将“${item.itemname}”加入到购物车`,
|
|
|
- complete: (res) => {
|
|
|
- if (res.confirm) _Http.basic({
|
|
|
- "id": 20220924095102,
|
|
|
- "content": {
|
|
|
- sa_brandid: item1.sa_brandid,
|
|
|
- "itemid": item.itemid, //货品id
|
|
|
- "qty": item.orderminqty, //数量
|
|
|
- itemno: item.itemno, //货品编号
|
|
|
- tradefield: item1.tradefield,
|
|
|
- width: item.width,
|
|
|
- length: item.length
|
|
|
- },
|
|
|
- }).then(res => {
|
|
|
- console.log("加入购物车", res)
|
|
|
- wx.showToast({
|
|
|
- title: res.msg == '成功' ? '加入成功' : res.msg,
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- if (res.msg == '成功') getApp().globalData.getCollectCount().then(badge => this.setData({
|
|
|
- badge
|
|
|
- }))
|
|
|
+ const {
|
|
|
+ name
|
|
|
+ } = e.target.dataset;
|
|
|
+ if (!name) return;
|
|
|
+ const item1 = e.currentTarget.dataset.item,
|
|
|
+ index = e.currentTarget.dataset.index,
|
|
|
+ item = item1.item[0];
|
|
|
+
|
|
|
+ if (name == '购物车') {
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: `是否确定将“${item.itemname}”加入到购物车`,
|
|
|
+ complete: (res) => {
|
|
|
+ if (res.confirm) _Http.basic({
|
|
|
+ "id": 20220924095102,
|
|
|
+ "content": {
|
|
|
+ sa_brandid: item1.sa_brandid,
|
|
|
+ "itemid": item.itemid, //货品id
|
|
|
+ "qty": item.orderminqty, //数量
|
|
|
+ itemno: item.itemno, //货品编号
|
|
|
+ tradefield: item1.tradefield,
|
|
|
+ width: item.width,
|
|
|
+ length: item.length
|
|
|
+ },
|
|
|
+ }).then(res => {
|
|
|
+ console.log("加入购物车", res)
|
|
|
+ wx.showToast({
|
|
|
+ title: res.msg == '成功' ? '加入成功' : res.msg,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ if (res.msg == '成功') getApp().globalData.getCollectCount().then(badge => this.setData({
|
|
|
+ badge
|
|
|
+ }))
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ let iscollection = item.iscollection == 1 ? false : true
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20231121143403,
|
|
|
+ "content": {
|
|
|
+ "itemid": item.itemid, //货品id
|
|
|
+ "qty": item.orderminqty, //数量
|
|
|
+ iscollection,
|
|
|
+ width: item.width,
|
|
|
+ length: item.length
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log(iscollection + "收藏夹", res)
|
|
|
+ wx.showToast({
|
|
|
+ title: res.msg == '成功' ? iscollection ? '收藏成功' : "已取消收藏" : res.msg,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ if (res.msg == '成功') getCurrentPages()[getCurrentPages().length - 1].setData({
|
|
|
+ [`list[${index}].item[0].iscollection`]: iscollection ? 1 : 0
|
|
|
})
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
}
|
|
|
})
|