瀏覽代碼

下单刷新

panhui 2 年之前
父節點
當前提交
99c490c91c
共有 3 個文件被更改,包括 20 次插入2 次删除
  1. 5 1
      src/store/index.js
  2. 1 0
      src/views/Submit.vue
  3. 14 1
      src/views/product/PrefixNameList.vue

+ 5 - 1
src/store/index.js

@@ -28,9 +28,13 @@ export default createStore({
         inviteType: 'NORMAL',
         neteaseUser: null,
         riceShare: false,
-        shareRiceId: 0
+        shareRiceId: 0,
+        listRefreash: false
     },
     mutations: {
+        setListRefreash(state, listRefreash) {
+            state.listRefreash = listRefreash;
+        },
         setRiceShare(state, riceShare) {
             state.riceShare = riceShare;
         },

+ 1 - 0
src/views/Submit.vue

@@ -290,6 +290,7 @@ export default {
                 return;
             }
             this.$toast.loading('请不要离开当前页面');
+            this.emitter.emit('listRefreash');
 
             let params = {
                 collectionId: this.collectionId,

+ 14 - 1
src/views/product/PrefixNameList.vue

@@ -86,6 +86,8 @@ import http from '@/plugins/http';
 //获取列表
 import useList from '@/plugins/list';
 import { reject } from 'q';
+import { mapState } from 'vuex';
+import { throwStatement } from '@babel/types';
 export default {
     setup() {
         let beforeData = {
@@ -171,9 +173,16 @@ export default {
     inject: ['setKeeps', 'scrollWrapper', 'changeScroll'],
     data() {
         return {
-            scrollTop: 0
+            scrollTop: 0,
+            isFreash: false
         };
     },
+    mounted() {
+        this.emitter.on('listRefreash', () => {
+            console.log('刷新');
+            this.isFreash = true;
+        });
+    },
     beforeRouteEnter(to, from) {
         fromRoute = from;
     },
@@ -206,11 +215,15 @@ export default {
         }
     },
     activated() {
+        if (this.isFreash) {
+            this.getData(true);
+        }
         this.$nextTick(() => {
             this.changeScroll(this.scrollTop);
         });
     },
     beforeRouteLeave(to, from, next) {
+        this.isFreash = false;
         if (to.name === 'productDetail') {
             this.scrollTop = this.scrollWrapper.scrollTop;
             this.setKeeps(['prefixNameList']);