panhui 4 years ago
parent
commit
776d2bb281
2 changed files with 16 additions and 3 deletions
  1. 8 2
      src/views/product/List.vue
  2. 8 1
      src/views/product/Search.vue

+ 8 - 2
src/views/product/List.vue

@@ -10,7 +10,7 @@
                 :ellipsis="false"
                 line-width="16"
                 line-height="2"
-                @change="getData(true)"
+                @click-tab="getData(true)"
                 :class="{ trans: source == 'TRANSFER' }"
             >
                 <van-tab
@@ -63,6 +63,7 @@ export default {
         return {
             list: [],
             empty: false,
+            beforeSort: '',
             sort: 'id,desc',
             type: '',
             source: '',
@@ -141,13 +142,18 @@ export default {
     activated() {
         this.$nextTick(() => {
             this.changeScroll(this.scrollTop);
+            setTimeout(() => {
+                this.sort = this.beforeSort;
+            }, 1000);
         });
     },
     beforeRouteLeave(to, from, next) {
-        if (!to.meta.menuPage) {
+        if (to.path === '/productDetail') {
+            this.beforeSort = this.sort;
             this.scrollTop = this.scrollWrapper.value.scrollTop;
             this.setKeeps(['productList']);
         } else {
+            this.beforeSort = '';
             this.scrollTop = 0;
             this.setKeeps(['productList'], false);
         }

+ 8 - 1
src/views/product/Search.vue

@@ -22,7 +22,7 @@
                 :ellipsis="false"
                 line-width="16"
                 line-height="2"
-                @change="getData(true)"
+                @click-tab="getData(true)"
                 :class="{ trans: source == 'TRANSFER' }"
             >
                 <van-tab
@@ -95,6 +95,7 @@ export default {
     data() {
         return {
             list: [],
+            beforeSort: '',
             empty: false,
             search: '',
             stiky: null,
@@ -165,13 +166,19 @@ export default {
     activated() {
         this.$nextTick(() => {
             this.changeScroll(this.scrollTop);
+
+            setTimeout(() => {
+                this.sort = this.beforeSort;
+            }, 1000);
         });
     },
     beforeRouteLeave(to, from, next) {
         if (to.path === '/productDetail') {
+            this.beforeSort = this.sort;
             this.scrollTop = this.scrollWrapper.value.scrollTop;
             this.setKeeps(['productSearch']);
         } else {
+            this.beforeSort = '';
             this.scrollTop = 0;
             this.setKeeps(['productSearch'], false);
         }