wangzhe 1 год назад
Родитель
Сommit
770aac764d
1 измененных файлов с 48 добавлено и 1 удалено
  1. 48 1
      pages/cooperative/cooperative.vue

+ 48 - 1
pages/cooperative/cooperative.vue

@@ -18,6 +18,7 @@
             </view>
             <em class="iconfont icon-xiangyoujiantou"></em>
         </view>
+        <uni-load-more :status="status" :content-text="contentText"/>
         <uni-fab ref="fab" horizontal="right" vertical="bottom"
                  @fabClick="handleAdd()"/>
     </view>
@@ -28,6 +29,21 @@ import { getList, getDetails } from '@/api/cooperative/cooperative';
 export default {
     data() {
         return {
+            // 查询参数
+            queryParams: {
+                pageNum: 1,
+                pageSize: 15,
+                id: null,
+                status:"1",
+            },
+            // 加载更多
+            status: 'more',
+            contentText: {
+                contentdown: '查看更多',
+                contentrefresh: '加载中',
+                contentnomore: '------------------我是有底线的------------------'
+            },
+            // 列表数据
             list: [
                 {
                     name:"-",
@@ -38,6 +54,27 @@ export default {
                 }
             ],
         };
+    },
+    onPullDownRefresh() {
+        console.log("onPullDownRefresh  "+this.queryParams.pageNum)
+        this.queryParams.pageNum = 1;
+        this.list = [];
+        this.getList()
+    },
+    //上拉加载
+    onReachBottom(){
+        let pageNum = this.queryParams.pageNum;
+        let pageSize = this.queryParams.pageSize;
+        let total = this.total;
+        if(pageNum*pageSize >= total){
+            uni.showToast({
+                title:'暂无更多数据'
+            });
+            return;
+        } else {
+            this.queryParams.pageNum += 1;
+            this.getList()
+        }
     }
     /**
      * 生命周期函数--监听页面加载
@@ -56,7 +93,17 @@ export default {
         getList(type) {
             this.loading = true;
             getList().then(response => {
-                this.list = response.rows;
+                if (this.queryParams.pageNum === 1) {
+                    this.list = response.rows;
+                } else {
+                    this.list = this.list.concat(response.rows);
+                }
+                // 判断是否还有更多数据
+                if (response.rows.length < this.queryParams.pageSize) {
+                    this.status = 'noMore'; // 没有更多数据
+                } else {
+                    this.status = 'more'; // 还有更多数据
+                }
             });
         },
         /** 查询详情 */