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

130 lines
2.7 KiB

5 years ago
// subpages/understandJs/pages/delicious/delicious.js
const api = require("../../../../utils/understandJs")
5 years ago
Page({
/**
* 页面的初始数据
*/
data: {
5 years ago
pageIndex: 1,
pageSize: 10,
noticelist: [],
nodata: false,
loadMoreType: "none",
5 years ago
loadMoreVisible: false,
noticeCategory: "",
5 years ago
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
5 years ago
this.setData({
noticeCategory:options.modulecode
})
if(options.modulecode == 'notice_taste'){
wx.setNavigationBarTitle({
title: '锦水味道'
})
}else if(options.modulecode == 'notice_jssq'){
wx.setNavigationBarTitle({
title: '锦水社区'
})
}
5 years ago
this.noticelist();
},
noticelist () {
5 years ago
let that = this;
let params = {
pageIndex: that.data.pageIndex,
pageSize: that.data.pageSize,
noticeCategory: that.data.noticeCategory
}
api.noticelist(params).then(function (res) { //了解锦水-模块管理接口
console.log(JSON.stringify(res))
that.setData({
noticelist: that.data.noticelist.concat(res.data),
loadMoreType: res.data.length === that.data.pageSize ? "loading" : "none",
5 years ago
loadMoreVisible: res.data.length === that.data.pageSize ? false : true
})
if (that.data.noticelist.length == 0) {//没有值
that.setData({
nodata: true,
loadMoreType: "none",
5 years ago
loadMoreVisible: false,
})
}
}).catch(err => {
that.setData({
noticelist: [],
nodata: true,
loadMoreType: "none",
5 years ago
loadMoreVisible: false,
})
console.log(err)
})
5 years ago
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
5 years ago
this.setData({
loadMoreVisible: true
})
if (this.data.loadMoreType === "loading") {
5 years ago
this.setData({
pageIndex: this.data.pageIndex + 1,
pageSize: this.data.pageSize,
})
5 years ago
this.noticelist();
5 years ago
}
5 years ago
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
5 years ago
},
//跳转倒详情页面
toDetail (e){
5 years ago
wx.navigateTo({
5 years ago
url: `../noticeDetail/noticeDetail?id=${e.currentTarget.dataset.id}&modulecode=${this.data.noticeCategory}`
5 years ago
})
5 years ago
}
})