移动端下拉分页的实现

1、在pages.js中开启下拉效果
“enablePullDownRefresh”: true

	{
		"path": "pages/inventory/inventoryTask/SupervisorAuditSheet",
			"style": {
				"navigationBarTitleText": "监盘人审核",
				"enablePullDownRefresh": true,
				"navigationStyle": "custom"
			}
	}, {
		"path": "pages/inventory/inventoryTask/units",
		"style": {
			"navigationBarTitleText": "使用单位",
			"enablePullDownRefresh": true,
			"navigationStyle": "custom"
		}
	}

2、使用 onReachBottom()来实现下拉

export default {
	data() {
		return {
			// 分页
			page: {
				pageSize: 10,
				pageNum: 1,
			},
	      }
	   }
	}
/* 下拉加载 */
async onReachBottom() {
    //this.statusList[this.tabsCurrent + 1] 当前处于那个状态下的数据
	// 状态资产总数
	let checkeAssetTotal = this.statusList[this.tabsCurrent + 1].number;
	// 当前显示资产长度
	const currentShowDataLength = this.assetItemInfo.length;
	// 资产总数大于当前显示分页数据 分页请求
	if (checkeAssetTotal > currentShowDataLength) {
		this.page.pageNum = this.page.pageNum + 1;
		uni.showLoading({
			title: '数据加载中',
		});
		//这里根据自己接口。
		const data = {
			page: this.page,
			mid: this.savedId,
			//状态
			planFlag: this.statusList[this.tabsCurrent + 1].text,
			//部门id
			shouldDepartId: this.filteredData[this.deptCurrent].shouldDepartId,
		}
		const res = await jobDetailSecond(data); //接口调用
		uni.hideLoading();//关闭Loading
		//在每次接口请求时、把数据拼接在后面
		this.assetItemInfo = this.assetItemInfo.concat(res.rows);
	} else {
		// 数据已全部加载完毕,显示提示消息
		uni.showToast({
			title: '已加载全部数据',
			icon: 'success',
			duration: 2000
		});
	}
},
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值