From fe23c26671c2465a84ee91c93857ddb1bcef227f Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Tue, 15 Jun 2021 22:56:43 +0800
Subject: [PATCH] 1.巡逻路线文本上下移动调整 2.资讯列表超过10条数据时,底部上拉加载更多数据

---
 pages/article/article.vue |  146 ++++++++++++++++++++----------------------------
 1 files changed, 62 insertions(+), 84 deletions(-)

diff --git a/pages/article/article.vue b/pages/article/article.vue
index 8437b4c..9bdfa4e 100644
--- a/pages/article/article.vue
+++ b/pages/article/article.vue
@@ -1,19 +1,9 @@
 <template>
 	<view class="advisory-big">
-		
-		 <!-- <view
-			ref="k-scroll-view"
-			:refreshType="refreshType"
-			:refreshTip="refreshTip"
-			:loadTip="loadTip"
-			:loadingTip="loadingTip"
-			:emptyTip="emptyTip"
-			:touchHeight="touchHeight"
-			:height="height"
-			:bottom="bottom"
-			:autoPullUp="autoPullUp"
-			@onPullDown="handlePullDown"
-			@onPullUp="handleLoadMore"> -->
+			<!-- 顶部下拉刷新 -->
+			<view v-show="isFlash">
+				<uni-load-more :status="loadStatus" ></uni-load-more>
+			</view>
 			<view  v-for="i in data" class="advisory-model" @click="goDetail(i)">
 				<view class="advisory-left">
 					<view class="advisory-title-top">
@@ -29,63 +19,50 @@
 				</view>
 				
 			</view>
-		<!-- </view> -->
-		<!-- <uni-load-more :status="status" :content-text="contentText"/> -->
-		
-		
+			<!-- loading加载提示处 -->
+			<view v-show="isLoadMore">
+				<uni-load-more :status="loadStatus" ></uni-load-more>
+		    </view>
 	</view>
 </template>
 
 <script>
-	// import kScrollView from '@/components/k-scroll-view/k-scroll-view.vue';
 	export default{
-		// components: {
-		//     kScrollView
-		// },
 		data(){
 			return {
 				// pathUrl:"http://localhost:89/",
 				pathUrl:"http://s16s652780.51mypc.cn/api/blade-jfpts",
-				// refreshType: 'custom',
-				// refreshTip: '正在下拉',
-				// loadTip: '获取更多数据',
-				// loadingTip: '正在加载中...',
-				// emptyTip: '--我是有底线的--',
-				// touchHeight: 50,
-				// height: 0,
-				// bottom: 50,
-				// autoPullUp: true,
-				// stopPullDown:true, // 如果为 false 则不使用下拉刷新,只进行上拉加载
-				// status: 'more',
-				// statusTypes: [{
-				// 	value: 'more',
-				// 	text: '加载前',
-				// 	checked: true
-				// }, {
-				// 	value: 'loading',
-				// 	text: '加载中',
-				// 	checked: false
-				// }, {
-				// 	value: 'noMore',
-				// 	text: '没有更多',
-				// 	checked: false
-				// }],
-				// contentText: {
-				// 	contentdown: '下拉查看更多',
-				// 	contentrefresh: '加载中',
-				// 	contentnomore: '没有更多'
-				// },
+				page:1,
+				pagesize:10,
+				loadStatus:'loading',  //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
+				isLoadMore:false,  //是否加载中
+				isFlash:false,//是否刷新
 				data:[]
 			}
 		},
 		mounted(){
-			this.getArtcilePageList();
+			// this.getArtcilePageList();
 		},
-		onPullDownRefresh () {			// 下拉刷新事件
-		    console.log('触发下拉刷新了')
-		    // 一些列操作
-		    uni.stopPullDownRefresh()		// 结束当前刷新事件
-		  },
+		//上拉加载更多
+		onReachBottom(){  //上拉触底函数
+			if(!this.isLoadMore){  //此处判断,上锁,防止重复请求
+				this.isLoadMore=true
+				this.page+=1
+				this.getArtcilePageList()
+			}
+		},
+		//下拉刷新
+		onPullDownRefresh() {
+			// console.log("上拉了!....");
+			if(!this.isFlash){  //此处判断,上锁,防止重复请求
+				this.isFlash=true;
+				this.page =1;
+				this.getArtcilePageList();
+			}
+		},
+		onLoad() {
+		    this.getArtcilePageList();
+		},
 		methods:{
 			//去跳转详情页面
 			goDetail(e){
@@ -116,36 +93,37 @@
 				uni.request({
 					url: that.pathUrl+'/article/article/page',
 					method:'GET',
+					data:{
+						current:this.page,
+						size: this.pagesize
+					},
 					success: (res) => {
-						that.data = res.data.data.records;
+						if(res.data.code==200){
+							if(res.data.data.records){
+								//如果总数小于pageSize,不做其他操作
+								if(res.data.data.total<this.pagesize){
+									that.data = res.data.data.records;
+								}else{
+									if(res.data.data.records.length<this.pagesize){
+										//如果数量小于分页数量,则为最后一页
+										this.isLoadMore=true;
+										this.loadStatus='nomore';
+									}else{
+										this.isLoadMore=false
+									}
+									res.data.data.records.forEach((item)=>{
+										that.data.push(item);
+									})
+								}
+							}else{
+								this.isLoadMore=true;
+								this.loadStatus='nomore';
+							}
+						}
+						
 					}
 				});
-			},
-			//下拉获取更多
-			// handlePullDown(stopLoad) {
-			// 	this.data = [];
-			// 	for (var i = 0; i < 10; i++) {
-			// 		this.data.push(i);
-			// 	}
-			// 	stopLoad ? stopLoad() : '';
-			// },
-			// //上拉加载
-			// handleLoadMore(stopLoad) {
-			// 	const size = this.data.length;
-			// 	if (size < 100) {
-			// 		const data = [];
-			// 		for (var i = 0; i < 10; i++) {
-			// 			data.push(size + i);
-			// 		}
-			// 		this.data = this.data.concat(data);
-			// 		stopLoad ? stopLoad() : '';
-			// 	} else {
-			// 		stopLoad ? stopLoad({ isEnd: true }) : '';
-			// 	}
-			// },
-			// handleGoTop() {
-			// 	this.$refs['k-scroll-view'].goTop();
-			// }
+			}
 		}
 	}
 </script>

--
Gitblit v1.9.3