diff --git a/packages/shop/shopCar/index.css b/packages/shop/shopCar/index.css index ebd0a038..d40c9638 100644 --- a/packages/shop/shopCar/index.css +++ b/packages/shop/shopCar/index.css @@ -76,8 +76,13 @@ justify-content: flex-end; } +.goodsItem_supplier{ + display: flex; + align-items: center; + margin: 20rpx; +} + .goodsItem_tit{ - margin: 20rpx 0 0 20rpx; font-size: 35rpx; font-weight: bold; } diff --git a/packages/shop/shopCar/index.vue b/packages/shop/shopCar/index.vue index 354b5362..1f896320 100644 --- a/packages/shop/shopCar/index.vue +++ b/packages/shop/shopCar/index.vue @@ -29,8 +29,14 @@ - - {{ carItem.supplier_name }} + + + + + + + {{ carItem.supplier_name }} + @@ -96,8 +102,14 @@ - - {{ carItem.supplier_name }} + + + + + + + {{ carItem.supplier_name }} + @@ -227,9 +239,32 @@ export default { // } // }, methods: { - back() { - NavgateTo("1"); - }, + back() { + NavgateTo("1"); + }, + + // 商家单选框全选/取消全选 + supplierCheck(carItem, isDay) { + carItem.supplierChecked = !carItem.supplierChecked; + carItem.commodity_cart_and_goods_model.forEach(goods => { + goods.checked = carItem.supplierChecked; + }); + this.calcTotal(); + + // 更新当日达或包邮全选状态 + if (isDay) { + this.isDaychecked = this.isDayCarList.every(item => + item.commodity_cart_and_goods_model.every(goods => goods.checked) + ); + } else { + this.isParcelPostchecked = this.shopCarList.every(item => + item.commodity_cart_and_goods_model.every(goods => goods.checked) + ); + } + + // 更新全选状态 + this.isAllchecked = this.isDaychecked && this.isParcelPostchecked; + }, // 结算 submitOrder() { @@ -262,12 +297,14 @@ export default { if (res.normal_cart_list.length > 0) { res.normal_cart_list.forEach((item) => { item.checked = false; + item.supplierChecked = false; this.parcelPostshow = true; }) this.shopCarList = res.normal_cart_list } else { res.normal_cart_list.forEach((item) => { item.checked = false; + item.supplierChecked = false; this.parcelPostshow = false; }) } @@ -275,12 +312,14 @@ export default { if (res.same_day_cart_list.length > 0) { res.same_day_cart_list.forEach((item) => { item.checked = false; + item.supplierChecked = false; this.isDayshow = true; }) this.isDayCarList = res.same_day_cart_list } else { res.normal_cart_list.forEach((item) => { item.checked = false; + item.supplierChecked = false; this.isDayshow = false; }) } @@ -307,6 +346,14 @@ export default { changeChecked(item) { item.checked = !item.checked; this.calcTotal(); + + // 找到对应的商家并更新商家选中状态 + this.shopCarList.forEach(carItem => { + if (carItem.commodity_cart_and_goods_model.includes(item)) { + carItem.supplierChecked = carItem.commodity_cart_and_goods_model.every(goods => goods.checked); + } + }); + // 检查当日达是否全选 this.isDaychecked = this.isDayCarList.every(carItem => carItem.commodity_cart_and_goods_model.every(goods => goods.checked) @@ -321,6 +368,14 @@ export default { DayChecked(item) { item.checked = !item.checked; this.calcTotal(); + + // 找到对应的商家并更新商家选中状态 + this.isDayCarList.forEach(carItem => { + if (carItem.commodity_cart_and_goods_model.includes(item)) { + carItem.supplierChecked = carItem.commodity_cart_and_goods_model.every(goods => goods.checked); + } + }); + // 检查当日达是否全选 this.isDaychecked = this.isDayCarList.every(carItem => carItem.commodity_cart_and_goods_model.every(goods => goods.checked) @@ -338,15 +393,17 @@ export default { this.isDaychecked = this.isAllchecked; this.isParcelPostchecked = this.isAllchecked; - // 设置当日达购物车商品选中状态 + // 设置当日达购物车商品和商家选中状态 this.isDayCarList.forEach(carItem => { + carItem.supplierChecked = this.isAllchecked; carItem.commodity_cart_and_goods_model.forEach(goods => { goods.checked = this.isAllchecked; }); }); - // 设置包邮购物车商品选中状态 + // 设置包邮购物车商品和商家选中状态 this.shopCarList.forEach(carItem => { + carItem.supplierChecked = this.isAllchecked; carItem.commodity_cart_and_goods_model.forEach(goods => { goods.checked = this.isAllchecked; }); @@ -359,8 +416,9 @@ export default { is_day_checked() { this.isDaychecked = !this.isDaychecked; - // 设置当日达购物车商品选中状态 + // 设置当日达购物车商品和商家选中状态 this.isDayCarList.forEach(carItem => { + carItem.supplierChecked = this.isDaychecked; carItem.commodity_cart_and_goods_model.forEach(goods => { goods.checked = this.isDaychecked; }); @@ -376,8 +434,9 @@ export default { parcel_post_checked() { this.isParcelPostchecked = !this.isParcelPostchecked; - // 设置包邮购物车商品选中状态 + // 设置包邮购物车商品和商家选中状态 this.shopCarList.forEach(carItem => { + carItem.supplierChecked = this.isParcelPostchecked; carItem.commodity_cart_and_goods_model.forEach(goods => { goods.checked = this.isParcelPostchecked; });