From 6db470a5b9d0e8091d165152f967180b2e42a399 Mon Sep 17 00:00:00 2001 From: ywk <317226901@qq.com> Date: Thu, 10 Apr 2025 09:20:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(shoppingCart):=20bug#16=20=E8=B4=AD?= =?UTF-8?q?=E7=89=A9=E8=BD=A6=E9=A1=B5=E9=9D=A2=E7=BC=93=E5=AD=98=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/shoppingCar/index.vue | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/pages/shoppingCar/index.vue b/pages/shoppingCar/index.vue index cca0897..b81fcad 100644 --- a/pages/shoppingCar/index.vue +++ b/pages/shoppingCar/index.vue @@ -128,9 +128,9 @@ :loading="isLoading" :loadingText="'购买中'" @tap="goBuy" - :disabled="!(isTo > 0 && isTo < 2)" + :disabled="checkoutDisabled" color="#FB3024" - >{{ '去结算' }} + >去结算 @@ -186,7 +186,6 @@ export default { isSelectAll: [], shopCarList: [], isLoading: false, - isTo: 0, goodsCheck: [], totalPrice: 0, totalAchive: 0, @@ -202,6 +201,11 @@ export default { // content:'确认删除该商品?' }; }, + computed: { + checkoutDisabled() { + return this.shopCarList.filter(item => item.isSelected).length !== 1 + } + }, watch: { selTable: { handler(n, o) { @@ -218,7 +222,8 @@ export default { // this.getCarList() }, onShow() { - this.getCarList(); + this.getCarList() + this.initCarList() }, methods: { tableTrue() { @@ -534,13 +539,13 @@ export default { }); }, checkArea() { - let i = 0; - this.shopCarList.forEach((item) => { - if (item.isSelected) { - i++; - } - }); - this.isTo = i; + // let i = 0; + // this.shopCarList.forEach((item) => { + // if (item.isSelected) { + // i++; + // } + // }); + // this.isTo = i; let arr = []; this.shopCarList.forEach((item) => { item.shoppingCartList.forEach((ctem) => { @@ -630,6 +635,13 @@ export default { }); }); }, + initCarList() { + this.shopCarList = [] + this.goodsCheck = [] + this.totalPrice = 0 + this.totalAchive = 0 + this.num = 0 + }, getCarList() { api.getShopping().then((res) => { res.data.forEach((item) => {