2025-09-22 15:17:59 +08:00
|
|
|
import { removeToken } from "../../../utils/auth";
|
|
|
|
import { loginOut, updatePwd, findOpenUserMsgId } from "../../../api/login";
|
|
|
|
import cfg from "../../../config";
|
|
|
|
const app = getApp();
|
2025-02-16 17:19:52 +08:00
|
|
|
Component({
|
2025-09-22 15:17:59 +08:00
|
|
|
/**数据监听 */
|
|
|
|
observers: {},
|
|
|
|
/**
|
|
|
|
* 组件的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
show: false,
|
|
|
|
userData: {},
|
|
|
|
resPas: false,
|
|
|
|
oldPsw: "",
|
|
|
|
newPsw: "",
|
|
|
|
password: "",
|
|
|
|
showOldPass: true,
|
|
|
|
showNewPass: true,
|
|
|
|
showPassWord: true,
|
|
|
|
binding: false,
|
|
|
|
msgOpenId: "",
|
|
|
|
baseImgUrl: cfg.baseImgUrl,
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.setData({
|
|
|
|
userData: app.globalData.userData,
|
|
|
|
loginName: app.globalData.userData.userName,
|
|
|
|
msgOpenId: "",
|
|
|
|
});
|
|
|
|
},
|
2025-02-16 17:19:52 +08:00
|
|
|
|
2025-09-22 15:17:59 +08:00
|
|
|
/**
|
|
|
|
* 组件的方法列表
|
|
|
|
*/
|
|
|
|
methods: {
|
|
|
|
loadUserInfo() {
|
|
|
|
let that = this;
|
|
|
|
//获取缓存数据
|
|
|
|
wx.getStorage({
|
|
|
|
key: "userinfo",
|
|
|
|
success: function (res) {
|
|
|
|
findOpenUserMsgId(res.data.openId).then((vo) => {
|
|
|
|
if (vo.code == 200 && vo.data) {
|
|
|
|
res.data.msgOpenId = vo.data.msgOpenId;
|
|
|
|
wx.setStorage({
|
|
|
|
key: "userinfo",
|
|
|
|
data: res.data,
|
|
|
|
});
|
|
|
|
that.setData({
|
|
|
|
show: true,
|
|
|
|
userData: res.data,
|
|
|
|
loginName: res.data.loginName,
|
|
|
|
msgOpenId: res.data.msgOpenId || "",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
2025-02-16 17:19:52 +08:00
|
|
|
|
2025-09-22 15:17:59 +08:00
|
|
|
showPopup() {
|
|
|
|
this.setData({
|
|
|
|
show: true,
|
|
|
|
});
|
|
|
|
},
|
2025-02-16 17:19:52 +08:00
|
|
|
|
2025-09-22 15:17:59 +08:00
|
|
|
/**
|
|
|
|
* 关闭用户详情
|
|
|
|
*/
|
|
|
|
closePopup() {
|
|
|
|
this.setData({
|
|
|
|
show: false,
|
|
|
|
});
|
|
|
|
},
|
2025-02-16 17:19:52 +08:00
|
|
|
|
2025-09-22 15:17:59 +08:00
|
|
|
//修改密码
|
|
|
|
resPassword: function () {
|
|
|
|
this.setData({
|
|
|
|
resPas: true,
|
|
|
|
});
|
|
|
|
},
|
2025-02-16 17:19:52 +08:00
|
|
|
|
2025-09-22 15:17:59 +08:00
|
|
|
//绑定公众号
|
|
|
|
binding: function () {
|
|
|
|
app.initWxAuth();
|
|
|
|
},
|
2025-02-16 17:19:52 +08:00
|
|
|
|
2025-09-22 15:17:59 +08:00
|
|
|
/**
|
|
|
|
* 修改密码返回
|
|
|
|
*/
|
|
|
|
closeResPas: function () {
|
|
|
|
this.setData({
|
|
|
|
resPas: false,
|
|
|
|
});
|
|
|
|
},
|
2025-02-16 17:19:52 +08:00
|
|
|
|
2025-09-22 15:17:59 +08:00
|
|
|
/**
|
|
|
|
* 修改密码返回
|
|
|
|
*/
|
|
|
|
closeBinding: function () {
|
|
|
|
this.setData({
|
|
|
|
binding: false,
|
|
|
|
});
|
|
|
|
},
|
2025-02-16 17:19:52 +08:00
|
|
|
|
2025-09-22 15:17:59 +08:00
|
|
|
bindingBuild: function () {
|
|
|
|
wx.previewImage({
|
|
|
|
urls: cfg.baseImgUrl + "/cdn/appimgs/qrv1.jpg".split(","),
|
|
|
|
current: 0,
|
|
|
|
});
|
|
|
|
},
|
2025-02-16 17:19:52 +08:00
|
|
|
|
2025-09-22 15:17:59 +08:00
|
|
|
//退出登录
|
|
|
|
loginOut: function () {
|
|
|
|
loginOut().then((res) => {
|
|
|
|
removeToken();
|
|
|
|
wx.clearStorageSync();
|
|
|
|
wx.navigateTo({
|
|
|
|
url: "/pages/login/login",
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
2025-02-16 17:19:52 +08:00
|
|
|
|
2025-09-22 15:17:59 +08:00
|
|
|
seeTap1() {
|
|
|
|
let that = this;
|
|
|
|
that.setData({
|
|
|
|
// 切换图标
|
|
|
|
showOldPass: !that.data.showOldPass,
|
|
|
|
});
|
|
|
|
},
|
2025-02-16 17:19:52 +08:00
|
|
|
|
2025-09-22 15:17:59 +08:00
|
|
|
seeTap2() {
|
|
|
|
let that = this;
|
|
|
|
that.setData({
|
|
|
|
// 切换图标
|
|
|
|
showNewPass: !that.data.showNewPass,
|
|
|
|
});
|
|
|
|
},
|
2025-02-16 17:19:52 +08:00
|
|
|
|
2025-09-22 15:17:59 +08:00
|
|
|
seeTap3() {
|
|
|
|
let that = this;
|
|
|
|
that.setData({
|
|
|
|
// 切换图标
|
|
|
|
showPassWord: !that.data.showPassWord,
|
|
|
|
});
|
|
|
|
if (that.data.newPsw != "" && that.data.newPsw != that.data.password) {
|
|
|
|
app.toast("两次密码输入不一致!");
|
|
|
|
}
|
|
|
|
},
|
2025-02-16 17:19:52 +08:00
|
|
|
|
2025-09-22 15:17:59 +08:00
|
|
|
/**
|
|
|
|
* 添加预警信息
|
|
|
|
*/
|
|
|
|
submit: function () {
|
|
|
|
var that = this;
|
|
|
|
if (that.data.password == "") {
|
|
|
|
app.toast("请确认新密码!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (that.data.newPsw != "" && that.data.newPsw != that.data.password) {
|
|
|
|
app.toast("两次密码输入不一致!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (that.data.newPsw.length < 6) {
|
|
|
|
app.toast("请输入新密码长度 [6-20]位字符!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (that.data.password.length < 6) {
|
|
|
|
app.toast("请输入确认密码长度 [6-20]位字符!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let data = {
|
|
|
|
loginName: that.data.loginName,
|
|
|
|
oldPass: that.data.oldPsw,
|
|
|
|
password: that.data.newPsw,
|
|
|
|
confPass: that.data.password,
|
|
|
|
source: "u",
|
|
|
|
};
|
|
|
|
updatePwd(data).then((res) => {
|
|
|
|
if (res.code == 200) {
|
|
|
|
app.toast("密码修改成功,请重新登录!", 800);
|
|
|
|
loginOut().then((res) => {
|
|
|
|
removeToken();
|
|
|
|
wx.clearStorageSync();
|
|
|
|
setTimeout(() => {
|
|
|
|
wx.redirectTo({
|
|
|
|
url: "../login/login",
|
|
|
|
});
|
|
|
|
}, 500);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|