162 lines
3.5 KiB
JavaScript
162 lines
3.5 KiB
JavaScript
|
const app = getApp()
|
|||
|
Page({
|
|||
|
/**
|
|||
|
* 页面的初始数据
|
|||
|
*/
|
|||
|
data: {
|
|||
|
loginName:null,
|
|||
|
oldPsw:'',
|
|||
|
newPsw:'',
|
|||
|
password:'',
|
|||
|
showOldPass:true,
|
|||
|
showNewPass:true,
|
|||
|
showPassWord:true,
|
|||
|
//数据加载参数
|
|||
|
show:false,
|
|||
|
},
|
|||
|
|
|||
|
onClickShow() {
|
|||
|
this.setData({ show: true });
|
|||
|
},
|
|||
|
|
|||
|
onClickHide() {
|
|||
|
this.setData({ show: false });
|
|||
|
},
|
|||
|
|
|||
|
//获取填写的旧密码信息
|
|||
|
oldPsw:function(even){
|
|||
|
this.setData({
|
|||
|
oldPsw:even.detail.value
|
|||
|
})
|
|||
|
},
|
|||
|
//获取填写的新密码信息
|
|||
|
newPsw:function(even){
|
|||
|
this.setData({
|
|||
|
newPsw:even.detail.value
|
|||
|
})
|
|||
|
},
|
|||
|
//获取填写的新密码信息
|
|||
|
password:function(even){
|
|||
|
this.setData({
|
|||
|
password:even.detail.value
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
seeTap1:function(){
|
|||
|
let that = this;
|
|||
|
this.setData({
|
|||
|
// 切换图标
|
|||
|
showOldPass:!that.data.showOldPass
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
seeTap2:function(){
|
|||
|
let that = this;
|
|||
|
this.setData({
|
|||
|
// 切换图标
|
|||
|
showNewPass:!that.data.showNewPass
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
seeTap3:function(){
|
|||
|
let that = this;
|
|||
|
this.setData({
|
|||
|
// 切换图标
|
|||
|
showPassWord:!that.data.showPassWord
|
|||
|
})
|
|||
|
if(this.data.newPsw!='' && this.data.newPsw!=this.data.password){
|
|||
|
app.toast("两次密码输入不一致!");
|
|||
|
}
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面加载
|
|||
|
*/
|
|||
|
onLoad: function (options) {
|
|||
|
this.onClickShow();
|
|||
|
var that = this;
|
|||
|
//获取缓存数据
|
|||
|
wx.getStorage({
|
|||
|
key: 'userinfo',
|
|||
|
success:function(res){
|
|||
|
that.setData({
|
|||
|
loginName:res.data.loginName,
|
|||
|
})
|
|||
|
}
|
|||
|
})
|
|||
|
this.onClickHide();
|
|||
|
},
|
|||
|
/**
|
|||
|
* 添加预警信息
|
|||
|
*/
|
|||
|
submit:function(){
|
|||
|
var that = this;
|
|||
|
if(that.data.oldPsw == ''){
|
|||
|
app.toast("请输入旧密码!");
|
|||
|
return;
|
|||
|
}
|
|||
|
if(that.data.newPsw == ''){
|
|||
|
app.toast("请输入旧密码!");
|
|||
|
return;
|
|||
|
}
|
|||
|
if(that.data.password == ''){
|
|||
|
app.toast("请确认新密码!");
|
|||
|
return;
|
|||
|
}
|
|||
|
if(that.data.newPsw!='' && that.data.newPsw!=that.data.password){
|
|||
|
app.toast("两次密码输入不一致!");
|
|||
|
return;
|
|||
|
}
|
|||
|
if(this.data.oldPsw.length<6){
|
|||
|
app.toast("请输入旧密码长度 [6-20]位字符!");
|
|||
|
return;
|
|||
|
}
|
|||
|
if(this.data.newPsw.length<6){
|
|||
|
app.toast("请输入新密码长度 [6-20]位字符!");
|
|||
|
return;
|
|||
|
}
|
|||
|
if(this.data.password.length<6){
|
|||
|
app.toast("请输入确认密码长度 [6-20]位字符!");
|
|||
|
return;
|
|||
|
}
|
|||
|
that.onClickShow();
|
|||
|
wx.request({
|
|||
|
header: {
|
|||
|
'content-type': 'application/x-www-form-urlencoded'
|
|||
|
},
|
|||
|
url:app.globalData.reqUrl+'/weixin/userLogin/updatePassword',
|
|||
|
data:{
|
|||
|
loginName:that.data.loginName,
|
|||
|
oldPsw:that.data.oldPsw,
|
|||
|
newPsw:that.data.newPsw,
|
|||
|
password:that.data.password
|
|||
|
},
|
|||
|
method:"POST",
|
|||
|
success:function(res){
|
|||
|
that.onClickHide();
|
|||
|
if(res.data && res.data.data=="200"){
|
|||
|
wx.clearStorageSync();
|
|||
|
wx.setStorageSync('isReload', "1");
|
|||
|
app.toast("密码修改成功!");
|
|||
|
wx.redirectTo({
|
|||
|
url: '../login/login',
|
|||
|
});
|
|||
|
}else{
|
|||
|
app.toast(res.data.info);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
//返回到项目概况页面
|
|||
|
goGCLB:function(){
|
|||
|
wx.redirectTo({
|
|||
|
url: '../xiangmugaikuang/xiangmugaikuang'
|
|||
|
})
|
|||
|
},
|
|||
|
//修改密码
|
|||
|
QRXG:function(){
|
|||
|
this.submit();
|
|||
|
}
|
|||
|
})
|