xz_gangba/pages/myVolunteerActivity/myVolunteerActivity.js

138 lines
2.7 KiB
JavaScript
Raw Normal View History

2020-06-26 14:06:35 +08:00
// pages/volunteer/volunteer.js
2020-06-26 18:51:28 +08:00
var app = getApp();
2020-06-26 14:06:35 +08:00
Page({
/**
* 页面的初始数据
*/
data: {
token: '',
2020-06-26 18:51:28 +08:00
dataMap: {},
2020-06-26 14:06:35 +08:00
type: '1',
2020-06-30 20:03:05 +08:00
teamId: ''
2020-06-26 14:06:35 +08:00
},
getToken: function() {
var self = this;
return new Promise(resolve =>{
wx.getStorage({
key: 'token',
success(res) {
self.setData({
token: res.data
})
return resolve();
}
})
})
},
newTeam: function () {
wx.navigateTo({
url: '../newTeam/newTeam',
})
},
2020-06-26 18:51:28 +08:00
goDetail: function (e) {
var id = e.currentTarget.dataset.id;
wx.navigateTo({
url: '../serviceActivityDetail/serviceActivityDetail?id=' + id
})
},
newActivity: function () {
wx.navigateTo({
url: '../newVolunteerActivity/newVolunteerActivity',
})
},
2020-06-26 14:06:35 +08:00
changeTab: function(e) {
var self = this;
self.setData({
type: e.currentTarget.dataset.type
})
if(self.data.type === '1') {
2020-06-26 18:51:28 +08:00
// 我发起的活动
self.myActivity(app.volunteerUrl + '/app/volunteerservice/listpagevolunteerservice');
2020-06-26 14:06:35 +08:00
}else {
2020-06-26 18:51:28 +08:00
// 我参加的活动
self.myActivity(app.volunteerUrl + '/app/volunteerservice/listpagemyjoinservice');
2020-06-26 14:06:35 +08:00
}
},
2020-06-26 18:51:28 +08:00
myActivity: function(url) {
2020-06-26 14:06:35 +08:00
var self = this;
2020-06-26 18:51:28 +08:00
app.restAjax.get(app.restAjax.path(url, []),
2020-06-30 20:03:05 +08:00
self.data.pages, {
2020-06-26 18:51:28 +08:00
headers: {
token: self.data.token
}
}, function(code, data) {
if('200' == code) {
for(var item of data.rows) {
if('' != item.photo) {
var photoArr = item.photo.split(",");
2022-11-10 10:22:40 +08:00
item.photo = app.volunteerUrl + '/route/file/download/true/' + photoArr[0];
2020-06-26 18:51:28 +08:00
}
}
2020-06-26 14:06:35 +08:00
self.setData({
2020-06-26 18:51:28 +08:00
dataMap: data.rows
2020-06-26 14:06:35 +08:00
})
}
2020-06-26 18:51:28 +08:00
}, function(code, data) {
app.dialog.msg(data.msg);
}, function() {
2020-06-26 14:06:35 +08:00
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getToken().then(result => {
this.myActivity(app.volunteerUrl + '/app/volunteerservice/listpagevolunteerservice');
2020-06-26 14:06:35 +08:00
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
2020-06-30 20:03:05 +08:00
2020-06-26 14:06:35 +08:00
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})