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.
140 lines
3.0 KiB
140 lines
3.0 KiB
5 years ago
|
// subpages/home/pages/noticeNew/noticeNew.js
|
||
|
const api = require('../../../../utils/understandJs')
|
||
|
Page({
|
||
|
|
||
|
/**
|
||
|
* 页面的初始数据
|
||
|
*/
|
||
|
data: {
|
||
|
pageIndex: 1,
|
||
|
pageSize: 10,
|
||
|
noticeCategory: '5',//模块编码(1-印象,2-味道,5-政策导航最新,6-政策导航最热)
|
||
|
noticelist: [],
|
||
|
selectTab: 'tab1',
|
||
|
nodata: false,
|
||
|
loadMoreType: 'none',
|
||
|
loadMoreVisible: false,
|
||
|
},
|
||
|
/**
|
||
|
* 生命周期函数--监听页面加载
|
||
|
*/
|
||
|
onLoad: function (options) {
|
||
|
this.noticelist();
|
||
|
},
|
||
|
|
||
|
// 加载网格长管辖的网格列表
|
||
|
noticelist() {
|
||
|
let that = this
|
||
|
let params = {
|
||
|
pageIndex: that.data.pageIndex,
|
||
|
pageSize: that.data.pageSize,
|
||
|
noticeCategory: that.data.noticeCategory
|
||
|
}
|
||
|
|
||
|
api.noticelist(params).then(res => {
|
||
|
that.setData({
|
||
|
noticelist: that.data.noticelist.concat(res.data),
|
||
|
loadMoreType: res.data.length === that.data.pageSize ? 'loading' : 'none',
|
||
|
loadMoreVisible: res.data.length === that.data.pageSize ? false : true
|
||
|
})
|
||
|
if (that.data.noticelist.length == 0) {//没有值
|
||
|
that.setData({
|
||
|
nodata: true,
|
||
|
loadMoreType: 'none',
|
||
|
loadMoreVisible: false,
|
||
|
})
|
||
|
}
|
||
|
}).catch(err => {
|
||
|
that.setData({
|
||
|
noticelist: [],
|
||
|
nodata: true,
|
||
|
loadMoreType: 'none',
|
||
|
loadMoreVisible: false,
|
||
|
})
|
||
|
console.log(err)
|
||
|
})
|
||
|
},
|
||
|
|
||
|
// tab 切换
|
||
|
onTabChange(e) {
|
||
|
if (e.currentTarget.dataset.tab == 'tab1') {//最新政策
|
||
|
this.setData({//模块编码(1-印象,2-味道,5-政策导航最新,6-政策导航最热)
|
||
|
noticeCategory: '5',
|
||
|
})
|
||
|
} else {//最新通知
|
||
|
this.setData({
|
||
|
noticeCategory: '6',
|
||
|
})
|
||
|
}
|
||
|
this.setData({
|
||
|
selectTab: e.currentTarget.dataset.tab,
|
||
|
noticelist: [],
|
||
|
loadMoreType: 'loading',
|
||
|
loadMoreVisible: true,
|
||
|
})
|
||
|
|
||
|
this.noticelist();
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
*/
|
||
|
onReady: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面显示
|
||
|
*/
|
||
|
onShow: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面隐藏
|
||
|
*/
|
||
|
onHide: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面卸载
|
||
|
*/
|
||
|
onUnload: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
*/
|
||
|
onPullDownRefresh: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面上拉触底事件的处理函数
|
||
|
*/
|
||
|
onReachBottom: function () {
|
||
|
this.setData({
|
||
|
loadMoreVisible: true
|
||
|
})
|
||
|
if (this.data.loadMoreType === 'loading') {
|
||
|
this.setData({
|
||
|
pageIndex: this.data.pageIndex + 1,
|
||
|
pageSize: this.data.pageSize,
|
||
|
})
|
||
|
this.deptinfolist();
|
||
|
}
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 用户点击右上角分享
|
||
|
*/
|
||
|
onShareAppMessage: function () {
|
||
|
|
||
|
},
|
||
|
toDetail(e) {
|
||
|
console.log(e.currentTarget.dataset.id)
|
||
|
wx.navigateTo({ url: '/subpages/home/pages/noticeDetail/noticeDetail?id=' + e.currentTarget.dataset.id })
|
||
|
}
|
||
|
})
|