// pages/volunteerNews/volunteerNews.js var app = getApp(); Page({ /** * 页面的初始数据 */ data: { newsList:[], page: 0,//当前页数 pageCount: 0,//总页数 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getNewList(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, //获取列表 getNewList() { var that = this; var config = wx.getStorageSync('config'); //获取用户消息列表 wx.request({ url: app.url + 'ajax_get_news_top_dat.php', header: { 'content-type': 'application/json' }, data: { unionId: config.unionId, }, method: 'GET', dataType: 'json', success: function (res) { if (res.statusCode == 200) { that.setData({ newsList: res.data.result.newsList }) } }, fail: function (res) {}, complete: function (res) {}, }) }, //跳转到详情页面 detail(e){ var newsId = e.currentTarget.dataset['index'] wx.navigateTo({ url: '../vNewsDetail/vNewsDetail?newsId='+newsId, }) }, //加载更多 onReachBottom() { if (this.data.page < this.data.pageCount) { var pageIndex = this.data.page + 1 this.setData({ page: pageIndex }) } else { wx.showToast({ title: '没有更多内容啦。', icon: 'success', duration: 2000 }); } }, })