guhongwei před 4 roky
rodič
revize
01aa2dfbc8
1 změnil soubory, kde provedl 30 přidání a 14 odebrání
  1. 30 14
      src/views/userCenter/productInfo/part/stay.vue

+ 30 - 14
src/views/userCenter/productInfo/part/stay.vue

@@ -60,8 +60,8 @@
           <el-pagination
             @current-change="handleCurrentChange"
             :current-page="currentPage"
-            layout="total,  prev, pager, next, jumper"
-            :total="pastTotal"
+            layout="total, prev, pager, next, jumper"
+            :total="total"
             :page-size="pageSize"
           >
           </el-pagination>
@@ -88,6 +88,7 @@ import achiDetail from '@/views/market/detail/achiDetail.vue';
 import busiDetail from '@/views/market/detail/busiDetail.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: marketproduct } = createNamespacedHelpers('marketproduct');
+import _ from 'lodash';
 export default {
   name: 'stay',
   props: {},
@@ -98,11 +99,11 @@ export default {
   },
   data: function() {
     return {
-      list: [],
-      pastTotal: 0,
-      currentPage: 0,
+      currentPage: 1,
       pageSize: 6,
-      skip: '',
+      origin: [],
+      list: [],
+      total: 0,
       // 信息预览
       type: '0',
       dialogVisible: false,
@@ -110,10 +111,12 @@ export default {
       displayBtn: false,
       // 信息显示
       detailInfo: {},
+      // 请求数据
+      newDataList: [],
     };
   },
-  created() {
-    this.searchInfo();
+  async created() {
+    await this.searchInfo();
   },
   methods: {
     ...marketproduct({ productList: 'query', columnInfo: 'fetch', marketcerate: 'create', productdeltet: 'delete', upup: 'update' }),
@@ -121,12 +124,12 @@ export default {
     async searchInfo({ skip = 0, limit = 6, ...info } = {}) {
       skip = this.skip;
       let userid = this.user.uid;
-      const res = await this.productList({ skip, limit, status: 2, userid, ...info });
-      const resTwo = await this.productList({ skip, limit, status: 3, userid, ...info });
+      const res = await this.productList({ skip, status: 2, userid, ...info });
+      const resTwo = await this.productList({ skip, status: 3, userid, ...info });
       var newData = res.data.concat(resTwo.data);
       if (newData.length != 0) {
-        this.$set(this, `list`, newData);
-        this.$set(this, `pastTotal`, newData.length);
+        this.$set(this, `newDataList`, newData);
+        this.$set(this, `total`, newData.length);
       }
     },
     // 预览
@@ -169,9 +172,11 @@ export default {
         this.$message.error('信息删除失败');
       }
     },
+    search(page = 1) {
+      this.$set(this, `list`, this.origin[page - 1]);
+    },
     handleCurrentChange(currentPage) {
-      this.$set(this, `skip`, (currentPage - 1) * this.pageSize);
-      this.searchInfo();
+      this.search(currentPage);
     },
   },
   computed: {
@@ -180,6 +185,17 @@ export default {
       return `${this.$route.meta.title}`;
     },
   },
+  watch: {
+    newDataList: {
+      immediate: true,
+      deep: true,
+      handler(val) {
+        console.log(val);
+        if (val && val.length > 0) this.$set(this, `origin`, _.chunk(val, this.pageSize));
+        this.search();
+      },
+    },
+  },
   metaInfo() {
     return { title: this.$route.meta.title };
   },