You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
188 lines
6.0 KiB
JavaScript
188 lines
6.0 KiB
JavaScript
|
2 years ago
|
// pages/changeName/index.js
|
||
|
|
const app = getApp();
|
||
|
|
|
||
|
|
Page({
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面的初始数据
|
||
|
|
*/
|
||
|
|
data: {
|
||
|
|
updateTag: null,
|
||
|
|
userName: null
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面加载
|
||
|
|
*/
|
||
|
|
onLoad: function (options) {
|
||
|
|
var that = this;
|
||
|
|
this.data.updateTag = options.updateTag;
|
||
|
|
if (options.updateTag == 0) {
|
||
|
|
this.data.userName = options.userName;
|
||
|
|
if (options.userName == null || options.userName == 'null') {
|
||
|
|
this.data.userName = '';
|
||
|
|
}
|
||
|
|
this.setData({
|
||
|
|
updateTag: options.updateTag,
|
||
|
|
userName: that.data.userName,
|
||
|
|
});
|
||
|
|
wx.setNavigationBarTitleTitle({
|
||
|
|
title: '修改昵称'
|
||
|
|
})
|
||
|
|
} else if (options.updateTag == 1) {
|
||
|
|
this.data.height = options.height;
|
||
|
|
if (options.height == null || options.height == 'null') {
|
||
|
|
this.data.height = '';
|
||
|
|
}
|
||
|
|
this.setData({
|
||
|
|
updateTag: options.updateTag,
|
||
|
|
height: that.data.height,
|
||
|
|
});
|
||
|
|
wx.setNavigationBarTitleTitle({
|
||
|
|
title: '修改身高'
|
||
|
|
})
|
||
|
|
} else if (options.updateTag == 2) {
|
||
|
|
this.data.weight = options.weight;
|
||
|
|
if (options.weight == null || options.weight == 'null') {
|
||
|
|
this.data.weight = '';
|
||
|
|
}
|
||
|
|
this.setData({
|
||
|
|
updateTag: options.updateTag,
|
||
|
|
weight: that.data.weight,
|
||
|
|
});
|
||
|
|
wx.setNavigationBarTitleTitle({
|
||
|
|
title: '修改体重'
|
||
|
|
})
|
||
|
|
} else if (options.updateTag == 4) {
|
||
|
|
this.data.liveAddress = options.liveAddress;
|
||
|
|
if (options.liveAddress == null || options.liveAddress == 'null') {
|
||
|
|
this.data.liveAddress = '';
|
||
|
|
}
|
||
|
|
this.setData({
|
||
|
|
updateTag: options.updateTag,
|
||
|
|
liveAddress: that.data.liveAddress,
|
||
|
|
});
|
||
|
|
wx.setNavigationBarTitleTitle({
|
||
|
|
title: '修改现住址'
|
||
|
|
})
|
||
|
|
}else if (options.updateTag == 5) {
|
||
|
|
this.data.emergencyName = options.emergencyName;
|
||
|
|
if (options.emergencyName == null || options.emergencyName == 'null') {
|
||
|
|
this.data.emergencyName = '';
|
||
|
|
}
|
||
|
|
this.setData({
|
||
|
|
updateTag: options.updateTag,
|
||
|
|
emergencyName: that.data.emergencyName,
|
||
|
|
});
|
||
|
|
wx.setNavigationBarTitleTitle({
|
||
|
|
title: '修改紧急联系人'
|
||
|
|
})
|
||
|
|
} else if (options.updateTag == 6) {
|
||
|
|
this.data.emergencyRelation = options.emergencyRelation;
|
||
|
|
if (options.emergencyRelation == null || options.emergencyRelation == 'null') {
|
||
|
|
this.data.emergencyRelation = '';
|
||
|
|
}
|
||
|
|
this.setData({
|
||
|
|
updateTag: options.updateTag,
|
||
|
|
emergencyRelation: that.data.emergencyRelation,
|
||
|
|
});
|
||
|
|
wx.setNavigationBarTitleTitle({
|
||
|
|
title: '修改紧急联系人关系'
|
||
|
|
})
|
||
|
|
} else if (options.updateTag == 7) {
|
||
|
|
this.data.emergencyTel = options.emergencyTel;
|
||
|
|
if (options.emergencyTel == null || options.emergencyTel == 'null') {
|
||
|
|
this.data.emergencyTel = '';
|
||
|
|
}
|
||
|
|
this.setData({
|
||
|
|
updateTag: options.updateTag,
|
||
|
|
emergencyTel: that.data.emergencyTel,
|
||
|
|
});
|
||
|
|
wx.setNavigationBarTitleTitle({
|
||
|
|
title: '修改紧急联系人手机号'
|
||
|
|
})
|
||
|
|
}
|
||
|
|
},
|
||
|
|
formSubmit: function (e) {
|
||
|
|
var that = this;
|
||
|
|
var dataParam;
|
||
|
|
if (that.data.updateTag == 0) {
|
||
|
|
|
||
|
|
if (app.isEmptyCheck(e.detail.value.userName)) {
|
||
|
|
app.showTips(that, "请填写昵称");
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
dataParam = { 'userName': e.detail.value.userName, 'updateTag': that.data.updateTag };
|
||
|
|
} else if (that.data.updateTag == 1) {
|
||
|
|
|
||
|
|
if (app.isEmptyCheck(e.detail.value.height)) {
|
||
|
|
app.showTips(that, "请填写身高");
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
dataParam = { 'height': e.detail.value.height, 'updateTag': that.data.updateTag };
|
||
|
|
} else if (that.data.updateTag == 2) {
|
||
|
|
if (app.isEmptyCheck(e.detail.value.weight)) {
|
||
|
|
app.showTips(that, "请填写体重");
|
||
|
|
return
|
||
|
|
}
|
||
|
|
dataParam = { 'weight': e.detail.value.weight, 'updateTag': that.data.updateTag };
|
||
|
|
} else if (that.data.updateTag == 4) {
|
||
|
|
if (app.isEmptyCheck(e.detail.value.liveAddress)) {
|
||
|
|
app.showTips(that, "请填写现住址");
|
||
|
|
return
|
||
|
|
}
|
||
|
|
dataParam = { 'liveAddress': e.detail.value.liveAddress, 'updateTag': that.data.updateTag };
|
||
|
|
} else if (that.data.updateTag == 5) {
|
||
|
|
if (app.isEmptyCheck(e.detail.value.emergencyName)) {
|
||
|
|
app.showTips(that, "请填写紧急联系人");
|
||
|
|
return
|
||
|
|
}
|
||
|
|
dataParam = { 'emergencyName': e.detail.value.emergencyName, 'updateTag': that.data.updateTag };
|
||
|
|
} else if (that.data.updateTag == 6) {
|
||
|
|
if (app.isEmptyCheck(e.detail.value.emergencyRelation)) {
|
||
|
|
app.showTips(that, "请填写紧急联系人关系");
|
||
|
|
return
|
||
|
|
}
|
||
|
|
dataParam = { 'emergencyRelation': e.detail.value.emergencyRelation, 'updateTag': that.data.updateTag };
|
||
|
|
} else if (that.data.updateTag == 7) {
|
||
|
|
|
||
|
|
var myreg = /^[1][3456789][0-9]{9}$/;
|
||
|
|
console.log(myreg.test(e.detail.value.emergencyTel));
|
||
|
|
|
||
|
|
|
||
|
|
if (app.isEmptyCheck(e.detail.value.emergencyTel)) {
|
||
|
|
app.showTips(that, "请填写紧急联系人手机号");
|
||
|
|
return
|
||
|
|
}else if (!myreg.test(e.detail.value.emergencyTel)){
|
||
|
|
app.showTips(that, "请填写正确的手机号");
|
||
|
|
return
|
||
|
|
}
|
||
|
|
dataParam = { 'emergencyTel': e.detail.value.emergencyTel, 'updateTag': that.data.updateTag };
|
||
|
|
}
|
||
|
|
|
||
|
|
wx.request({
|
||
|
|
url: app.globalData.ip + '/user/updateMyInfo',
|
||
|
|
data: dataParam,
|
||
|
|
header: app.globalData.header,
|
||
|
|
method: "POST",
|
||
|
|
success: function (res) {
|
||
|
|
console.log(res);
|
||
|
|
if (res.data.status == 200) {
|
||
|
|
/*wx.redirectTo({
|
||
|
|
url: '../myInfo/index'
|
||
|
|
})*/
|
||
|
|
wx.navigateBack({
|
||
|
|
delta: 1
|
||
|
|
})
|
||
|
|
} else if (res.data.status == 9999) {
|
||
|
|
app.dialogNotLogin();
|
||
|
|
} else {
|
||
|
|
app.showTips(that, res.data.msg);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},
|
||
|
|
|
||
|
|
})
|