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
});
}
},