panhui 4 лет назад
Родитель
Сommit
17a5d0c219

+ 9 - 2
src/App.vue

@@ -50,8 +50,15 @@ export default {
         //     });
     },
     methods: {
-        setKeeps(keeps) {
-            console.log(keeps);
+        setKeeps(keep = [], isAdd = true) {
+            let keeps = [...this.keeps];
+            if (isAdd) {
+                keeps = [...keeps, ...keep];
+            } else {
+                keeps = keeps.filter(item => {
+                    return !keep.includes(item);
+                });
+            }
             this.keeps = keeps;
         },
         changeScroll(scrollTop) {

+ 1 - 1
src/views/Discover.vue

@@ -283,7 +283,7 @@ export default {
             this.setKeeps(['index', 'discover']);
         } else {
             this.scrollTop = 0;
-            this.setKeeps([]);
+            this.setKeeps(['index', 'discover'], false);
         }
         next();
     }

+ 2 - 2
src/views/asset/Search.vue

@@ -118,10 +118,10 @@ export default {
     beforeRouteLeave(to, from, next) {
         if (!to.meta.menuPage) {
             this.scrollTop = this.scrollWrapper.value.scrollTop;
-            this.setKeeps(['productSearch']);
+            this.setKeeps(['assetSearch']);
         } else {
             this.scrollTop = 0;
-            this.setKeeps([]);
+            this.setKeeps(['assetSearch'], false);
         }
         next();
     }

+ 19 - 2
src/views/creator/List.vue

@@ -42,8 +42,9 @@
 import CreatorInfo from '../../components/creator/CreatorInfo.vue';
 import list from '../../mixins/list';
 export default {
+    name: 'creatorList',
     components: { CreatorInfo },
-    inject: ['bar'],
+    inject: ['bar', 'setKeeps', 'scrollWrapper', 'changeScroll'],
     mixins: [list],
     data() {
         return {
@@ -69,7 +70,8 @@ export default {
                     type: 'select'
                 }
             ],
-            url: '/user/all'
+            url: '/user/all',
+            scrollTop: 0
         };
     },
     methods: {
@@ -79,6 +81,21 @@ export default {
                 sort: this.sort
             };
         }
+    },
+    activated() {
+        this.$nextTick(() => {
+            this.changeScroll(this.scrollTop);
+        });
+    },
+    beforeRouteLeave(to, from, next) {
+        if (!to.meta.menuPage) {
+            this.scrollTop = this.scrollWrapper.value.scrollTop;
+            this.setKeeps(['creatorList']);
+        } else {
+            this.scrollTop = 0;
+            this.setKeeps(['creatorList'], false);
+        }
+        next();
     }
 };
 </script>

+ 2 - 2
src/views/creator/Search.vue

@@ -89,10 +89,10 @@ export default {
     beforeRouteLeave(to, from, next) {
         if (!to.meta.menuPage) {
             this.scrollTop = this.scrollWrapper.value.scrollTop;
-            this.setKeeps(['productSearch']);
+            this.setKeeps(['creatorSearch']);
         } else {
             this.scrollTop = 0;
-            this.setKeeps([]);
+            this.setKeeps(['creatorSearch'], false);
         }
         next();
     }

+ 20 - 4
src/views/product/List.vue

@@ -6,7 +6,6 @@
                 <img src="@assets/icon-sosuo.png" alt="" @click="goSearch" class="search" />
             </div>
             <van-tabs
-                v-if="!title"
                 v-model:active="sort"
                 :ellipsis="false"
                 line-width="16"
@@ -56,8 +55,9 @@ import ProductInfo from '../../components/product/productInfo.vue';
 import product from '../../mixins/product';
 import list from '../../mixins/list';
 export default {
+    name: 'productList',
     components: { ProductInfo },
-    inject: ['bar'],
+    inject: ['bar', 'setKeeps', 'scrollWrapper', 'changeScroll'],
     mixins: [product, list],
     data() {
         return {
@@ -88,7 +88,8 @@ export default {
             ],
             url: '/collection/all',
             title: '',
-            salable: false
+            salable: false,
+            scrollTop: 0
         };
     },
     computed: {
@@ -123,7 +124,7 @@ export default {
                     minterId: this.minterId,
                     salable: this.salable || ''
                 },
-                sort: this.sortOptions[this.title] || this.sort
+                sort: this.sort === 'id,desc' ? this.sortOptions[this.title] || this.sort : this.sort
             };
         },
         goSearch() {
@@ -136,6 +137,21 @@ export default {
             }
             this.$router.push(url);
         }
+    },
+    activated() {
+        this.$nextTick(() => {
+            this.changeScroll(this.scrollTop);
+        });
+    },
+    beforeRouteLeave(to, from, next) {
+        if (!to.meta.menuPage) {
+            this.scrollTop = this.scrollWrapper.value.scrollTop;
+            this.setKeeps(['productList']);
+        } else {
+            this.scrollTop = 0;
+            this.setKeeps(['productList'], false);
+        }
+        next();
     }
 };
 </script>

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

@@ -112,7 +112,7 @@ export default {
             this.setKeeps(['productSearch']);
         } else {
             this.scrollTop = 0;
-            this.setKeeps([]);
+            this.setKeeps(['productSearch'], false);
         }
         next();
     }