Browse Source

贞达市政小程序代码增加分页功能

wang_xy 2 năm trước cách đây
mục cha
commit
8b527961e1
2 tập tin đã thay đổi với 77 bổ sung4 xóa
  1. 37 2
      pages/historyConstruction/historyConstruction.vue
  2. 40 2
      pages/noLogin/My.vue

+ 37 - 2
pages/historyConstruction/historyConstruction.vue

@@ -79,6 +79,10 @@
 				houseName: '',
 				pop: false,
 				kgName: '展开搜索',
+				params: {
+					pageNum: 1,
+					pageSize: 10,
+				},
 			}
 		},
 		onShow() {
@@ -86,16 +90,47 @@
 			this.getListAll();
 			this.select();
 		},
+		onReachBottom() {
+			this.getNextListFn()
+		},
+		onPullDownRefresh() {
+			this.getListAll();
+			setTimeout(function () {
+				uni.stopPullDownRefresh();
+			}, 1000);
+		},
 		methods: {
 			getListAll() {
 				service.getListAll({serviceType: this.show,
 				areaName:this.areaName,
 				buildingName:this.buildingName,
 				unitName:this.unitName,
-				houseName:this.houseName}).then(res => {
-					this.list = res
+				houseName:this.houseName,
+				pageSize: 10,
+				pageNum: 1,
+				}).then(res => {
+					this.list = res.records;
+					that.total = res.total || 0;
+					that.params.pageNum = res.current + 1;
 				})
 			},
+			getNextListFn(){
+				if (this.list.length < this.total) {
+					service.getListAll({serviceType: this.show,
+				areaName:this.areaName,
+				buildingName:this.buildingName,
+				unitName:this.unitName,
+				houseName:this.houseName,
+				pageSize: this.params.pageSize,
+				pageNum: this.params.pageNum,
+				}).then(response => {
+						that.params.pageNum = response.current + 1
+						response.records.forEach(item =>{
+							that.list.push(item)
+						})
+					})
+				}
+			},
 			gotopage(url) {
 				uni.navigateTo({
 					url

+ 40 - 2
pages/noLogin/My.vue

@@ -28,6 +28,7 @@
 					</view>
 				</view>
 			</view>
+			<view class="main-list-icon"></view>
 		</view>
 	</view>
 
@@ -40,6 +41,10 @@
 			return {
 				list:[],
 				name:'',
+				params: {
+					pageNum: 1,
+					pageSize: 10,
+				},
 			}
 		},
 		onLoad(e) {
@@ -49,12 +54,45 @@
 			this.address = e.address;
 			this.getListAll();
 		},
+		onReachBottom() {
+			this.getNextListFn()
+		},
+		onPullDownRefresh() {
+			this.getListAll();
+			setTimeout(function () {
+				uni.stopPullDownRefresh();
+			}, 1000);
+		},
 		methods:{
 			getListAll() {
-				service.getListAll({serviceType: this.id}).then(res => {
-					this.list = res
+				let that = this;
+				let params ={
+					serviceType: this.id,
+					pageSize: 10,
+					pageNum: 1,
+				}
+				service.getListAll(params).then(res => {
+					this.list = res.records;
+					that.total = res.total || 0;
+					that.params.pageNum = res.current + 1;
 				})
 			},
+			getNextListFn() {
+				let that = this;
+				let params ={
+					serviceType: this.id,
+					pageSize: this.params.pageSize,
+					pageNum: this.params.pageNum,
+				}
+				if (this.list.length < this.total) {
+					service.getListAll(params).then(response => {
+						that.params.pageNum = response.current + 1
+						response.records.forEach(item =>{
+							that.list.push(item)
+						})
+					})
+				}
+			},
 			gotopage(item){
 				uni.navigateTo({
 					url:`/pages/noLogin/Myphoto?id=${item.id}`,