// pages/donationIndex/donationIndex.js var app = getApp(); Page({ /** * 页面的初始数据 */ data: { page:0, pageCount:0, donationList:[] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getDonationList(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { if (this.data.page < this.data.pageCount) { var pageIndex = this.data.page + 1 this.setData({ page: pageIndex }) this.getDonationList(); } else { wx.showToast({ title: '没有更多内容啦。', icon: 'success', duration: 2000 }); } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, //获取募捐列表 getDonationList() { var that = this; var config = wx.getStorageSync('config'); wx: wx.request({ url: app.url + 'ajax_get_donation_event_list.php', data: { unionId: config.unionId, page: that.data.page }, header: { 'content-type': 'application/json' }, method: 'GET', dataType: 'json', success: function (res) { console.log(res) if (res.statusCode == 200) { that.setData({ pageCount: res.data.result.pageCount, donationList: res.data.result.list }) } }, fail: function (res) { }, complete: function (res) { }, }) }, //查看详情 donationDetail(e){ let donationId = e.currentTarget.dataset['index'] wx.navigateTo({ url: '../donationDetail/donationDetail?donationId=' + donationId, }) } })