114 lines
2.3 KiB
JavaScript
114 lines
2.3 KiB
JavaScript
import {
|
|
loginOut,
|
|
updatePwd,
|
|
} from '../../api/login'
|
|
import {
|
|
removeToken
|
|
} from '../../utils/auth'
|
|
const app = getApp()
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
loginName: null,
|
|
oldPsw: '',
|
|
newPsw: '',
|
|
password: '',
|
|
showOldPass: true,
|
|
showNewPass: true,
|
|
showPassWord: true
|
|
},
|
|
|
|
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) {
|
|
|
|
},
|
|
|
|
/**
|
|
* 添加预警信息
|
|
*/
|
|
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;
|
|
}
|
|
if (that.data.oldPsw.length < 6) {
|
|
app.toast("请输入旧密码长度 [6-20]位字符!");
|
|
return;
|
|
}
|
|
if (that.data.newPsw.length < 6) {
|
|
app.toast("请输入新密码长度 [6-20]位字符!");
|
|
return;
|
|
}
|
|
if (that.data.password.length < 6) {
|
|
app.toast("请输入确认密码长度 [6-20]位字符!");
|
|
return;
|
|
}
|
|
let formData = {
|
|
oldPsw: that.data.oldPsw,
|
|
newPsw: that.data.newPsw,
|
|
cfmPsw: that.data.password
|
|
}
|
|
updatePwd(formData).then(res => {
|
|
if (res.data == "200") {
|
|
loginOut().then(response => {
|
|
app.toast("密码修改成功,请重新登录!", 'success');
|
|
removeToken();
|
|
wx.redirectTo({
|
|
url: '../login/login',
|
|
});
|
|
});
|
|
}
|
|
});
|
|
},
|
|
|
|
//返回到项目概况页面
|
|
goGCLB: function () {
|
|
wx.redirectTo({
|
|
url: '../index/index'
|
|
})
|
|
},
|
|
//修改密码
|
|
QRXG: function () {
|
|
this.submit();
|
|
}
|
|
}) |