Преглед изворни кода

【我的作品】作品总数显示的不应是列表长度而应是真正的总数。

任一存 пре 4 година
родитељ
комит
1b30e14c29
1 измењених фајлова са 11 додато и 4 уклоњено
  1. 11 4
      src/views/material/works/index.vue

+ 11 - 4
src/views/material/works/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="works con">
     <div class="tab">
-      <span>我的作品 {{list.length > 0 ? `(${list.length})`:''}}</span>
+      <span>我的作品 {{workTotalNum !== undefined ? `(${workTotalNum})`:''}}</span>
       <div class="tab-r">
          <div class="filter">
           <div :class="{active:searchKey}">
@@ -98,6 +98,7 @@ export default {
     return {
       config,
       list:[],
+      workTotalNum: undefined,
       hasMoreData: true,
       isRequestingMoreData: false,
       searchKey:'',
@@ -179,6 +180,9 @@ export default {
                     }
                     this.isRequestingMoreData = false
                     this.lastestUsedSearchKey = lastestUsedSearchKey
+                    if (!lastestUsedSearchKey) {
+                      this.workTotalNum = data.data.total
+                    }
                     // TODO: 这是干啥呢?
                     this.$nextTick(()=>{
                       this.$bus.emit('refreshTips')
@@ -195,7 +199,7 @@ export default {
     },
     requestMoreData() {
       this.isRequestingMoreData = true
-      const thisTimeSearchKey = this.searchKey
+      const lastestUsedSearchKey = this.searchKey
       getWorksList(
         {
           pageNum: Math.floor(this.list.length / config.PAGE_SIZE) + 1,
@@ -208,14 +212,17 @@ export default {
             this.hasMoreData = false
           }
           this.isRequestingMoreData = false
-          this.lastestUsedSearchKey = thisTimeSearchKey
+          this.lastestUsedSearchKey = lastestUsedSearchKey
+          if (!lastestUsedSearchKey) {
+            this.workTotalNum = data.data.total
+          }
           // TODO: 这是干啥呢?
           this.$nextTick(()=>{
             this.$bus.emit('refreshTips')
           })
         },
         () => {
-          this.lastestUsedSearchKey = thisTimeSearchKey
+          this.lastestUsedSearchKey = lastestUsedSearchKey
           this.isRequestingMoreData = false
         }
       );