|
|
|
@ -14,7 +14,7 @@ Page({
|
|
|
|
finalMoney: 0,
|
|
|
|
finalMoney: 0,
|
|
|
|
totalMoney: 0,
|
|
|
|
totalMoney: 0,
|
|
|
|
subtractMoney: 0,
|
|
|
|
subtractMoney: 0,
|
|
|
|
allChecked: true
|
|
|
|
allChecked: false
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -35,40 +35,41 @@ Page({
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
onShow: function () {
|
|
|
|
wx.showLoading();
|
|
|
|
this.loadBasketData();
|
|
|
|
//加载购物车
|
|
|
|
http.getCartCount();//重新计算购物车总数量
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
loadBasketData(){
|
|
|
|
|
|
|
|
uni.showLoading(); //加载购物车
|
|
|
|
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
var params = {
|
|
|
|
url: "/p/shopCart/info",
|
|
|
|
url: "/p/shopCart/info",
|
|
|
|
method: "POST",
|
|
|
|
method: "POST",
|
|
|
|
data: {},
|
|
|
|
data: {},
|
|
|
|
callBack: res => {
|
|
|
|
callBack: res => {
|
|
|
|
if (res.length > 0) {
|
|
|
|
if (res.length > 0) {
|
|
|
|
// 默认全选
|
|
|
|
// 默认不选中
|
|
|
|
var shopCartItemDiscounts = res[0].shopCartItemDiscounts;
|
|
|
|
var shopCartItemDiscounts = res[0].shopCartItemDiscounts;
|
|
|
|
shopCartItemDiscounts.forEach(shopCartItemDiscount => {
|
|
|
|
shopCartItemDiscounts.forEach(shopCartItemDiscount => {
|
|
|
|
shopCartItemDiscount.shopCartItems.forEach(shopCartItem => {
|
|
|
|
shopCartItemDiscount.shopCartItems.forEach(shopCartItem => {
|
|
|
|
shopCartItem.checked = true;
|
|
|
|
shopCartItem.checked = false;
|
|
|
|
})
|
|
|
|
});
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
this.setData({
|
|
|
|
shopCartItemDiscounts: shopCartItemDiscounts,
|
|
|
|
shopCartItemDiscounts: shopCartItemDiscounts,
|
|
|
|
allChecked: true
|
|
|
|
allChecked: false
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.setData({
|
|
|
|
this.setData({
|
|
|
|
shopCartItemDiscounts: [],
|
|
|
|
shopCartItemDiscounts: []
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.calTotalPrice(); //计算总价
|
|
|
|
this.calTotalPrice(); //计算总价
|
|
|
|
wx.hideLoading();
|
|
|
|
|
|
|
|
|
|
|
|
uni.hideLoading();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
http.request(params);
|
|
|
|
http.request(params);
|
|
|
|
|
|
|
|
|
|
|
|
http.getCartCount();//重新计算购物车总数量
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -290,7 +291,7 @@ Page({
|
|
|
|
data: basketIds,
|
|
|
|
data: basketIds,
|
|
|
|
callBack: function (res) {
|
|
|
|
callBack: function (res) {
|
|
|
|
wx.hideLoading();
|
|
|
|
wx.hideLoading();
|
|
|
|
ths.onShow();
|
|
|
|
ths.loadBasketData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
http.request(params);
|
|
|
|
http.request(params);
|
|
|
|
|