diff --git a/pages/activity/activity.js b/pages/activity/activity.js index 201b727..75d3736 100644 --- a/pages/activity/activity.js +++ b/pages/activity/activity.js @@ -1,12 +1,11 @@ // pages/activity/activity.js +var app = getApp(); Page({ /** * 页面的初始数据 */ data: { - url: 'http://192.168.0.111:8080/culturalactivity/', - imgUrl: 'http://192.168.0.111:8080/culturalactivity/route/file/downloadfile/true/', dataList: [] }, goDetail: function (e) { @@ -20,20 +19,22 @@ Page({ */ onLoad: function (options) { var self = this; - wx.request({ - url: self.data.url + 'wxminiapp/activitylibrary/listpageactivitylibraryfornetrelease', - success: function(res) { - if('200' == res.statusCode) { - for(var item of res.data.rows) { + app.restAjax.get(app.restAjax.path(app.activityUrl + 'wxminiapp/activitylibrary/listpageactivitylibraryfornetrelease', []), + {}, null, function(code, data) { + if('200' == code) { + for(var item of data.rows) { if('' != item.activityImage) { - item.activityImage = self.data.imgUrl + item.activityImage; + item.activityImage = app.activityUrl + 'route/file/downloadfile/true/' + item.activityImage; } } self.setData({ - dataList: res.data.rows, + dataList: data.rows, }) } - } + }, function() { + + }, function() { + }) }, diff --git a/pages/activityDetail/activityDetail.js b/pages/activityDetail/activityDetail.js index f7e8732..115d24b 100644 --- a/pages/activityDetail/activityDetail.js +++ b/pages/activityDetail/activityDetail.js @@ -1,12 +1,11 @@ // pages/activityDetail/activityDetail.js +var app = getApp(); Page({ /** * 页面的初始数据 */ data: { - url: 'http://192.168.0.111:8080/culturalactivity/', - imgUrl: 'http://192.168.0.111:8080/culturalactivity/route/file/downloadfile/true/', dataMap: {} }, goSign: function () { @@ -20,16 +19,18 @@ Page({ onLoad: function (options) { var self = this; var id = options.id; - wx.request({ - url: self.data.url + 'wxminiapp/activitylibrary/getactivitylibrarybyidrelease/' + id, - success: function(res) { - if('200' == res.statusCode) { - res.data.activityImage = self.data.imgUrl + res.data.activityImage; + app.restAjax.get(app.restAjax.path(app.activityUrl + 'wxminiapp/activitylibrary/getactivitylibrarybyidrelease/' + id, []), + {}, null, function(code, data) { + if('200' == code) { + data.activityImage = app.activityUrl + 'route/file/downloadfile/true/' + data.activityImage; self.setData({ - dataMap: res.data + dataMap: data }) } - } + }, function() { + + }, function() { + }) }, diff --git a/pages/center/center.js b/pages/center/center.js index 9fca8ff..d49a43a 100644 --- a/pages/center/center.js +++ b/pages/center/center.js @@ -67,7 +67,7 @@ Page({ */ toMyTeam: function() { wx.navigateTo({ - url: '../myVlounteerTeam/myVlounteerTeam', + url: '../myVolunteerTeam/myVolunteerTeam', }) }, /** diff --git a/pages/center/center.wxml b/pages/center/center.wxml index 82ae944..e434ec7 100644 --- a/pages/center/center.wxml +++ b/pages/center/center.wxml @@ -23,13 +23,13 @@ 我的收藏 - + - 我的志愿团队 + 我的志愿团队 - + - 我的志愿活动 + 我的志愿活动 diff --git a/pages/myVolunteerActivity/myVolunteerActivity.js b/pages/myVolunteerActivity/myVolunteerActivity.js index 8f4575b..216845f 100644 --- a/pages/myVolunteerActivity/myVolunteerActivity.js +++ b/pages/myVolunteerActivity/myVolunteerActivity.js @@ -1,13 +1,13 @@ // pages/volunteer/volunteer.js +var app = getApp(); Page({ /** * 页面的初始数据 */ data: { - baseUrl: 'http://192.168.0.111:8888/volunteer/', token: '', - otherTeamMap: {}, + dataMap: {}, type: '1', teamId: '', @@ -31,33 +31,53 @@ Page({ url: '../newTeam/newTeam', }) }, + goDetail: function (e) { + var id = e.currentTarget.dataset.id; + wx.navigateTo({ + url: '../serviceActivityDetail/serviceActivityDetail?id=' + id + }) + }, + newActivity: function () { + wx.navigateTo({ + url: '../newVolunteerActivity/newVolunteerActivity', + }) + }, changeTab: function(e) { var self = this; self.setData({ type: e.currentTarget.dataset.type }) if(self.data.type === '1') { - self.otherTeam(self.data.baseUrl + 'wxminiapp/team/otherteamm?otherTeam=true'); + // 我发起的活动 + self.myActivity(app.volunteerUrl + 'wxminiapp/volunteerservice/listpagevolunteerservice'); }else { - self.otherTeam(self.data.baseUrl + 'wxminiapp/team/myjointeam?myTeam=true'); + // 我参加的活动 + self.myActivity(app.volunteerUrl + 'wxminiapp/volunteerservice/listpagemyjoinservice'); } }, - otherTeam: function(url) { + myActivity: function(url) { var self = this; - wx.request({ - url: url, - header: { - token: self.data.token - }, - success(res) { - if('200' == res.statusCode) { + app.restAjax.get(app.restAjax.path(url, []), + {}, { + 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(","); + item.photo = app.volunteerUrl + 'route/file/downloadfile/true/' + photoArr[0]; + } + } self.setData({ - otherTeamMap: res.data.rows + dataMap: data.rows }) } - console.log(res) - console.log(self.data.otherTeamMap) - } + }, function(code, data) { + app.dialog.msg(data.msg); + }, function() { + }) }, /** @@ -73,45 +93,42 @@ Page({ var methodType; var title; if('1' == self.data.type) { - url = self.data.baseUrl + 'wxminiapp/teammember/saveteammember' + url = app.volunteerUrl + 'wxminiapp/teammember/saveteammember' teamMemberVO = { teamId: e.currentTarget.dataset.teamid } - methodType = 'POST' + methodType = app.restAjax.post title = '申请成功!' }else { - url = self.data.baseUrl + 'wxminiapp/teammember/quitTeam/' + self.data.teamId - methodType = 'GET' + url = app.volunteerUrl + 'wxminiapp/teammember/quitTeam/' + self.data.teamId + methodType = app.restAjax.get title = '退出成功!' } - wx.request({ - url: url, - data: teamMemberVO, - method: methodType, - header: { - token: self.data.token - }, - success(res) { - if('200' == res.statusCode) { - wx.showToast({ - title: title, - icon: 'none', - duration: 2000 - }) + + methodType(app.restAjax.path(url, []), + teamMemberVO, { + headers: { + token: self.data.token + } + }, function(code, data) { + if('200' == code) { + app.dialog.msg(title); wx.navigateTo({ url: '../volunteer/volunteer', }) } - } + }, function(code, data) { + app.dialog.msg(data.msg); + }, function() { + }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - var self = this; this.getToken().then(result => { - this.otherTeam(self.data.baseUrl + 'wxminiapp/team/otherteamm?otherTeam=true'); + this.myActivity(app.volunteerUrl + 'wxminiapp/volunteerservice/listpagevolunteerservice'); }) }, diff --git a/pages/myVolunteerActivity/myVolunteerActivity.wxml b/pages/myVolunteerActivity/myVolunteerActivity.wxml index 7fb08c9..b018090 100644 --- a/pages/myVolunteerActivity/myVolunteerActivity.wxml +++ b/pages/myVolunteerActivity/myVolunteerActivity.wxml @@ -1,30 +1,30 @@ - 未参加 + 我发起 - 已参加 + 我参加 - - - - {{item.teamName}} - 申请加入 - 退出 - 待审核 - 退出 - 审核驳回 - 已退出 + + + + + + + + + {{item.serviceName}} + + {{item.startTime}}至{{item.endTime}} + - 团队口号:{{item.teamWatchword}} - 所属区域:{{item.teamCityDictionaryName}} {{item.teamCountyDictionaryName}} {{item.teamAreaDictionaryName}} - 创建新团队 + 发起新活动 \ No newline at end of file diff --git a/pages/myVolunteerActivity/myVolunteerActivity.wxss b/pages/myVolunteerActivity/myVolunteerActivity.wxss index 97bc150..b777244 100644 --- a/pages/myVolunteerActivity/myVolunteerActivity.wxss +++ b/pages/myVolunteerActivity/myVolunteerActivity.wxss @@ -91,4 +91,47 @@ color: #fff; background: #9F1512; border-radius: 10rpx; +} +.volunteer-activity{ + margin-top: 90rpx; + padding: 0 30rpx; + margin-bottom: 105rpx; +} +.activity{ + padding: 20rpx 30rpx 0; +} +.activity-box{ + margin-bottom: 20rpx; + box-shadow:0px 0px 17rpx 0px rgba(0,0,0,0.1); + border-radius: 10rpx; + overflow: hidden; +} +.activity-img{ + height: 320rpx; + position: relative; +} +.activity-img image{ + width: 100%; + height: 100%; +} +.activity-info{ + padding: 15rpx 20rpx; +} +.title{ + display: flex; + justify-content: space-between; +} +.activity-title{ + width: 100%; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + font-size: 30rpx; + color: #242424; + line-height: 40rpx; +} +.date{ + margin-top: 10rpx; + font-size: 22rpx; + color: #242424; } \ No newline at end of file diff --git a/pages/myVolunteerTeam/myVlounteerTeam.js b/pages/myVolunteerTeam/myVolunteerTeam.js similarity index 60% rename from pages/myVolunteerTeam/myVlounteerTeam.js rename to pages/myVolunteerTeam/myVolunteerTeam.js index 8f4575b..840cbc1 100644 --- a/pages/myVolunteerTeam/myVlounteerTeam.js +++ b/pages/myVolunteerTeam/myVolunteerTeam.js @@ -1,11 +1,11 @@ // pages/volunteer/volunteer.js +var app = getApp(); Page({ /** * 页面的初始数据 */ data: { - baseUrl: 'http://192.168.0.111:8888/volunteer/', token: '', otherTeamMap: {}, type: '1', @@ -31,33 +31,23 @@ Page({ url: '../newTeam/newTeam', }) }, - changeTab: function(e) { - var self = this; - self.setData({ - type: e.currentTarget.dataset.type - }) - if(self.data.type === '1') { - self.otherTeam(self.data.baseUrl + 'wxminiapp/team/otherteamm?otherTeam=true'); - }else { - self.otherTeam(self.data.baseUrl + 'wxminiapp/team/myjointeam?myTeam=true'); - } - }, otherTeam: function(url) { var self = this; - wx.request({ - url: url, - header: { - token: self.data.token - }, - success(res) { - if('200' == res.statusCode) { + app.restAjax.get(app.restAjax.path(url, []), + {}, { + headers: { + token: self.data.token + } + }, function(code, data) { + if('200' == code) { self.setData({ - otherTeamMap: res.data.rows + otherTeamMap: data.rows }) } - console.log(res) - console.log(self.data.otherTeamMap) - } + }, function(code, data) { + app.dialog.msg(data.msg); + }, function() { + }) }, /** @@ -73,45 +63,42 @@ Page({ var methodType; var title; if('1' == self.data.type) { - url = self.data.baseUrl + 'wxminiapp/teammember/saveteammember' + url = app.volunteerUrl + 'wxminiapp/teammember/saveteammember' teamMemberVO = { teamId: e.currentTarget.dataset.teamid } - methodType = 'POST' + methodType = app.restAjax.post title = '申请成功!' }else { - url = self.data.baseUrl + 'wxminiapp/teammember/quitTeam/' + self.data.teamId - methodType = 'GET' + url = app.volunteerUrl + 'wxminiapp/teammember/quitTeam/' + self.data.teamId + methodType = app.restAjax.get title = '退出成功!' } - wx.request({ - url: url, - data: teamMemberVO, - method: methodType, - header: { - token: self.data.token - }, - success(res) { - if('200' == res.statusCode) { - wx.showToast({ - title: title, - icon: 'none', - duration: 2000 - }) + + methodType(app.restAjax.path(url, []), + teamMemberVO, { + headers: { + token: self.data.token + } + }, function(code, data) { + if('200' == code) { + app.dialog.msg(title); wx.navigateTo({ url: '../volunteer/volunteer', }) } - } + }, function(code, data) { + app.dialog.msg(data.msg); + }, function() { + }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - var self = this; this.getToken().then(result => { - this.otherTeam(self.data.baseUrl + 'wxminiapp/team/otherteamm?otherTeam=true'); + this.otherTeam(app.volunteerUrl + 'wxminiapp/team/myteamm'); }) }, diff --git a/pages/myVolunteerTeam/myVlounteerTeam.json b/pages/myVolunteerTeam/myVolunteerTeam.json similarity index 100% rename from pages/myVolunteerTeam/myVlounteerTeam.json rename to pages/myVolunteerTeam/myVolunteerTeam.json diff --git a/pages/myVolunteerTeam/myVlounteerTeam.wxml b/pages/myVolunteerTeam/myVolunteerTeam.wxml similarity index 63% rename from pages/myVolunteerTeam/myVlounteerTeam.wxml rename to pages/myVolunteerTeam/myVolunteerTeam.wxml index 7fb08c9..38740fc 100644 --- a/pages/myVolunteerTeam/myVlounteerTeam.wxml +++ b/pages/myVolunteerTeam/myVolunteerTeam.wxml @@ -1,15 +1,3 @@ - - - - 未参加 - - - - - 已参加 - - - @@ -24,7 +12,4 @@ 团队口号:{{item.teamWatchword}} 所属区域:{{item.teamCityDictionaryName}} {{item.teamCountyDictionaryName}} {{item.teamAreaDictionaryName}} - - - 创建新团队 \ No newline at end of file diff --git a/pages/myVolunteerTeam/myVlounteerTeam.wxss b/pages/myVolunteerTeam/myVolunteerTeam.wxss similarity index 96% rename from pages/myVolunteerTeam/myVlounteerTeam.wxss rename to pages/myVolunteerTeam/myVolunteerTeam.wxss index 97bc150..29df066 100644 --- a/pages/myVolunteerTeam/myVlounteerTeam.wxss +++ b/pages/myVolunteerTeam/myVolunteerTeam.wxss @@ -39,9 +39,7 @@ right: 100rpx; } .team{ - margin-top: 90rpx; padding: 0 30rpx; - margin-bottom: 110rpx; } .team-box{ padding: 20rpx 0; diff --git a/pages/newTeam/newTeam.js b/pages/newTeam/newTeam.js index fb48765..8cea636 100644 --- a/pages/newTeam/newTeam.js +++ b/pages/newTeam/newTeam.js @@ -1,11 +1,11 @@ // pages/newTeam/newTeam.js +var app = getApp(); Page({ /** * 页面的初始数据 */ data: { - baseUrl: 'http://192.168.0.111:8888/volunteer/', isAgree: false, // 是否同意志愿者注册协议 index: 0, array: ['区域1','区域2','区域3','区域4'], @@ -63,26 +63,24 @@ Page({ wx.chooseImage({ success (res) { const tempFilePaths = res.tempFilePaths - wx.uploadFile({ - url: self.data.baseUrl + 'app/file/uploadimage', - filePath: tempFilePaths[0], - name: 'image', - header: { - 'token': self.data.token - }, - formData: { - 'image': tempFilePaths[0] - }, - success (res){ - var data = res.data.substr(9, res.data.length); - data = data.substr(0, data.length - 2); - self.setData({ - photo: data - }) - }, - fail: function(res) { - console.log(res) - } + console.log(tempFilePaths) + app.restAjax.file(app.restAjax.path(app.volunteerUrl + 'app/file/uploadimage', []), tempFilePaths[0], + 'image', { + headers: { + token: self.data.token + } + }, function(code, data) { + if('200' == code) { + var data = data.substr(9, data.length); + data = data.substr(0, data.length - 2); + self.setData({ + photo: data + }) + } + }, function(code, data) { + app.dialog.msg(data.msg) + }, function() { + }) } }) @@ -186,27 +184,22 @@ Page({ self.data.teamArea[self.data.teamAreaIndex].dictionaryId : '', }; - wx.request({ - url: self.data.baseUrl + 'wxminiapp/team/saveteam', - method: 'POST', - header: { - 'token': self.data.token - }, - data: teamVO, - success(res) { - if(res.statusCode == 200) { - wx.showToast({ - title: '注册成功!', - icon: 'none', - duration: 1500 - }) + app.restAjax.post(app.restAjax.path(app.volunteerUrl + 'wxminiapp/team/saveteam', []), + teamVO, { + headers: { + 'token': self.data.token + } + }, function(code, data) { + if('200' == code) { + app.dialog.msg('注册成功') wx.navigateTo({ url: '../volunteer/volunteer', }) - }else { - console.log('登陆失败!' + res.errMsg); } - } + }, function(code, data) { + app.dialog.msg(data.msg) + }, function() { + }) }, /** @@ -215,16 +208,15 @@ Page({ getDataFromDict: function(dictId, type) { var self = this; return new Promise(resolve => { - wx.request({ - url: self.data.baseUrl + 'app/datadictionary/listdictionarybyparentid/' + dictId, - header: { - 'token': self.data.token - }, - success: function(res) { - if('200' == res.statusCode) { - if(res.data || type === 2) { - var array = []; - for(var item of res.data) { + app.restAjax.get(app.restAjax.path(app.volunteerUrl + 'app/datadictionary/listdictionarybyparentid/' + dictId, []), + {}, { + headers: { + token: self.data.token + } + }, function(code, data) { + if('200' == code) { + var array = []; + for(var item of data) { delete item.dictionaryParentId; delete item.dictionaryParentName; delete item.dictionarySummary; @@ -240,11 +232,13 @@ Page({ }) } self.setData({ - tempObj: res.data + tempObj: data }) - } - return resolve(); - } + return resolve(); + }, function() { + + }, function() { + }) }) }, diff --git a/pages/newVolunteerActivity/newVolunteerActivity.js b/pages/newVolunteerActivity/newVolunteerActivity.js index 34d1463..03915af 100644 --- a/pages/newVolunteerActivity/newVolunteerActivity.js +++ b/pages/newVolunteerActivity/newVolunteerActivity.js @@ -1,4 +1,5 @@ // pages/newVolunteerActivity/newVolunteerActivity.js +var app = getApp(); var util = require('../../utils/util.js'); Page({ @@ -6,7 +7,6 @@ Page({ * 页面的初始数据 */ data: { - baseUrl: 'http://192.168.0.111:8888/volunteer/', token: '', startDate: '', endDate: '', @@ -89,26 +89,23 @@ Page({ wx.chooseImage({ success (res) { const tempFilePaths = res.tempFilePaths - wx.uploadFile({ - url: self.data.baseUrl + 'app/file/uploadimage', - filePath: tempFilePaths[0], - name: 'image', - header: { - 'token': self.data.token - }, - formData: { - 'image': tempFilePaths[0] - }, - success (res){ - var data = res.data.substr(9, res.data.length); - data = data.substr(0, data.length - 2); - self.setData({ - photo: data - }) - }, - fail: function(res) { - console.log(res) - } + app.restAjax.file(app.restAjax.path(app.volunteerUrl + 'app/file/uploadimage', []), tempFilePaths[0], + 'image', { + headers: { + token: self.data.token + } + }, function(code, data) { + if('200' == code) { + var data = data.substr(9, data.length); + data = data.substr(0, data.length - 2); + self.setData({ + photo: data + }) + } + }, function(code, data) { + app.dialog.msg(data.msg) + }, function() { + }) } }) @@ -163,7 +160,6 @@ Page({ }) return false; } - console.log(self.data.startDate) var volunteerServiceVO = { serviceName: self.data.serviceName, serviceContent: self.data.serviceContent, @@ -179,27 +175,22 @@ Page({ photo: self.data.photo, serviceRequirement: self.data.serviceRequirement }; - wx.request({ - url: self.data.baseUrl + 'wxminiapp/volunteerservice/savevolunteerservice', - method: 'POST', - header: { - 'token': self.data.token - }, - data: volunteerServiceVO, - success(res) { - if(res.statusCode == 200) { - wx.showToast({ - title: '活动发布成功!', - icon: 'none', - duration: 1500 - }) + app.restAjax.post(app.restAjax.path(app.volunteerUrl + 'wxminiapp/volunteerservice/savevolunteerservice', []), + volunteerServiceVO, { + headers: { + 'token': self.data.token + } + }, function(code, data) { + if('200' == code) { + app.dialog.msg('活动发布成功!'); wx.navigateTo({ url: '../volunteer/volunteer', }) - }else { - console.log('登陆失败!' + res.errMsg); } - } + }, function(code, data) { + app.dialog.msg(data.msg); + }, function() { + }) }, /** diff --git a/pages/serviceActivityDetail/serviceActivityDetail.js b/pages/serviceActivityDetail/serviceActivityDetail.js index cfa9a88..15f8aa8 100644 --- a/pages/serviceActivityDetail/serviceActivityDetail.js +++ b/pages/serviceActivityDetail/serviceActivityDetail.js @@ -1,12 +1,11 @@ // pages/activityDetail/activityDetail.js +var app = getApp(); Page({ /** * 页面的初始数据 */ data: { - baseUrl: 'http://192.168.0.111:8888/volunteer/', - imgUrl: 'http://192.168.0.111:8888/volunteer/route/file/downloadfile/true/', dataMap: {}, token: '', serviceId: '', @@ -33,19 +32,22 @@ Page({ }, getDetail: function(id) { var self = this; - wx.request({ - url: self.data.baseUrl + 'wxminiapp/volunteerservice/getvolunteerservicebyid/' + id, - header: { + app.restAjax.get(app.restAjax.path(app.volunteerUrl + 'wxminiapp/volunteerservice/getvolunteerservicebyid/' + id, []), + {}, { + headers: { 'token': self.data.token - }, - success: function(res) { - if('200' == res.statusCode) { - res.data.photo = self.data.imgUrl + res.data.photo; + } + }, function(code, data) { + if('200' == code) { + data.photo = app.volunteerUrl + 'route/file/downloadfile/true/' + data.photo; self.setData({ - dataMap: res.data + dataMap: data }) } - } + }, function() { + + }, function() { + }) }, /** @@ -128,25 +130,22 @@ Page({ */ sendEnrollRequest: function(serviceMemberVO) { var self = this; - wx.request({ - url: self.data.baseUrl + 'wxminiapp/servicemember/saveservicemember', - method: 'POST', - header: { - token: self.data.token - }, - data: serviceMemberVO, - success(res) { - if(res.statusCode == 200) { - wx.showToast({ - title: '报名成功!', - icon: 'none', - duration: 1500 - }) + app.restAjax.post(app.restAjax.path(app.volunteerUrl + 'wxminiapp/servicemember/saveservicemember', []), + serviceMemberVO, { + headers: { + token: self.data.token + } + }, function(code, data) { + if('200' == code) { + app.dialog.msg('注册成功!'); wx.navigateTo({ url: '../volunteer/volunteer', }) } - } + }, function() { + + }, function() { + }) }, /** @@ -156,30 +155,26 @@ Page({ var self = this; var url; if(self.data.teamArray.length > 0) { - url = self.data.baseUrl + 'wxminiapp/servicemember/cancelapply/'+ self.data.type +'/'+ self.data.serviceId +'/' + self.data.team[self.data.teamIndex].teamId; + url = app.volunteerUrl + 'wxminiapp/servicemember/cancelapply/'+ self.data.type +'/'+ self.data.serviceId +'/' + self.data.team[self.data.teamIndex].teamId; }else { - url = self.data.baseUrl + 'wxminiapp/servicemember/cancelapply/'+ self.data.type +'/'+ self.data.serviceId +'/null'; + url = app.volunteerUrl + 'wxminiapp/servicemember/cancelapply/'+ self.data.type +'/'+ self.data.serviceId +'/null'; } - wx.request({ - url: url, - header: { + + app.restAjax.get(app.restAjax.path(url, []), {}, { + headers: { token: self.data.token - }, - success(res) { - if(res.statusCode == 200) { - wx.showToast({ - title: '取消报名成功!', - icon: 'none', - duration: 1500 - }) + } + }, function(code, data) { + if('200' == code) { + app.dialog.msg('取消报名成功!'); wx.navigateTo({ url: '../volunteer/volunteer', }) } - }, - fail(res) { - - } + }, function() { + + }, function() { + }) }, /** @@ -187,15 +182,16 @@ Page({ */ getMyTeam: function() { var self = this; - wx.request({ - url: self.data.baseUrl + 'wxminiapp/team/myteamm', - header: { - token: self.data.token - }, - success(res) { - if('200' == res.statusCode) { + console.log(self.data.token) + app.restAjax.get(app.restAjax.path(app.volunteerUrl + 'wxminiapp/team/myteamm', []), + {}, { + headers: { + token: self.data.token + } + }, function(code, data) { + if('200' == code) { var array = []; - for(var item of res.data.rows) { + for(var item of data.rows) { delete item.teamArea; delete item.teamAreaDictionaryName; delete item.teamWatchword; @@ -219,10 +215,13 @@ Page({ } self.setData({ teamArray: array, - team: res.data.rows + team: data.rows }) } - } + }, function(code, data) { + app.dialog.msg(data.msg); + }, function() { + }) }, /** diff --git a/pages/volunteer/volunteer.js b/pages/volunteer/volunteer.js index e0f9843..5821d54 100644 --- a/pages/volunteer/volunteer.js +++ b/pages/volunteer/volunteer.js @@ -1,4 +1,5 @@ // pages/volunteer/volunteer.js +var app = getApp(); Page({ /** @@ -7,8 +8,6 @@ Page({ data: { indicatorDots: true, autoplay: true, - baseUrl: 'http://192.168.0.111:8888/volunteer/', - imgUrl: 'http://192.168.0.111:8888/volunteer/route/file/downloadfile/true/', serviceMap: [] }, goDetail: function (e) { @@ -37,22 +36,24 @@ Page({ */ activityList: function() { var self = this; - wx.request({ - url: self.data.baseUrl + 'wxminiapp/volunteerservice/listpagevolunteerservicerelease', - success: function(res) { - if('200' == res.statusCode) { + app.restAjax.get(app.restAjax.path(app.volunteerUrl + 'wxminiapp/volunteerservice/listpagevolunteerservicerelease', []), + {}, null, function(code, data) { + if('200' == code) { // 将活动照片,拼接为可访问地址 - for(var item of res.data.rows) { + for(var item of data.rows) { if('' != item.photo) { var photoArr = item.photo.split(","); - item.photo = self.data.imgUrl + photoArr[0]; + item.photo = app.volunteerUrl + 'route/file/downloadfile/true/' + photoArr[0]; } } self.setData({ - serviceMap: res.data.rows + serviceMap: data.rows }) } - } + }, function() { + + }, function() { + }) }, /** diff --git a/pages/volunteerRegister/volunteerRegister.js b/pages/volunteerRegister/volunteerRegister.js index d2d7878..beab318 100644 --- a/pages/volunteerRegister/volunteerRegister.js +++ b/pages/volunteerRegister/volunteerRegister.js @@ -1,11 +1,11 @@ // pages/volunteerRegister/volunteerRegister.js +var app = getApp(); Page({ /** * 页面的初始数据 */ data: { - baseUrl: 'http://192.168.0.111:8888/volunteer/', token: '', isAgree: false, // 是否同意志愿者注册协议 openExperience: 0, @@ -103,6 +103,12 @@ Page({ } }) }, + areaChange: function(e) { + var self = this; + self.setData({ + teamAreaIndex: e.detail.value + }) + }, changeOpen: function(e) { if(e.detail.value == ''){ this.setData({ @@ -197,27 +203,22 @@ Page({ agree: self.data.isAgree, openExperience : self.data.openExperience }; - wx.request({ - url: self.data.baseUrl + 'wxminiapp/volunteer/savevolunteer', - method: 'POST', - header: { - 'token': self.data.token - }, - data: volunteerVO, - success(res) { - if(res.statusCode == 200) { - wx.showToast({ - title: '注册成功!', - icon: 'none', - duration: 1500 - }) + app.restAjax.post(app.restAjax.path(app.volunteerUrl + 'wxminiapp/volunteer/savevolunteer', []), + volunteerVO, { + headers: { + 'token': self.data.token + } + }, function(code, data) { + if('200' == code) { + app.dialog.msg('注册成功!'); wx.navigateTo({ url: '../volunteer/volunteer', }) - }else { - console.log('登陆失败!' + res.errMsg); } - } + }, function(code, data) { + app.dialog.msg(data.msg); + }, function() { + }) }, /** @@ -226,16 +227,16 @@ Page({ getDataFromDict: function(dictId, type) { var self = this; return new Promise(resolve => { - wx.request({ - url: self.data.baseUrl + 'app/datadictionary/listdictionarybyparentid/' + dictId, - header: { - 'token': self.data.token - }, - success: function(res) { - if('200' == res.statusCode) { - if(res.data || type === 2) { + app.restAjax.get(app.restAjax.path(app.volunteerUrl + 'app/datadictionary/listdictionarybyparentid/' + dictId, []), + {}, { + headers: { + 'token': self.data.token + } + }, function(code, data) { + if('200' == code) { + if(data || type === 2) { var array = []; - for(var item of res.data) { + for(var item of data) { delete item.dictionaryParentId; delete item.dictionaryParentName; delete item.dictionarySummary; @@ -251,11 +252,14 @@ Page({ }) } self.setData({ - tempObj: res.data + tempObj: data }) } - return resolve(); - } + return resolve(); + }, function() { + + }, function() { + }) }) }, diff --git a/pages/volunteerRegister/volunteerRegister.wxml b/pages/volunteerRegister/volunteerRegister.wxml index 7871737..7597413 100644 --- a/pages/volunteerRegister/volunteerRegister.wxml +++ b/pages/volunteerRegister/volunteerRegister.wxml @@ -40,7 +40,7 @@ 乡镇村: - + {{teamAreaArray[teamAreaIndex]}} diff --git a/pages/volunteerTeam/volunteerTeam.js b/pages/volunteerTeam/volunteerTeam.js index 8f4575b..032dbc8 100644 --- a/pages/volunteerTeam/volunteerTeam.js +++ b/pages/volunteerTeam/volunteerTeam.js @@ -1,11 +1,11 @@ // pages/volunteer/volunteer.js +var app = getApp(); Page({ /** * 页面的初始数据 */ data: { - baseUrl: 'http://192.168.0.111:8888/volunteer/', token: '', otherTeamMap: {}, type: '1', @@ -37,27 +37,28 @@ Page({ type: e.currentTarget.dataset.type }) if(self.data.type === '1') { - self.otherTeam(self.data.baseUrl + 'wxminiapp/team/otherteamm?otherTeam=true'); + self.otherTeam(app.volunteerUrl + 'wxminiapp/team/otherteamm?otherTeam=true'); }else { - self.otherTeam(self.data.baseUrl + 'wxminiapp/team/myjointeam?myTeam=true'); + self.otherTeam(app.volunteerUrl + 'wxminiapp/team/myjointeam?myTeam=true'); } }, otherTeam: function(url) { var self = this; - wx.request({ - url: url, - header: { - token: self.data.token - }, - success(res) { - if('200' == res.statusCode) { + app.restAjax.get(app.restAjax.path(url, []), + {}, { + headers: { + token: self.data.token + } + }, function(code, data) { + if('200' == code) { self.setData({ - otherTeamMap: res.data.rows + otherTeamMap: data.rows }) } - console.log(res) - console.log(self.data.otherTeamMap) - } + }, function(code, data) { + app.dialog.msg(data.msg); + }, function() { + }) }, /** @@ -73,45 +74,42 @@ Page({ var methodType; var title; if('1' == self.data.type) { - url = self.data.baseUrl + 'wxminiapp/teammember/saveteammember' + url = app.volunteerUrl + 'wxminiapp/teammember/saveteammember' teamMemberVO = { teamId: e.currentTarget.dataset.teamid } - methodType = 'POST' + methodType = app.restAjax.post title = '申请成功!' }else { - url = self.data.baseUrl + 'wxminiapp/teammember/quitTeam/' + self.data.teamId - methodType = 'GET' + url = app.volunteerUrl + 'wxminiapp/teammember/quitTeam/' + self.data.teamId + methodType = app.restAjax.get title = '退出成功!' } - wx.request({ - url: url, - data: teamMemberVO, - method: methodType, - header: { - token: self.data.token - }, - success(res) { - if('200' == res.statusCode) { - wx.showToast({ - title: title, - icon: 'none', - duration: 2000 - }) + + methodType(app.restAjax.path(url, []), + teamMemberVO, { + headers: { + token: self.data.token + } + }, function(code, data) { + if('200' == code) { + app.dialog.msg(title); wx.navigateTo({ url: '../volunteer/volunteer', }) } - } + }, function(code, data) { + app.dialog.msg(data.msg); + }, function() { + }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - var self = this; this.getToken().then(result => { - this.otherTeam(self.data.baseUrl + 'wxminiapp/team/otherteamm?otherTeam=true'); + this.otherTeam(app.volunteerUrl + 'wxminiapp/team/otherteamm?otherTeam=true'); }) },