锦水居民端小程序
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.

74 lines
1.6 KiB

5 years ago
// subpages/understandJs/pages/sclerotia/sclerotia.js
const api = require("../../../../utils/understandJs")
5 years ago
Page({
/**
* 页面的初始数据
*/
data: {
5 years ago
pageIndex: 1,
pageSize: 10,
sclerotialist: [],
5 years ago
nodata: false,
loadMoreType: "none",
5 years ago
loadMoreVisible: false,
5 years ago
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getSclerotiaList()
5 years ago
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.setData({
loadMoreVisible: true
})
if (this.data.loadMoreType === 'loading') {
this.setData({
pageIndex: this.data.pageIndex + 1,
pageSize: this.data.pageSize,
})
this.getSclerotiaList()
5 years ago
}
},
getSclerotiaList: function() {
let that = this
let para = {
pageIndex: this.data.pageIndex,
pageSize: this.data.pageSize,
noticeCategory: 'notice_yh'
5 years ago
}
api.noticelist(para).then(function(res) {
5 years ago
that.setData({
sclerotialist: that.data.sclerotialist.concat(res.data),
5 years ago
loadMoreType: res.data.length === that.data.pageSize ? 'loading' : 'none',
})
if (that.data.sclerotialist.length == 0) {
5 years ago
that.setData({
nodata: true,
loadMoreType: 'none',
loadMoreVisible: false
5 years ago
})
}
}).catch(() => {
5 years ago
that.setData({
nodata: true,
loadMoreType: "none",
5 years ago
loadMoreVisible: false,
sclerotialist: []
5 years ago
})
})
},
5 years ago
toDetail (e) {
wx.navigateTo({
url: '../noticeDetail/noticeDetail?modulecode=notice_yh&id=' + e.currentTarget.dataset.id
5 years ago
})
5 years ago
}
})