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) => {