锦水居民端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

43 lines
981 B

const api = require('../../../../utils/api')
import { getTimestamp } from '../../../../utils/common'
Page({
data: {
loadMoreType: 'none',
loadMoreVisible: false,
newsList: [],
pageNo: 1,
pageSize: 10,
},
onLoad () {
this.getNewsList()
},
onReachBottom () {
this.setData({
loadMoreVisible: true
})
if (this.data.loadMoreType === 'loading') {
this.data.pageNo += 1
this.getNewsList()
}
},
getNewsList: function() {
let that = this
let para = {
pageIndex: this.data.pageNo,
pageSize: this.data.pageSize,
timestamp: getTimestamp()
}
api.newsList(para).then(function(res) {
that.setData({
first: false,
newsList: that.data.newsList.concat(res.data),
loadMoreType: res.data.length === that.data.pageSize ? 'loading' : 'none',
})
}).catch(() => {
that.setData({
loadMoreType: 'none',
newsList: []
})
})
},
})