微信小程序组件 下拉刷新
<!-- &&底部加载 -->
<view class='page-add-data flexca'>
<text>{{pageTottomText}}</text>
</view>
/*加载 ---------------- */
.page-add-data{
width: 100%;
height: 40rpx;
color: #666;
font-size: 24rpx;
padding-bottom: 20rpx;
}
JS-------------------------
// 底部加载信息
pageTottomText: '',
pageN:2,
onReachBottom: function () {
let textCity = this.data.textCity;
let sexC = this.data.sexC;
this.setData({
pageTottomText: ''
});
let that = this;
let pageN = this.data.pageN;
let lists = this.data.lists;
// console.log(pageN)
that.setData({
pageTottomText: getApp().globalData.addText,
});
wx.request({
url: app.globalData.hpUrl + 'queryUsers',
data: {
census: textCity,
sex: sexC,
page: pageN
},
success: function (res) {
var arr = [];
// console.log(res.data)
var result = res.data;
//----------------------------------------------
// 判断分页
if (result.length != 0) {
pageN += 1;
that.setData({
pageN: pageN
});
//----------------------------------------------
setTimeout(function () {
lists= lists.concat(result)
// console.log(lists)
that.setData({
lists: lists
});
}, 1000);
//----------------------------------------------
} else {
that.setData({
pageTottomText: getApp().globalData.endText,
});
}
//----------------------------------------------
}
})
},