yuanyuan hace 3 años
padre
commit
a5c0ff3d50
Se han modificado 1 ficheros con 29 adiciones y 4 borrados
  1. 29 4
      src/views/user/ShoppingCart.vue

+ 29 - 4
src/views/user/ShoppingCart.vue

@@ -7,7 +7,7 @@
                         @click="$router.back()">
                     购物车
                     <div class="shopping_cart_top_one_btn" v-if="!showDelete" @click="showDelete = true">管理</div>
-                    <div class="shopping_cart_top_one_btns" v-else @click="showDelete = false">完成</div>
+                    <div class="shopping_cart_top_one_btns" v-else @click="accomplish">完成</div>
                 </div>
                 <div class="shopping_cart_top_two">
                     <div class="shopping_cart_top_two_con" :class="{ active: active === 'ALL' }"
@@ -145,6 +145,18 @@ export default {
         changeActive(title) {
             this.active = title
             this.showDelete = false
+            this.checkAllStatus = false
+            this.price = 0
+            this.totalSettlement = 0
+            this.getList(true)
+        },
+        accomplish() {
+            this.showDelete = false
+            if (this.active == 'SELLOUT') {
+                this.checkAllStatus = false
+                this.totalSettlement = 0
+                this.getList(true)
+            }
         },
         cartExplain() {
         },
@@ -167,6 +179,9 @@ export default {
             }
         },
         settle(index) {
+            if (this.active == 'SELLOUT' && !this.showDelete) {
+                return
+            }
             this.collectionList[index].check = !this.collectionList[index].check
             let newCollectionList = this.collectionList.filter(item => item.check == true)
             if (this.collectionList.length == newCollectionList.length) {
@@ -253,9 +268,19 @@ export default {
                         this.collectionList = [];
                         this.page = 0;
                     }
-                    res.content.forEach(item => {
-                        item.check = false
-                    })
+                    if (this.checkAllStatus) {
+                        let newPrice = Number(this.price)
+                        res.content.forEach(item => {
+                            item.check = true
+                            newPrice += Number(item.price)
+                        })
+                        this.totalSettlement = this.totalSettlement + res.content.length
+                        this.price = newPrice.toFixed(1)
+                    } else {
+                        res.content.forEach(item => {
+                            item.check = false
+                        })
+                    }
                     this.collectionList = [...this.collectionList, ...res.content];
                     this.empty = res.empty;
                     this.loading = false;