<view class="container">
<view wx:if="{{isUpper}}" class="lower-con">数据已更新</view>
<!-- 问题展示开始 -->
<block wx:for="{{lists}}" wx:key="idx">
</block>
<!-- 问题展示结束 -->
<view wx:if="{{isLower}}" class="lower-con">没有多余的消息了</view>
</view>
Page({
data: {
lists:[],
current: 1,
isUpper: false,
isLower: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getData()
},
//获取数据
getData(){
const data = {}
const _this = this
app.POST('lists', data, function (res) {
if (res.data.errno === 0) {
if (_this.data.current > 1 && res.data.data.data.length === 0) {
_this.setData({
isLower: true
})
} else {
_this.setData({
lists: res.data.data.data
})
}
} else {
wx.showToast({
title: '网络错误',
icon: 'warn',
duration: 2000
})
}
})
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
const _this = this
if (_this.data.current == 1){
var timeIn = setTimeout(function () {
_this.setData({
isUpper: true
})
}, 3000)
var timeOut = setTimeout(function () {
_this.setData({
isUpper: false
})
}, 6000)
}else{
_this.setData({
current: _this.data.current - 1
})
this.getData()
}
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.setData({
current: this.data.current + 1
})
this.getData()
const _this = this
var timeOut = setTimeout(function () {
_this.setData({
isLower: false
})
}, 6000)
}
})