|
|
|
|
|
const app=getApp();
|
|
|
const app = getApp();
|
|
|
Page({
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -7,16 +6,16 @@ Page({ |
|
|
*/
|
|
|
data: {
|
|
|
//
|
|
|
ifempower:true,//是否授权
|
|
|
showapply:false,
|
|
|
provincearr:[],
|
|
|
cityarr:[],
|
|
|
countryarr:[],
|
|
|
confirmvalarr:[0,0,0],
|
|
|
valarr:[0,0,0],
|
|
|
ifempower: true, //是否授权
|
|
|
showapply: false,
|
|
|
provincearr: [],
|
|
|
cityarr: [],
|
|
|
countryarr: [],
|
|
|
confirmvalarr: [0, 0, 0],
|
|
|
valarr: [0, 0, 0],
|
|
|
photo: '',
|
|
|
name: '',
|
|
|
enddata:'',
|
|
|
enddata: '',
|
|
|
arraysex: ['男', '女'],
|
|
|
sex: '',
|
|
|
birthday: '', //生日
|
...
|
...
|
@@ -75,7 +74,7 @@ Page({ |
|
|
],
|
|
|
front_card: '', //身份证正面照
|
|
|
reverse_card: '', //身份证反面照
|
|
|
id:'',//用户id,
|
|
|
id: '', //用户id,
|
|
|
},
|
|
|
setname(e) {
|
|
|
this.setData({
|
...
|
...
|
@@ -163,18 +162,18 @@ Page({ |
|
|
politics: politicsarr[e.detail.value]
|
|
|
})
|
|
|
},
|
|
|
// bindtypeChange(e) {
|
|
|
// let typearr = this.data.typearr;
|
|
|
// this.setData({
|
|
|
// type: parseInt(e.detail.value) +1
|
|
|
// })
|
|
|
// },
|
|
|
// bindtypeChange(e) {
|
|
|
// let typearr = this.data.typearr;
|
|
|
// this.setData({
|
|
|
// type: parseInt(e.detail.value) +1
|
|
|
// })
|
|
|
// },
|
|
|
start(e) {
|
|
|
let that = this;
|
|
|
let tem = e.currentTarget.dataset.tem;
|
|
|
app.globalData.userInfo = e.detail.userInfo;
|
|
|
wx.login({
|
|
|
success: function (s) {
|
|
|
success: function(s) {
|
|
|
let url = 'wxapp/public/getSessionKey';
|
|
|
if (s.code) {
|
|
|
var code = s.code;
|
...
|
...
|
@@ -182,7 +181,7 @@ Page({ |
|
|
code: code
|
|
|
}
|
|
|
app.post(url, param).then((res) => {
|
|
|
that.login(res.openid, res.session_key, e.detail.encryptedData, e.detail.iv,tem);
|
|
|
that.login(res.openid, res.session_key, e.detail.encryptedData, e.detail.iv, tem);
|
|
|
}).catch((errMsg) => {
|
|
|
|
|
|
})
|
...
|
...
|
@@ -190,7 +189,7 @@ Page({ |
|
|
}
|
|
|
});
|
|
|
},
|
|
|
login(openid, session_key, encrypted_data, iv,tem) {
|
|
|
login(openid, session_key, encrypted_data, iv, tem) {
|
|
|
let that = this;
|
|
|
let param = {
|
|
|
openid: openid,
|
...
|
...
|
@@ -202,7 +201,7 @@ Page({ |
|
|
app.post(url, param).then((res) => {
|
|
|
wx.setStorageSync('token', res.token);
|
|
|
that.setData({
|
|
|
ifempower:true
|
|
|
ifempower: true
|
|
|
})
|
|
|
that.uploadImage(tem);
|
|
|
}).catch((errMsg) => {
|
...
|
...
|
@@ -211,10 +210,10 @@ Page({ |
|
|
},
|
|
|
|
|
|
//选择省市区
|
|
|
getarea(){
|
|
|
let that=this;
|
|
|
let url ='index/area/index';
|
|
|
app.post(url,{}).then((res)=>{
|
|
|
getarea() {
|
|
|
let that = this;
|
|
|
let url = 'index/area/index';
|
|
|
app.post(url, {}).then((res) => {
|
|
|
let country = res.country;
|
|
|
let tem = {
|
|
|
id: 0,
|
...
|
...
|
@@ -232,27 +231,27 @@ Page({ |
|
|
countryarr: temcountry,
|
|
|
provincearr: provincearr
|
|
|
})
|
|
|
if (that.data.is_submit==undefined){
|
|
|
if (that.data.is_submit == undefined) {
|
|
|
that.setData({
|
|
|
ifempower:false
|
|
|
ifempower: false
|
|
|
})
|
|
|
|
|
|
}else if (that.data.is_submit=='1'){
|
|
|
} else if (that.data.is_submit == '1') {
|
|
|
that.getdatalist();
|
|
|
}
|
|
|
|
|
|
}).catch((err)=>{
|
|
|
}).catch((err) => {
|
|
|
|
|
|
})
|
|
|
},
|
|
|
//切换省份获取市和区/县
|
|
|
get_city(province_id=0){
|
|
|
let that=this;
|
|
|
let url ='index/area/get_city';
|
|
|
let params={
|
|
|
get_city(province_id = 0) {
|
|
|
let that = this;
|
|
|
let url = 'index/area/get_city';
|
|
|
let params = {
|
|
|
'province_id': province_id
|
|
|
}
|
|
|
app.post(url, params).then((res)=>{
|
|
|
app.post(url, params).then((res) => {
|
|
|
let country = res.country;
|
|
|
let tem = {
|
|
|
id: 0,
|
...
|
...
|
@@ -266,24 +265,24 @@ Page({ |
|
|
cityarr: res.city,
|
|
|
countryarr: temcountry
|
|
|
})
|
|
|
}).catch((err)=>{
|
|
|
}).catch((err) => {
|
|
|
|
|
|
})
|
|
|
},
|
|
|
//切换市获取区/县
|
|
|
get_country(city_id=0){
|
|
|
let that=this;
|
|
|
let url ='index/area/get_country';
|
|
|
let params={
|
|
|
get_country(city_id = 0) {
|
|
|
let that = this;
|
|
|
let url = 'index/area/get_country';
|
|
|
let params = {
|
|
|
'city_id': city_id
|
|
|
}
|
|
|
app.post(url, params).then((res) => {
|
|
|
let country = res.country;
|
|
|
let tem={
|
|
|
id:0,
|
|
|
let tem = {
|
|
|
id: 0,
|
|
|
city_id: res.country[0].city_id,
|
|
|
country_id:0,
|
|
|
country_name:' '
|
|
|
country_id: 0,
|
|
|
country_name: ' '
|
|
|
}
|
|
|
country.push(tem);
|
|
|
let temcountry = country.reverse();
|
...
|
...
|
@@ -294,13 +293,13 @@ Page({ |
|
|
|
|
|
})
|
|
|
},
|
|
|
bindChange: function (e) {
|
|
|
let that=this;
|
|
|
bindChange: function(e) {
|
|
|
let that = this;
|
|
|
let valarr = that.data.valarr;
|
|
|
let provincearr = that.data.provincearr;
|
|
|
let cityarr = that.data.cityarr;
|
|
|
const val = e.detail.value;
|
|
|
if (valarr[0] != val[0] ){//改变省
|
|
|
if (valarr[0] != val[0]) { //改变省
|
|
|
let i = val[0];
|
|
|
that.get_city(provincearr[i].province_id);
|
|
|
valarr[0] = val[0];
|
...
|
...
|
@@ -309,7 +308,7 @@ Page({ |
|
|
that.setData({
|
|
|
valarr: valarr
|
|
|
})
|
|
|
} else if (valarr[1] != val[1]){//改变市
|
|
|
} else if (valarr[1] != val[1]) { //改变市
|
|
|
let j = val[1];
|
|
|
that.get_country(cityarr[j].city_id);
|
|
|
valarr[1] = val[1];
|
...
|
...
|
@@ -317,7 +316,7 @@ Page({ |
|
|
that.setData({
|
|
|
valarr: valarr
|
|
|
})
|
|
|
}else {//改变区
|
|
|
} else { //改变区
|
|
|
valarr[2] = val[2];
|
|
|
that.setData({
|
|
|
valarr: valarr
|
...
|
...
|
@@ -325,16 +324,16 @@ Page({ |
|
|
}
|
|
|
},
|
|
|
//取消地区选择
|
|
|
setno(){
|
|
|
let that=this;
|
|
|
setno() {
|
|
|
let that = this;
|
|
|
that.setData({
|
|
|
valarr: that.data.confirmvalarr,
|
|
|
showapply: false
|
|
|
})
|
|
|
},
|
|
|
//确定选择区域
|
|
|
setyes(){
|
|
|
let that=this;
|
|
|
setyes() {
|
|
|
let that = this;
|
|
|
let valarr = that.data.valarr;
|
|
|
let i = valarr[0];
|
|
|
let j = valarr[1];
|
...
|
...
|
@@ -348,14 +347,14 @@ Page({ |
|
|
city: cityarr[j].city_name,
|
|
|
county: countryarr[k].country_name,
|
|
|
address: provincearr[i].province_name + cityarr[j].city_name + countryarr[k].country_name,
|
|
|
showapply:false
|
|
|
showapply: false
|
|
|
})
|
|
|
},
|
|
|
|
|
|
setshowapply(){
|
|
|
let that=this;
|
|
|
setshowapply() {
|
|
|
let that = this;
|
|
|
that.setData({
|
|
|
showapply:true
|
|
|
showapply: true
|
|
|
})
|
|
|
},
|
|
|
setshowapply_no() {
|
...
|
...
|
@@ -364,10 +363,9 @@ Page({ |
|
|
showapply: false
|
|
|
})
|
|
|
},
|
|
|
void_fun(){
|
|
|
},
|
|
|
bindRegionChange(e){
|
|
|
let that=this;
|
|
|
void_fun() {},
|
|
|
bindRegionChange(e) {
|
|
|
let that = this;
|
|
|
this.setData({
|
|
|
region: e.detail.value,
|
|
|
province: e.detail.value[0],
|
...
|
...
|
@@ -430,8 +428,8 @@ Page({ |
|
|
record: record
|
|
|
})
|
|
|
},
|
|
|
uploadImages(e){
|
|
|
let that=this;
|
|
|
uploadImages(e) {
|
|
|
let that = this;
|
|
|
let tem = e.currentTarget.dataset.tem;
|
|
|
that.uploadImage(tem);
|
|
|
|
...
|
...
|
@@ -488,72 +486,71 @@ Page({ |
|
|
},
|
|
|
submit() {
|
|
|
let that = this;
|
|
|
let err='';
|
|
|
let err = '';
|
|
|
//匹配中国邮政编码
|
|
|
// var AuglyTest_PostalCode = /^[0-9]\\d{5}$/;
|
|
|
//匹配身份证
|
|
|
var AuglyTest_ID = /\d{15}|\d{18}/;
|
|
|
//验证手机号
|
|
|
var AuglyTest_phone =/^1(3|4|5|6|7|8)\d{9}$/;
|
|
|
var AuglyTest_phone = /^1(3|4|5|6|7|8)\d{9}$/;
|
|
|
//验证腾讯QQ号
|
|
|
var AuglyTest_QQ = /^[1-9]*[1-9][0-9]*$/;
|
|
|
//匹配国内电话号码
|
|
|
var AuglyTest_tel = /(\d{3}-|\d{4}-)?(\d{8}|\d{7})?/;
|
|
|
//email地址
|
|
|
var AuglyTest_email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
|
|
|
if (that.data.photo==''){
|
|
|
if (that.data.photo == '') {
|
|
|
err = '请上传您的头像!'
|
|
|
} else if (that.data.name==''){
|
|
|
err='请输入您的姓名!'
|
|
|
} else if (that.data.sex==''){
|
|
|
} else if (that.data.name == '') {
|
|
|
err = '请输入您的姓名!'
|
|
|
} else if (that.data.sex == '') {
|
|
|
err = '请选择您的姓别!';
|
|
|
} else if (that.data.birthday==''){
|
|
|
} else if (that.data.birthday == '') {
|
|
|
err = '请选择您的出生日期!';
|
|
|
} else if (that.data.nation==''){
|
|
|
} else if (that.data.nation == '') {
|
|
|
err = '请选择您的民族!';
|
|
|
} else if (that.data.education==''){
|
|
|
} else if (that.data.education == '') {
|
|
|
err = '请选择您的学历!';
|
|
|
} else if (that.data.politics==''){
|
|
|
} else if (that.data.politics == '') {
|
|
|
err = '请选择您的政治面貌!';
|
|
|
} else if (that.data.unit==''){
|
|
|
err='请填写您的工作单位!';
|
|
|
} else if (that.data.duty==''){
|
|
|
} else if (that.data.unit == '') {
|
|
|
err = '请填写您的工作单位!';
|
|
|
} else if (that.data.duty == '') {
|
|
|
err = '请填写您的职务!';
|
|
|
} else if (that.data.addr==''){
|
|
|
err ='请填写您的通讯地址!';
|
|
|
} else if (that.data.postcode==''){
|
|
|
} else if (that.data.addr == '') {
|
|
|
err = '请填写您的通讯地址!';
|
|
|
} else if (that.data.postcode == '') {
|
|
|
err = '请填写您的邮编!';
|
|
|
} else if (that.data.school==''){
|
|
|
err ='请输入就读/毕业院校!';
|
|
|
} else if (that.data.card_number==''){
|
|
|
} else if (that.data.school == '') {
|
|
|
err = '请输入就读/毕业院校!';
|
|
|
} else if (that.data.card_number == '') {
|
|
|
err = '请输入您的身份证号!';
|
|
|
} else if (!AuglyTest_ID.test(that.data.card_number)){
|
|
|
} else if (!AuglyTest_ID.test(that.data.card_number)) {
|
|
|
err = '请输入正确的身份证号!';
|
|
|
}else if (that.data.move_phone==''){
|
|
|
} else if (that.data.move_phone == '') {
|
|
|
err = '请输入您的移动电话!';
|
|
|
} else if (!AuglyTest_phone.test(that.data.move_phone)){
|
|
|
} else if (!AuglyTest_phone.test(that.data.move_phone)) {
|
|
|
err = '请输入正确的移动电话!';
|
|
|
}else if (that.data.email==''){
|
|
|
} else if (that.data.email == '') {
|
|
|
err = '请输入您的电子邮箱!';
|
|
|
} else if (!AuglyTest_email.test(that.data.email)){
|
|
|
} else if (!AuglyTest_email.test(that.data.email)) {
|
|
|
err = '请输入正确的电子邮箱!';
|
|
|
}else if (that.data.urgency_phone==''){
|
|
|
} else if (that.data.urgency_phone == '') {
|
|
|
err = '请输入紧急联系人及电话!';
|
|
|
} else if (that.data.qq==''){
|
|
|
} else if (that.data.qq == '') {
|
|
|
err = '请输入您的QQ!';
|
|
|
} else if (!AuglyTest_QQ.test(that.data.qq)){
|
|
|
} else if (!AuglyTest_QQ.test(that.data.qq)) {
|
|
|
err = '请输入正确的QQ号!';
|
|
|
}
|
|
|
else if (that.data.address==''){
|
|
|
} else if (that.data.address == '') {
|
|
|
err = '请选择您的服务区域';
|
|
|
} else if(that.data.type==''){
|
|
|
} else if (that.data.type == '') {
|
|
|
err = '请选择您的志愿类别!';
|
|
|
} else if (that.data.front_card==''){
|
|
|
} else if (that.data.front_card == '') {
|
|
|
err = '请上传身份证正面!';
|
|
|
} else if (that.data.reverse_card==''){
|
|
|
} else if (that.data.reverse_card == '') {
|
|
|
err = '请上传身份证反面!';
|
|
|
}
|
|
|
if(err==''){
|
|
|
if (err == '') {
|
|
|
let record = that.data.record;
|
|
|
let record_start_time = [];
|
|
|
let record_end_time = [];
|
...
|
...
|
@@ -613,14 +610,13 @@ Page({ |
|
|
duration: 2000
|
|
|
})
|
|
|
|
|
|
setTimeout(function(){
|
|
|
setTimeout(function() {
|
|
|
wx.switchTab({
|
|
|
url: '/pages/my/my'
|
|
|
})
|
|
|
},1000)
|
|
|
}).catch((err) => {
|
|
|
})
|
|
|
}else{
|
|
|
}, 1000)
|
|
|
}).catch((err) => {})
|
|
|
} else {
|
|
|
wx.showToast({
|
|
|
title: err,
|
|
|
icon: 'none',
|
...
|
...
|
@@ -628,23 +624,23 @@ Page({ |
|
|
})
|
|
|
}
|
|
|
},
|
|
|
getdatalist(){
|
|
|
let that=this;
|
|
|
let url ='/index/member_center/edit';
|
|
|
let params={
|
|
|
'id':that.data.id
|
|
|
getdatalist() {
|
|
|
let that = this;
|
|
|
let url = '/index/member_center/edit';
|
|
|
let params = {
|
|
|
'id': that.data.id
|
|
|
};
|
|
|
let head={
|
|
|
'XX-Token':wx.getStorageSync('token')
|
|
|
let head = {
|
|
|
'XX-Token': wx.getStorageSync('token')
|
|
|
}
|
|
|
app.post(url, params, head).then((res)=>{
|
|
|
app.post(url, params, head).then((res) => {
|
|
|
let provincearr = that.data.provincearr;
|
|
|
let cityarr = that.data.cityarr;
|
|
|
let countryarr = that.data.countryarr;
|
|
|
let val=[0,0,0];
|
|
|
for (let i=0; i<provincearr.length;i++ ){
|
|
|
if (provincearr[i].province_name == res.province){
|
|
|
val[0]=i;
|
|
|
let val = [0, 0, 0];
|
|
|
for (let i = 0; i < provincearr.length; i++) {
|
|
|
if (provincearr[i].province_name == res.province) {
|
|
|
val[0] = i;
|
|
|
}
|
|
|
}
|
|
|
for (let i = 0; i < cityarr.length; i++) {
|
...
|
...
|
@@ -675,7 +671,7 @@ Page({ |
|
|
nation: res.nation,
|
|
|
photo: res.photo,
|
|
|
politics: res.politics,
|
|
|
postcode:res.postcode,
|
|
|
postcode: res.postcode,
|
|
|
province: res.province,
|
|
|
qq: res.qq,
|
|
|
record: res.record,
|
...
|
...
|
@@ -686,7 +682,7 @@ Page({ |
|
|
urgency_phone: res.urgency_phone,
|
|
|
type: res.type
|
|
|
})
|
|
|
}).catch((err)=>{
|
|
|
}).catch((err) => {
|
|
|
|
|
|
})
|
|
|
},
|
...
|
...
|
@@ -694,10 +690,11 @@ Page({ |
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function(options) {
|
|
|
let that=this;
|
|
|
let that = this;
|
|
|
that.setData({
|
|
|
is_submit: options.is_submit,
|
|
|
id: options.id
|
|
|
id: options.id,
|
|
|
page_type: options.type ? options.type : null
|
|
|
})
|
|
|
let now = new Date();
|
|
|
let time = now.getFullYear() + "-" + ((now.getMonth() + 1) < 10 ? "0" : "") + (now.getMonth() + 1) + "-" + (now.getDate() < 10 ? "0" : "") + now.getDate();
|
...
|
...
|
|