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.
110 lines
3.0 KiB
110 lines
3.0 KiB
// subpages/home/pages/noticeNew/noticeNew.js
|
|
const api = require('../../../../utils/understandJs')
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
pageIndex: 1,
|
|
pageSize: 10,
|
|
noticeCategory: 'notice_navigation_hot',// 通知:notice_navigation_new
|
|
noticelist: [],
|
|
// selectTab: 'tab1',
|
|
nodata: false,
|
|
loadMoreType: 'none',
|
|
loadMoreVisible: false,
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.setData({
|
|
noticeCategory: options.modulecode
|
|
})
|
|
wx.setNavigationBarTitle({
|
|
title: options.modulecode == 'notice_navigation_hot' ? '最热政策' : options.modulecode == 'notice_navigation_new' ? '最新通知' : ''
|
|
})
|
|
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 切换
|
|
//模块编码(政策导航-最热政策:notice_navigation_hot、了解锦水-印象:notice_impression、了解锦水-味道:notice_taste、政策导航-最新通知: notice_navigation_new、了解锦水-警示:notice_warning)
|
|
// onTabChange(e) {
|
|
// if (e.currentTarget.dataset.tab == 'tab1') {
|
|
// this.setData({
|
|
// noticeCategory: 'notice_navigation_hot',
|
|
// })
|
|
// } else {
|
|
// this.setData({
|
|
// noticeCategory: 'notice_navigation_new',
|
|
// })
|
|
// }
|
|
// this.setData({
|
|
// selectTab: e.currentTarget.dataset.tab,
|
|
// pageIndex: 1,
|
|
// pageSize: 10,
|
|
// noticelist: [],
|
|
// loadMoreType: 'loading',
|
|
// loadMoreVisible: true,
|
|
// nodata: false,
|
|
// })
|
|
|
|
// this.noticelist();
|
|
// },
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
this.setData({
|
|
loadMoreVisible: true
|
|
})
|
|
if (this.data.loadMoreType === 'loading') {
|
|
this.setData({
|
|
pageIndex: this.data.pageIndex + 1,
|
|
pageSize: this.data.pageSize,
|
|
})
|
|
this.noticelist();
|
|
}
|
|
},
|
|
|
|
toDetail(e) {
|
|
console.log(e.currentTarget.dataset.id)
|
|
wx.navigateTo({ url: '/subpages/home/pages/noticeDetail/noticeDetail?id=' + e.currentTarget.dataset.id +'&code=' + this.data.noticeCategory })
|
|
}
|
|
})
|