feat(login): 增强密码安全性和用户提示

- 添加用户名显示和旧密码验证
-增强新密码复杂性要求
- 优化密码修改成功后的提示和跳转逻辑
- 新增弱密码登录时的提示和强制修改密码功能
master
10396 2025-06-25 13:53:32 +08:00
parent b32ed7f9dc
commit ae2a7c28af
2 changed files with 63 additions and 14 deletions

View File

@ -5,9 +5,9 @@
<block slot="content">设置密码</block>
</cu-custom>
<view class="register">
<view class="reg-title mb40">
<text>修改密码</text>
</view>
<view class="user_main">
<view >账号{{USERNAME}}</view>
</view>
<view class="reg-form">
<view class="reg-input">
<input password @input="oldInpPwd" placeholder="旧密码" name="input"></input>
@ -24,7 +24,7 @@
</view>
</view>
<view class="reg-title">
<text class="text-gray">需8-20位字</text>
<text class="text-gray">需8-20位字母大小写数字混合</text>
</view>
<view class="flex flex-direction mt50">
<button :loading="buttonloading" class="cu-btn bg-blue lg round" @click="updateUserPwd()"></button>
@ -44,6 +44,7 @@
nowPwd :'',
buttonloading: false,
confirmPwd :'',
USERNAME: loginUser.USERNAME
}
},
methods: {
@ -112,6 +113,15 @@
});
return
}
var reg1 = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[~!@#$%^&*.])[\da-zA-Z~!@#$%^&*.]{8,}$/
if (!reg1.test(_this.nowPwd)) {
uni.showToast({
icon: 'none',
title: '密码必须包含大小写字母、数字、特殊符号',
duration: 2000
});
return
}
this.buttonloading = true
uni.request({
url: basePath +'/app/user/editUserPwd' ,
@ -132,16 +142,31 @@
this.buttonloading = false
if (res.data != null) {
var result = res.data.result;
if ("success" == result) {
uni.showToast({
title: "密码修改成功",
duration: 1000
});
uni.navigateTo({
url: '/pages/login/home',
});
var Code = res.data.code;
console.log(res.data.code)
if ("success" === result) {
if("9999" === Code){
uni.showToast({
icon: 'none',
title: "旧密码错误",
duration: 2000
});
}else{
uni.showToast({
title: "密码修改成功",
duration: 1500, //
success: function() {
// 使 setTimeout
setTimeout(function() {
uni.navigateTo({
url: '/pages/login/home',
});
}, 1500); // duration
}
});
}
} else if ("usererror" == result) {
} else if ("usererror" === result) {
uni.showToast({
icon: 'none',
title: "密码有误",
@ -179,4 +204,13 @@
page{
background-color: #FFFFFF;
}
.user_main{
width: 100%;
padding:30upx 20upx ;
background: #d8e9ff;
border-radius: 10upx;
box-sizing: border-box;
margin-bottom: 40upx;
font-size: 30upx;
}
</style>

View File

@ -271,13 +271,28 @@
title: res.data.msg,
duration: 2000
});
if ("success" == result) {
if ("success" === result) {
setloginUserId(res.data.USER_ID);
setCorpinfoId(res.data.CORPINFO_ID);
setDeptId(res.data.DEPARTMENT_ID);
setDeptLevel(res.data.DEPARTMENT_LEVEL);
setIsRest(res.data.ISREST);
setloginUser(res.data);
if(res.data.passwordType === '0'){
uni.showToast({
icon: 'none',
title: "登录的密码强度为弱,请修改密码!",
duration: 2000 // 2
});
// 2000ms
setTimeout(() => {
uni.navigateTo({
url: '/pages/login/forget/forget-reset'
});
}, 2000); // toastduration
return
}
uni.setStorage({key: 'USER', data: res.data});
const remember = {}
remember.username = userName