2023-08-10 01:21:29 +08:00
|
|
|
|
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 });
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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) {
|
2023-08-27 13:20:30 +08:00
|
|
|
|
this.onClickShow();
|
2023-08-10 01:21:29 +08:00
|
|
|
|
var that = this;
|
|
|
|
|
//获取缓存数据
|
|
|
|
|
wx.getStorage({
|
|
|
|
|
key: 'userinfo',
|
|
|
|
|
success:function(res){
|
2023-08-27 13:20:30 +08:00
|
|
|
|
that.onClickHide();
|
2023-08-10 01:21:29 +08:00
|
|
|
|
that.setData({
|
|
|
|
|
loginName:res.data.loginName,
|
2023-08-27 13:20:30 +08:00
|
|
|
|
})
|
|
|
|
|
if(that.data.loginName == null || that.data.loginName == ""){
|
|
|
|
|
app.toast("数据异常!!");
|
|
|
|
|
wx.redirectTo({
|
|
|
|
|
url: '../updatePassword/updatePassword'
|
|
|
|
|
})
|
|
|
|
|
}
|
2023-08-10 01:21:29 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 添加预警信息
|
|
|
|
|
*/
|
|
|
|
|
submit:function(){
|
|
|
|
|
var that = this;
|
|
|
|
|
if(that.data.oldPsw == ''){
|
|
|
|
|
app.toast("请输入旧密码!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(that.data.password == ''){
|
|
|
|
|
app.toast("请确认新密码!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(that.data.newPsw!='' && that.data.newPsw!=that.data.password){
|
|
|
|
|
app.toast("两次密码输入不一致!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-08-27 13:20:30 +08:00
|
|
|
|
if(that.data.oldPsw.length<6){
|
2023-08-10 01:21:29 +08:00
|
|
|
|
app.toast("请输入旧密码长度 [6-20]位字符!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-08-27 13:20:30 +08:00
|
|
|
|
if(that.data.newPsw.length<6){
|
2023-08-10 01:21:29 +08:00
|
|
|
|
app.toast("请输入新密码长度 [6-20]位字符!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-08-27 13:20:30 +08:00
|
|
|
|
if(that.data.password.length<6){
|
2023-08-10 01:21:29 +08:00
|
|
|
|
app.toast("请输入确认密码长度 [6-20]位字符!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
that.onClickShow();
|
|
|
|
|
wx.request({
|
|
|
|
|
header: {
|
|
|
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
|
|
|
},
|
2023-08-27 13:20:30 +08:00
|
|
|
|
url:app.globalData.reqUrl+'/wechat/updatePassword',
|
2023-08-10 01:21:29 +08:00
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
})
|