From 9b5db39b6c9a2011451b35d57008ed2b356c57a8 Mon Sep 17 00:00:00 2001 From: liudan <18634735655@163.com> Date: Wed, 10 Jul 2024 19:11:19 +0800 Subject: [PATCH] 1 --- pages/order_addcart/order_addcart.vue | 40 ++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/pages/order_addcart/order_addcart.vue b/pages/order_addcart/order_addcart.vue index 79347fd..f7624e3 100644 --- a/pages/order_addcart/order_addcart.vue +++ b/pages/order_addcart/order_addcart.vue @@ -257,7 +257,6 @@ // }, onShow() { - console.log(this.cartList.valid) let resArr=[] this.cartList.valid.forEach(item=>{ @@ -268,6 +267,9 @@ }) }) console.log(resArr) + let finishArr = []; + let totalMoney = 0 + this.selectCountPrice = 0.00 if (this.isLogin == true) { // this.getCartList(); getCartList().then(res => { @@ -281,14 +283,27 @@ } }) let selectedArr = i.list.filter(y=>{return y.check}) + console.log(selectedArr) + + + if(selectedArr.length==i.list.length){ this.$set(i,'allCheck',true) } if(selectedArr.length>0){ + finishArr.push(...selectedArr) hasSelected = true; } }) + finishArr.forEach(e => { + if (e.check) { + totalMoney = this.$util.$h.Add(totalMoney, this.$util.$h.Mul(e.productAttr.price, e.cart_num)) + + } + + }) + this.selectCountPrice = totalMoney if(!hasSelected){ this.selectCountPrice = 0.00 this.cartCount = 0 @@ -480,14 +495,16 @@ }); } }, - onMyEvent: function() { + onMyEvent() { + this.$set(this.attr, 'cartAttr', false); this.$set(this, 'isOpen', false); + }, /* * 更改商品属性 */ - changeCart: function(goods, id) { + changeCart(goods, id) { let that = this; if(that.goods == goods){ that.isOpen = that.attr.cartAttr = true; @@ -819,7 +836,22 @@ } const sku = {} // this.checkboxAllChange(true) - // + if(isChange){ + let totalMoney = 0; + console.log(this.cartList.valid,"liudan") + this.cartList.valid.forEach(el=>{ + el.list.forEach(e => { + if (e.check) { + totalMoney = this.$util.$h.Add(totalMoney, this.$util.$h.Mul(e.productAttr.price, e.cart_num)) + + } + }) + }) + + + this.selectCountPrice = totalMoney + } + }); }, // 商铺全选