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

master
linzj 5 years ago
parent e1c19c19ac
commit 19b55886a5

@ -129,7 +129,7 @@ export default {
finalMoney: 0, finalMoney: 0,
totalMoney: 0, totalMoney: 0,
subtractMoney: 0, subtractMoney: 0,
allChecked: true allChecked: false
}; };
}, },
@ -150,6 +150,11 @@ export default {
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
this.loadBasketData();
http.getCartCount(); //
},
methods: {
loadBasketData(){
uni.showLoading(); // uni.showLoading(); //
var params = { var params = {
@ -158,16 +163,16 @@ export default {
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({
@ -181,9 +186,7 @@ export default {
} }
}; };
http.request(params); http.request(params);
http.getCartCount(); //
}, },
methods: {
/** /**
* 去结算 * 去结算
*/ */
@ -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