|
@@ -306,17 +306,37 @@
|
|
|
content: '请选择要删除的商品',
|
|
|
success: async (res) => {
|
|
|
if (!res.confirm) return
|
|
|
- const result = await this.$api(`/cart/${e.cart_id}`, 'Delete');
|
|
|
- if (result.errcode === 0) {
|
|
|
- list = list.map(i => ({
|
|
|
- ...i,
|
|
|
- goods: i.goods.filter(f => f.cart_id !== e.cart_id)
|
|
|
- }))
|
|
|
- this.$set(this, `list`, list);
|
|
|
- // 检查店铺内是否还有商品
|
|
|
- this.checkShopGoodsExist();
|
|
|
- // 计算总额
|
|
|
- this.countMoney();
|
|
|
+ if (e?.cart_id) {
|
|
|
+ const result = await this.$api(`/cart/${e.cart_id}`, 'Delete');
|
|
|
+ if (result.errcode === 0) {
|
|
|
+ list = list.map(i => ({
|
|
|
+ ...i,
|
|
|
+ goods: i.goods.filter(f => f.cart_id !== e.cart_id)
|
|
|
+ }))
|
|
|
+ this.$set(this, `list`, list);
|
|
|
+ // 检查店铺内是否还有商品
|
|
|
+ this.checkShopGoodsExist();
|
|
|
+ // 计算总额
|
|
|
+ this.countMoney();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log(1);
|
|
|
+ const goodsList = this.list.map(i => i.goods).flat();
|
|
|
+ const cartIds = goodsList.filter(i => i.check).map(i => i.cart_id)
|
|
|
+ for (let val of cartIds) {
|
|
|
+ const result = await this.$api(`/cart/${val}`, 'Delete');
|
|
|
+ if (result.errcode === 0) {
|
|
|
+ list = list.map(i => ({
|
|
|
+ ...i,
|
|
|
+ goods: i.goods.filter(f => f.cart_id !== val)
|
|
|
+ }))
|
|
|
+ this.$set(this, `list`, list);
|
|
|
+ // 检查店铺内是否还有商品
|
|
|
+ this.checkShopGoodsExist();
|
|
|
+ // 计算总额
|
|
|
+ this.countMoney();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|