Просмотр исходного кода

兼职H5 无限刷新问题修复

dxj 6 лет назад
Родитель
Сommit
d985cc7fc5
1 измененных файлов с 16 добавлено и 11 удалено
  1. 16 11
      pages/job/index.vue

+ 16 - 11
pages/job/index.vue

@@ -222,6 +222,7 @@
         loading: false,
         refreshing: false,
         firstLoading: false, //移动端加载loading
+        isLoading: false
       }
     },
     watch: {
@@ -351,20 +352,20 @@
         direction && (p.occupationId = direction) //一级
         workType && (p.workType = workType)
         directionSmall > 0 && (p.directionId = directionSmall)  //耳二级
+        if (this.isLoading) {
+          return
+        }
         this.loading = true
+        this.isLoading = true
         this.$axios.post('/api/recruit/search', p).then(res => {
           if (Number(res.data.status) === 1) {
             let data = res.data.data
             this.page.total = data.total
-            let dataList = data.list || []
-            dataList.forEach(item => {
-              item[ 'successCase' ] = ''
-              if (Array.isArray(item.successful_case)) {
-                let tem = item.successful_case.map(item => item.title)
-                item[ 'successCase' ] = tem.join('、')
-              }
-            })
-            this.dataList = data.list
+            if (this.page.page === 1 || !this.mobile) {
+              this.dataList = [...data.list]
+            } else {
+              this.dataList = [ ...this.dataList, ...data.list]
+            }
             this.page.page += 1
             this.page.current = Number(data.page)
             if (this.page.total <= this.dataList.length) {
@@ -374,7 +375,10 @@
         }).finally(() => {
           this.firstLoading = false
           this.refreshing = false
-          this.loading = false
+          this.isLoading = false
+          this.$nextTick(()=>{
+            this.loading = false
+          })
           console.log("this.finished", this.finished)
         })
       },
@@ -390,10 +394,11 @@
       onRefresh() {
         // 清空列表数据
         this.finished = false;
-        this.loading = true;
+        console.log('onRefresh')
         this.onLoad();
       },
       onLoad() {
+        console.log('onLoad')
         this.getList()
       },
     }