购物车页面加载问题与选中修复

master
linzj 5 years ago
parent fc42935f7b
commit e60946e95b

@ -129,7 +129,7 @@ export default {
finalMoney: 0, finalMoney: 0,
totalMoney: 0, totalMoney: 0,
subtractMoney: 0, subtractMoney: 0,
allChecked: true allChecked: false
}; };
}, },
@ -150,40 +150,43 @@ export default {
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
uni.showLoading(); // this.loadBasketData();
var params = {
url: "/p/shopCart/info",
method: "POST",
data: {},
callBack: res => {
if (res.length > 0) {
//
var shopCartItemDiscounts = res[0].shopCartItemDiscounts;
shopCartItemDiscounts.forEach(shopCartItemDiscount => {
shopCartItemDiscount.shopCartItems.forEach(shopCartItem => {
shopCartItem.checked = true;
});
});
this.setData({
shopCartItemDiscounts: shopCartItemDiscounts,
allChecked: true
});
} else {
this.setData({
shopCartItemDiscounts: []
});
}
this.calTotalPrice(); //
uni.hideLoading();
}
};
http.request(params);
http.getCartCount(); // http.getCartCount(); //
}, },
methods: { methods: {
loadBasketData(){
uni.showLoading(); //
var params = {
url: "/p/shopCart/info",
method: "POST",
data: {},
callBack: res => {
if (res.length > 0) {
//
var shopCartItemDiscounts = res[0].shopCartItemDiscounts;
shopCartItemDiscounts.forEach(shopCartItemDiscount => {
shopCartItemDiscount.shopCartItems.forEach(shopCartItem => {
shopCartItem.checked = false;
});
});
this.setData({
shopCartItemDiscounts: shopCartItemDiscounts,
allChecked: false
});
} else {
this.setData({
shopCartItemDiscounts: []
});
}
this.calTotalPrice(); //
uni.hideLoading();
}
};
http.request(params);
},
/** /**
* 去结算 * 去结算
*/ */
@ -416,7 +419,7 @@ export default {
data: basketIds, data: basketIds,
callBack: function (res) { callBack: function (res) {
uni.hideLoading(); uni.hideLoading();
ths.onShow(); ths.loadBasketData();
} }
}; };
http.request(params); http.request(params);

Loading…
Cancel
Save