|
@@ -7,122 +7,161 @@ Page({
|
|
data: {
|
|
data: {
|
|
userInfo: {},
|
|
userInfo: {},
|
|
isLogin: false,
|
|
isLogin: false,
|
|
|
|
+ isBindPhone:0,
|
|
sexType: [{
|
|
sexType: [{
|
|
value: 1,
|
|
value: 1,
|
|
text: '男'
|
|
text: '男'
|
|
}, {
|
|
}, {
|
|
value: 2,
|
|
value: 2,
|
|
text: '女'
|
|
text: '女'
|
|
|
|
+ }, {
|
|
|
|
+ value: 3,
|
|
|
|
+ text: '保密'
|
|
}],
|
|
}],
|
|
sexIndex: null,
|
|
sexIndex: null,
|
|
- phone: null,
|
|
|
|
|
|
+ carNum: null,
|
|
email: null,
|
|
email: null,
|
|
checkPass: false,
|
|
checkPass: false,
|
|
errorMsg: ''
|
|
errorMsg: ''
|
|
},
|
|
},
|
|
|
|
+
|
|
inputSex(e) {
|
|
inputSex(e) {
|
|
- //console.log(this.data.sexType[e.detail.value]);
|
|
|
|
- this.setData({
|
|
|
|
- sexIndex: e.detail.value
|
|
|
|
- });
|
|
|
|
- this.checkAll();
|
|
|
|
- },
|
|
|
|
- inputPhone(e) {
|
|
|
|
this.setData({
|
|
this.setData({
|
|
- phone: e.detail.value
|
|
|
|
|
|
+ sexIndex: parseInt(e.detail.value)+1
|
|
});
|
|
});
|
|
- this.checkAll();
|
|
|
|
|
|
+ let userdata= {
|
|
|
|
+ sexIndex: e.detail.value,
|
|
|
|
+ carNum: null,
|
|
|
|
+ email: null,
|
|
|
|
+ };
|
|
|
|
+ this.bindUpdateUser(userdata);
|
|
},
|
|
},
|
|
- inputEmail(e) {
|
|
|
|
- this.setData({
|
|
|
|
- email: e.detail.value
|
|
|
|
|
|
+
|
|
|
|
+ inputCarNum(e){
|
|
|
|
+ let that = this;
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: '修改车牌号',
|
|
|
|
+ showCancel:true,
|
|
|
|
+ editable: true,
|
|
|
|
+ confirmColor:'#36a9a6',
|
|
|
|
+ success: function (res1) {
|
|
|
|
+ if (res1.confirm) {
|
|
|
|
+ let carNum = res1.content;
|
|
|
|
+ that.confirmCarNum(carNum);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
});
|
|
});
|
|
- this.checkAll();
|
|
|
|
- },
|
|
|
|
- checkPhone() {
|
|
|
|
- if (!(/^1[3456789]\d{9}$/.test(this.data.phone))) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- return true;
|
|
|
|
},
|
|
},
|
|
- checkMail() {
|
|
|
|
- if (!(/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(this.data.email))) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- return true;
|
|
|
|
- },
|
|
|
|
- checkAll() {
|
|
|
|
- if (this.data.userInfo.sex == null || (this.data.userInfo.sex != 1 && this.data.userInfo.sex != 2)){
|
|
|
|
- if (!this.data.sexIndex) {
|
|
|
|
- this.setData({
|
|
|
|
- errorMsg: '请选择性别'
|
|
|
|
- });
|
|
|
|
- this.setData({
|
|
|
|
- checkPass: false
|
|
|
|
- });
|
|
|
|
- return;
|
|
|
|
- } else {
|
|
|
|
- this.setData({
|
|
|
|
- errorMsg: ''
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (!this.checkPhone()) {
|
|
|
|
- this.setData({
|
|
|
|
- errorMsg: '手机号输入有误,请重新输入'
|
|
|
|
- });
|
|
|
|
- this.setData({
|
|
|
|
- checkPass: false
|
|
|
|
|
|
+
|
|
|
|
+ confirmCarNum(carNum) {
|
|
|
|
+ if (!this.checkCarNum(carNum)) {
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: '提示',
|
|
|
|
+ showCancel:false,
|
|
|
|
+ content: '车牌号输入有误,请重新输入',
|
|
|
|
+ confirmColor:'#36a9a6',
|
|
});
|
|
});
|
|
return;
|
|
return;
|
|
} else {
|
|
} else {
|
|
this.setData({
|
|
this.setData({
|
|
|
|
+ carNum: carNum,
|
|
errorMsg: ''
|
|
errorMsg: ''
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- if (!this.checkMail()) {
|
|
|
|
- this.setData({
|
|
|
|
- errorMsg: '邮箱输入有误,请重新输入'
|
|
|
|
- });
|
|
|
|
- this.setData({
|
|
|
|
- checkPass: false
|
|
|
|
|
|
+ let userdata= {
|
|
|
|
+ sexIndex: null,
|
|
|
|
+ carNum: carNum,
|
|
|
|
+ email: null,
|
|
|
|
+ };
|
|
|
|
+ this.bindUpdateUser(userdata);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ inputEmail(e) {
|
|
|
|
+ let that = this;
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: '修改邮箱',
|
|
|
|
+ showCancel:true,
|
|
|
|
+ editable: true,
|
|
|
|
+ confirmColor:'#36a9a6',
|
|
|
|
+ success: function (res1) {
|
|
|
|
+ if (res1.confirm) {
|
|
|
|
+ let email = res1.content;
|
|
|
|
+ that.confirmEmail(email);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ confirmEmail(email) {
|
|
|
|
+ if (!this.checkMail(email)) {
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: '提示',
|
|
|
|
+ showCancel:false,
|
|
|
|
+ content: '邮箱输入有误,请重新输入',
|
|
|
|
+ confirmColor:'#36a9a6',
|
|
});
|
|
});
|
|
return;
|
|
return;
|
|
} else {
|
|
} else {
|
|
this.setData({
|
|
this.setData({
|
|
|
|
+ email: email,
|
|
errorMsg: ''
|
|
errorMsg: ''
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- this.setData({
|
|
|
|
- checkPass: true
|
|
|
|
- });
|
|
|
|
|
|
+ let userdata= {
|
|
|
|
+ sexIndex: null,
|
|
|
|
+ carNum: null,
|
|
|
|
+ email: email
|
|
|
|
+ };
|
|
|
|
+ this.bindUpdateUser(userdata);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ checkMail(email) {
|
|
|
|
+ if (!(/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(email))) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
},
|
|
},
|
|
- bindUpdateUser() {
|
|
|
|
|
|
+ checkCarNum(carNum){
|
|
|
|
+ if (carNum){
|
|
|
|
+ // if (!(/^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$/.test(this.data.carNum))) {
|
|
|
|
+ if (!/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领].*$/.test(carNum)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ bindUpdateUser(userdata) {
|
|
let that = this;
|
|
let that = this;
|
|
|
|
+ if(this.data.isBindPhone==0){
|
|
|
|
+ let url = `/pages/bindPhone/bindPhone`;
|
|
|
|
+ wx.navigateTo({
|
|
|
|
+ url
|
|
|
|
+ });
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
let loginName = this.data.userInfo.loginName;
|
|
let loginName = this.data.userInfo.loginName;
|
|
let {
|
|
let {
|
|
sexIndex,
|
|
sexIndex,
|
|
- phone,
|
|
|
|
|
|
+ carNum: license_number,
|
|
email
|
|
email
|
|
- } = this.data;
|
|
|
|
|
|
+ } = userdata;
|
|
var sex = null;
|
|
var sex = null;
|
|
if (sexIndex!=null){
|
|
if (sexIndex!=null){
|
|
sex = this.data.sexType[sexIndex].value;
|
|
sex = this.data.sexType[sexIndex].value;
|
|
- }else{
|
|
|
|
- sex = this.data.userInfo.sex;
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
wx.request({
|
|
wx.request({
|
|
url: getApp().globalData.postHeadAgreement + '/restapi/wechat/updateUser',
|
|
url: getApp().globalData.postHeadAgreement + '/restapi/wechat/updateUser',
|
|
data: {
|
|
data: {
|
|
loginName,
|
|
loginName,
|
|
sex: sex,
|
|
sex: sex,
|
|
- phonenumber: phone,
|
|
|
|
|
|
+ license_number,
|
|
email,
|
|
email,
|
|
},
|
|
},
|
|
method: 'POST',
|
|
method: 'POST',
|
|
success(res1) {
|
|
success(res1) {
|
|
- //console.log(res1);
|
|
|
|
- //console.log(res1.data.code == 1);
|
|
|
|
if (res1.data.code == 1) {
|
|
if (res1.data.code == 1) {
|
|
that.setData({
|
|
that.setData({
|
|
errorMsg: res1.data.msg
|
|
errorMsg: res1.data.msg
|
|
@@ -132,7 +171,13 @@ Page({
|
|
//跳转到上一页
|
|
//跳转到上一页
|
|
wx.setStorageSync("userInfo", res1.data);
|
|
wx.setStorageSync("userInfo", res1.data);
|
|
wx.setStorageSync("isLogin", true);
|
|
wx.setStorageSync("isLogin", true);
|
|
- wx.navigateBack();
|
|
|
|
|
|
+ let userInfo = wx.getStorageSync('userInfo');
|
|
|
|
+ that.setData({
|
|
|
|
+ userInfo: userInfo
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // wx.navigateBack();
|
|
//let url = `/pages/ucenter/index/index`;
|
|
//let url = `/pages/ucenter/index/index`;
|
|
//wx.redirectTo({
|
|
//wx.redirectTo({
|
|
//url
|
|
//url
|
|
@@ -164,17 +209,22 @@ Page({
|
|
onShow: function() {
|
|
onShow: function() {
|
|
let userInfo = wx.getStorageSync('userInfo');
|
|
let userInfo = wx.getStorageSync('userInfo');
|
|
let isLogin = wx.getStorageSync('isLogin');
|
|
let isLogin = wx.getStorageSync('isLogin');
|
|
|
|
+ let isBindPhone = wx.getStorageSync('isBindPhone');
|
|
|
|
|
|
// 页面显示
|
|
// 页面显示
|
|
if (userInfo && isLogin) {
|
|
if (userInfo && isLogin) {
|
|
//userInfo.flag = true;
|
|
//userInfo.flag = true;
|
|
- //console.log(userInfo);
|
|
|
|
|
|
+ console.log(userInfo);
|
|
this.setData({
|
|
this.setData({
|
|
userInfo: userInfo,
|
|
userInfo: userInfo,
|
|
isLogin: isLogin,
|
|
isLogin: isLogin,
|
|
- phone: userInfo.phonenumber,
|
|
|
|
- email:userInfo.email
|
|
|
|
|
|
+ isBindPhone:isBindPhone,
|
|
|
|
+ carNum: userInfo.license_number,
|
|
|
|
+ email:userInfo.email,
|
|
|
|
+ sexIndex:userInfo.sex
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
//未登录信息
|
|
//未登录信息
|
|
this.setData({
|
|
this.setData({
|