|
@@ -44,13 +44,13 @@ Page({
|
|
|
// 选中/取消选中所有
|
|
// 选中/取消选中所有
|
|
|
handleCheckedAll(){
|
|
handleCheckedAll(){
|
|
|
API.handleCheckedAll().then(res=>{
|
|
API.handleCheckedAll().then(res=>{
|
|
|
-
|
|
|
|
|
|
|
+ this.handleCartsFn(res);
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
// 取消选中所有
|
|
// 取消选中所有
|
|
|
handleUncheckedAll(){
|
|
handleUncheckedAll(){
|
|
|
API.handleUncheckedAll().then(res=>{
|
|
API.handleUncheckedAll().then(res=>{
|
|
|
-
|
|
|
|
|
|
|
+ this.handleCartsFn(res);
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
// 删除选中的商品
|
|
// 删除选中的商品
|
|
@@ -100,23 +100,17 @@ Page({
|
|
|
// 增加数量
|
|
// 增加数量
|
|
|
increaseCount(e) {
|
|
increaseCount(e) {
|
|
|
const id = e.currentTarget.dataset.id;
|
|
const id = e.currentTarget.dataset.id;
|
|
|
- const cartList = this.data.cartList.map(item => {
|
|
|
|
|
- if (item.id == id) item.quantity++;
|
|
|
|
|
- return item;
|
|
|
|
|
- });
|
|
|
|
|
- this.setData({ cartList });
|
|
|
|
|
- this.calculateTotal();
|
|
|
|
|
|
|
+ API.addCartProdCount({id}).then(res=>{
|
|
|
|
|
+ this.handleCartsFn(res);
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// 减少数量
|
|
// 减少数量
|
|
|
decreaseCount(e) {
|
|
decreaseCount(e) {
|
|
|
const id = e.currentTarget.dataset.id;
|
|
const id = e.currentTarget.dataset.id;
|
|
|
- const cartList = this.data.cartList.map(item => {
|
|
|
|
|
- if (item.id == id && item.quantity > 1) item.quantity--;
|
|
|
|
|
- return item;
|
|
|
|
|
- });
|
|
|
|
|
- this.setData({ cartList });
|
|
|
|
|
- this.calculateTotal();
|
|
|
|
|
|
|
+ API.subCartProdCount({id}).then(res=>{
|
|
|
|
|
+ this.handleCartsFn(res);
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
// 计算总价和选中数量
|
|
// 计算总价和选中数量
|
|
|
calculateTotal() {
|
|
calculateTotal() {
|
|
@@ -137,6 +131,8 @@ Page({
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
onLoad(){
|
|
onLoad(){
|
|
|
|
|
+ },
|
|
|
|
|
+ onShow(){
|
|
|
this.getCartProds();
|
|
this.getCartProds();
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|