// pages/volunteer/volunteer.js var app = getApp(); Page({ /** * 页面的初始数据 */ data: { indicatorDots: true, autoplay: true, serviceMap: [], pages: { page: 1, rows: 5 } }, goDetail: function (e) { var id = e.currentTarget.dataset.id; wx.navigateTo({ url: '../serviceActivityDetail/serviceActivityDetail?id=' + id }) }, goTeam: function () { wx.navigateTo({ url: '../volunteerTeam/volunteerTeam', }) }, goRegister: function () { wx.navigateTo({ url: '../volunteerRegister/volunteerRegister', }) }, newActivity: function () { wx.navigateTo({ url: '../newVolunteerActivity/newVolunteerActivity', }) }, /** * 获取志愿者活动列表 */ activityList: function() { var self = this; app.restAjax.get(app.restAjax.path(app.volunteerUrl + '/app/volunteerservice/listpagevolunteerservicerelease/{areaCode}', [app.areaCode]), self.data.pages, null, function(code, data) { if('200' == code) { // 将活动照片,拼接为可访问地址 for(var item of data.rows) { if('' != item.photo) { var photoArr = item.photo.split(","); item.photo = app.volunteerUrl + '/route/file/download/true/' + photoArr[0]; } } if(1 === self.data.pages.page) { self.setData({ serviceMap: data.rows }) }else { if(data.rows.length == 0) { self.setData({ [`pages.page`] : self.data.pages.page - 1 }) app.dialog.msg('暂无更多') return false; } self.setData({ serviceMap: data.rows.concat(self.data.serviceMap), }) } } }, function() { }, function() { wx.hideNavigationBarLoading(); //完成停止加载图标 wx.stopPullDownRefresh(); }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.activityList(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { // 在标题栏中显示加载图标 wx.showNavigationBarLoading(); var self = this; self.setData({ [`pages.page`] : 1 }) this.activityList(); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })