diff --git a/pages/order_addcart/order_addcart.vue b/pages/order_addcart/order_addcart.vue index 6c9df0c..6b1e045 100644 --- a/pages/order_addcart/order_addcart.vue +++ b/pages/order_addcart/order_addcart.vue @@ -334,6 +334,35 @@ }, onLoadFun(){ this.isShowAuth = false; + let resArr=[] + this.cartList.valid.forEach(item=>{ + item.list.forEach(i=>{ + if(i.check){ + resArr.push(i.product_id) + } + }) + }) + getCartList().then(res => { + console.log(res,"mm") + res.data.list.forEach(i=>{ + + i.list.forEach(u=>{ + if(resArr.includes(u.product_id)){ + u.check = true; + } + }) + let selectedArr = i.list.filter(y=>{return y.check}) + console.log(selectedArr) + if(selectedArr.length==i.list.length){ + this.$set(i,'allCheck',true) + } + + }) + this.cartList.valid = res.data.list; + + this.cartList.invalid = res.data.fail + }) + this.getCartNum(); }, goRouter(item) { var pages = getCurrentPages(); @@ -740,7 +769,7 @@ this.recommend = false } const sku = {} - this.checkboxAllChange() + this.checkboxAllChange(true) // }); }, @@ -780,7 +809,7 @@ this.cartAllCheck('goodsCheck') }, // 全选判断 - cartAllCheck(type) { + cartAllCheck(type,isFirst) { let allArr = []; let totalMoney = 0 let totalNum = 0 @@ -816,12 +845,19 @@ this.cartCount = totalNum this.selectCountPrice = totalMoney // 全选 - this.isAllSelect = allArr.length == this.cartList.valid.length ? true : false + console.log(allArr,"oooo12345",this.cartList.valid,isFirst) + if(!isFirst){ + this.isAllSelect = allArr.length == this.cartList.valid.length ? true : false + } + }, // 购物车全选 - checkboxAllChange() { + checkboxAllChange(val) { this.isAllSelect = !this.isAllSelect - this.cartAllCheck('cartCheck') + if(val){ + this.cartAllCheck('cartCheck','first') + } + }, // 推荐列表 getHostProduct: function() {