panhui 3 gadi atpakaļ
vecāks
revīzija
17eaa6f273

+ 20 - 7
src/main/comos/src/views/product/List.vue

@@ -10,15 +10,13 @@
                 :ellipsis="false"
                 line-width="16"
                 line-height="2"
-                @change="getData(true)"
+                @click-tab="changeTab"
                 :class="{ trans: source == 'TRANSFER' }"
             >
                 <van-tab
                     :title="item.label"
-                    :name="
-                        item.type === 'select' ? (sort === item.value[0] ? item.value[1] : item.value[0]) : item.value
-                    "
-                    :title-class="item.type === 'select' && sort === item.value[0] ? '' : 'asc'"
+                    :name="item.value"
+                    :title-class="item.type === 'select' && sortDes ? sortDes : ''"
                     :key="index"
                     v-for="(item, index) in selectOptions"
                 >
@@ -64,6 +62,7 @@ export default {
             list: [],
             empty: false,
             sort: 'id,desc',
+            sortDes: '',
             type: '',
             source: '',
             minterId: '',
@@ -82,7 +81,7 @@ export default {
                 },
                 {
                     label: '价格',
-                    value: ['price,desc', 'price,asc'],
+                    value: 'price',
                     type: 'select'
                 }
             ],
@@ -106,6 +105,8 @@ export default {
         if (this.$route.query.source) {
             this.source = this.$route.query.source;
             this.salable = true;
+            this.sort = 'price';
+            this.sortDes = 'asc';
         }
 
         if (this.$route.query.minterId) {
@@ -121,7 +122,19 @@ export default {
         }
     },
     methods: {
+        changeTab(info) {
+            this.$nextTick(() => {
+                if (info.name === 'price') {
+                    this.sortDes = this.sortDes == 'desc' ? 'asc' : 'desc';
+                }
+                this.getData(true);
+            });
+        },
         beforeData() {
+            let sort = this.sort;
+            if (sort == 'price') {
+                sort = 'price,' + this.sortDes;
+            }
             return {
                 query: {
                     type: this.type,
@@ -131,7 +144,7 @@ export default {
                     minterId: this.minterId,
                     salable: this.salable || ''
                 },
-                sort: this.sort === 'id,desc' ? this.sortOptions[this.title] || this.sort : this.sort
+                sort: sort === 'id,desc' ? this.sortOptions[this.title] || sort : sort
             };
         },
         goSearch() {

+ 20 - 7
src/main/nine-space/src/views/product/List.vue

@@ -11,14 +11,12 @@
                 :ellipsis="false"
                 line-width="16"
                 line-height="2"
-                @change="getData(true)"
+                @click-tab="changeTab"
             >
                 <van-tab
                     :title="item.label"
-                    :name="
-                        item.type === 'select' ? (sort === item.value[0] ? item.value[1] : item.value[0]) : item.value
-                    "
-                    :title-class="item.type === 'select' && sort === item.value[0] ? '' : 'asc'"
+                    :name="item.value"
+                    :title-class="item.type === 'select' && sortDes ? sortDes : ''"
                     :key="index"
                     v-for="(item, index) in selectOptions"
                 >
@@ -60,6 +58,7 @@ export default {
             list: [],
             empty: false,
             sort: 'soldOut;id,desc',
+            sortDes: '',
             type: '',
             source: '',
             minterId: '',
@@ -78,7 +77,7 @@ export default {
                 },
                 {
                     label: '价格',
-                    value: ['price,desc', 'price,asc'],
+                    value: 'price',
                     type: 'select'
                 }
             ],
@@ -100,6 +99,8 @@ export default {
         if (this.$route.query.source) {
             this.source = this.$route.query.source;
             this.salable = true;
+            this.sort = 'price';
+            this.sortDes = 'asc';
         }
 
         if (this.$route.query.minterId) {
@@ -115,7 +116,19 @@ export default {
         }
     },
     methods: {
+        changeTab(info) {
+            this.$nextTick(() => {
+                if (info.name === 'price') {
+                    this.sortDes = this.sortDes == 'desc' ? 'asc' : 'desc';
+                }
+                this.getData(true);
+            });
+        },
         beforeData() {
+            let sort = this.sort;
+            if (sort == 'price') {
+                sort = 'price,' + this.sortDes;
+            }
             return {
                 query: {
                     type: this.type,
@@ -125,7 +138,7 @@ export default {
                     minterId: this.minterId,
                     salable: this.salable || ''
                 },
-                sort: this.sortOptions[this.title] || this.sort
+                sort: this.sortOptions[this.title] || sort
             };
         },
         goSearch() {