From 62f400a15cc42724f27fe7404613e415a3e094f9 Mon Sep 17 00:00:00 2001 From: Junling Bu Date: Mon, 12 Aug 2019 21:21:23 +0800 Subject: [PATCH] fix[litemall-vue]: #245 --- litemall-vue/src/views/order/tabbar-cart.vue | 37 +++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/litemall-vue/src/views/order/tabbar-cart.vue b/litemall-vue/src/views/order/tabbar-cart.vue index 4c0610e4..e30889e3 100755 --- a/litemall-vue/src/views/order/tabbar-cart.vue +++ b/litemall-vue/src/views/order/tabbar-cart.vue @@ -37,7 +37,7 @@ label="总计" @submit="cartSubmit" > - 全选 + 全选 @@ -57,25 +57,16 @@ export default { checkedAll: false, isSubmit: false, checkedGoods: [], - AllGoods: [], - allCheckedStatus: false, - goods: [], - count: 0 + allGoods: [], + goods: [] }; }, - - activated() { - this.checkedAll = false; - this.isEditor = false; - this.isSubmit = false; - }, created() { this.init(); }, computed: { submitBarText() { - const count = this.count; - return this.isEditor ? '删除' : `结算${count ? `(${count})` : ''}`; + return this.isEditor ? '删除' : '结算'; }, totalPrice() { return this.goods.reduce( @@ -102,9 +93,8 @@ export default { init() { cartList().then(res => { this.goods = res.data.data.cartList; - this.AllGoods = this.getAllList(); + this.allGoods = this.getAllList(); this.checkedGoods = this.getCheckedList(this.goods); - this.count = this.checkedGoods.length; }); }, getAllList() { @@ -149,10 +139,10 @@ export default { } }, setCheckAll(val) { - if (this.checkedGoods.length === this.AllGoods.length) { + if (this.checkedGoods.length === this.allGoods.length) { this.checkedGoods = []; } else { - this.checkedGoods = this.AllGoods; + this.checkedGoods = this.allGoods; } }, deleteCart(o) { @@ -175,19 +165,25 @@ export default { }); let delProductIds = []; - _.each(_.difference(this.AllGoods, index), v => { + _.each(_.difference(this.allGoods, index), v => { let productId = _.find(this.goods, result => { return result.id === v; }).productId; delProductIds.push(productId); }); - //没选中的不掉接口 if (delProductIds.length > 0) { cartChecked({productIds: delProductIds, isChecked: 0}); } if (addProductIds.length > 0) { cartChecked({productIds: addProductIds, isChecked: 1}); } + + if(index.length === this.allGoods.length){ + this.checkedAll = true + } + else{ + this.checkedAll = false + } }, deleteNext(o) { let productIds = []; @@ -199,9 +195,8 @@ export default { cartDelete({productIds: productIds}).then(res => { this.goods = res.data.data.cartList; - this.AllGoods = this.getAllList(); + this.allGoods = this.getAllList(); this.checkedGoods = this.getCheckedList(this.goods); - this.count = this.checkedGoods.length; }); } },