修改请求方式

This commit is contained in:
Renpc-kilig 2020-06-26 18:51:28 +08:00
parent 3acc1cd9e4
commit 3cd7d19b77
18 changed files with 376 additions and 357 deletions

View File

@ -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() {
})
},

View File

@ -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() {
})
},

View File

@ -67,7 +67,7 @@ Page({
*/
toMyTeam: function() {
wx.navigateTo({
url: '../myVlounteerTeam/myVlounteerTeam',
url: '../myVolunteerTeam/myVolunteerTeam',
})
},
/**

View File

@ -23,13 +23,13 @@
<image src="../../images/my-collect.png"></image>
<view class="title">我的收藏</view>
</view>
<view class="main-box">
<view class="main-box" bindtap="toMyTeam">
<image src="../../images/share.png"></image>
<view class="title" bindtap="toMyTeam">我的志愿团队</view>
<view class="title">我的志愿团队</view>
</view>
<view class="main-box">
<view class="main-box" bindtap="toMyVolunteerActivity">
<image src="../../images/team.png"></image>
<view class="title" bindtap="toMyVolunteerActivity">我的志愿活动</view>
<view class="title">我的志愿活动</view>
</view>
<view class="main-box">
<image src="../../images/share.png"></image>

View File

@ -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');
})
},

View File

@ -1,30 +1,30 @@
<view class="top-tab">
<view class="tab-box {{type==1?'active':''}}" data-type="1" bindtap="changeTab">
<image src="../../images/selected-l.png" class="selected-l"></image>
未参加
我发起
<image src="../../images/selected-r.png" class="selected-r"></image>
</view>
<view class="tab-box {{type==2?'active':''}}" data-type="2" bindtap="changeTab">
<image src="../../images/selected-l.png" class="selected-l"></image>
参加
参加
<image src="../../images/selected-r.png" class="selected-r"></image>
</view>
</view>
<view class="team">
<view class="team-box" wx:for="{{otherTeamMap}}" data-id="{{item.teamId}}">
<view class="name-join">
<view class="name">{{item.teamName}}</view>
<view class="join" wx:if="{{item.checkStatus == '' && type == 1}}" data-teamid="{{item.teamId}}" bindtap="joinOrOutTeam">申请加入</view>
<view class="join" wx:if="{{item.checkStatus == '' && type == 2}}" data-teamid="{{item.teamId}}" bindtap="joinOrOutTeam">退出</view>
<view class="join" wx:if="{{item.checkStatus != '' && item.checkStatus == '0'}}">待审核</view>
<view class="join" wx:if="{{item.checkStatus != '' && item.checkStatus == '1'}}" bindtap="joinOrOutTeam">退出</view>
<view class="join" wx:if="{{item.checkStatus != '' && item.checkStatus == '2'}}">审核驳回</view>
<view class="join" wx:if="{{item.checkStatus != '' && item.checkStatus == '3'}}">已退出 </view>
<view class="volunteer-activity">
<view class="activity">
<view class="activity-box" bindtap="goDetail" data-id="{{item.volunteerServiceId}}" wx:for="{{dataMap}}">
<view class="activity-img">
<image src="{{item.photo}}"></image>
</view>
<view class="activity-info">
<view class="title">
<view class="activity-title">{{item.serviceName}}</view>
</view>
<view class="date">{{item.startTime}}至{{item.endTime}}</view>
</view>
</view>
<view class="slogan">团队口号:{{item.teamWatchword}}</view>
<view class="area">所属区域:{{item.teamCityDictionaryName}} {{item.teamCountyDictionaryName}} {{item.teamAreaDictionaryName}}</view>
</view>
</view>
<view class="new-team">
<view class="new-team-btn" bindtap="newTeam">创建新团队</view>
<view class="new-team-btn" bindtap="newActivity">发起新活动</view>
</view>

View File

@ -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;
}

View File

@ -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');
})
},

View File

@ -1,15 +1,3 @@
<view class="top-tab">
<view class="tab-box {{type==1?'active':''}}" data-type="1" bindtap="changeTab">
<image src="../../images/selected-l.png" class="selected-l"></image>
未参加
<image src="../../images/selected-r.png" class="selected-r"></image>
</view>
<view class="tab-box {{type==2?'active':''}}" data-type="2" bindtap="changeTab">
<image src="../../images/selected-l.png" class="selected-l"></image>
已参加
<image src="../../images/selected-r.png" class="selected-r"></image>
</view>
</view>
<view class="team">
<view class="team-box" wx:for="{{otherTeamMap}}" data-id="{{item.teamId}}">
<view class="name-join">
@ -24,7 +12,4 @@
<view class="slogan">团队口号:{{item.teamWatchword}}</view>
<view class="area">所属区域:{{item.teamCityDictionaryName}} {{item.teamCountyDictionaryName}} {{item.teamAreaDictionaryName}}</view>
</view>
</view>
<view class="new-team">
<view class="new-team-btn" bindtap="newTeam">创建新团队</view>
</view>

View File

@ -39,9 +39,7 @@
right: 100rpx;
}
.team{
margin-top: 90rpx;
padding: 0 30rpx;
margin-bottom: 110rpx;
}
.team-box{
padding: 20rpx 0;

View File

@ -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() {
})
})
},

View File

@ -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() {
})
},
/**

View File

@ -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() {
})
},
/**

View File

@ -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() {
})
},
/**

View File

@ -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() {
})
})
},

View File

@ -40,7 +40,7 @@
<view class="info-name">乡镇村:</view>
<view class="info-text">
<view class="section">
<picker bindchange="countyChange" value="{{teamAreaIndex}}" range="{{teamAreaArray}}">
<picker bindchange="areaChange" value="{{teamAreaIndex}}" range="{{teamAreaArray}}">
<view class="picker">
{{teamAreaArray[teamAreaIndex]}}
</view>

View File

@ -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');
})
},