Commit f00e92e9 by liangjianmin

feat(auth): 优化修改密码弹窗显示逻辑

- 修改密码弹窗关闭时触发handlePasswordDialogClose方法
- 点击取消按钮调用handlePasswordDialogClose以统一处理关闭逻辑
- 增加cookie标记记录密码弹窗是否关闭,防止重复弹出
- 初始化和获取用户信息时检测cookie决定是否显示修改密码弹窗
- 修改changePwd方法,检测cookie决定是否直接显示弹窗
- 登录成功时清除密码弹窗关闭的cookie,保证重新登录后弹窗逻辑生效
parent e8d14cd2
......@@ -89,7 +89,7 @@
</template>
</div>
<!--修改密码弹窗-->
<el-dialog title="修改密码" :visible.sync="dialogVisible" width="500px" class="demo-ruleForm" :close-on-click-modal="false">
<el-dialog title="修改密码" :visible.sync="dialogVisible" width="500px" class="demo-ruleForm" :close-on-click-modal="false" @close="handlePasswordDialogClose">
<!-- 验证方式选择 -->
<div style="margin-bottom: 20px;">
<span style="color: #F56C6C; margin-right: 5px;margin-left: 20px;">*</span>
......@@ -110,7 +110,7 @@
<el-input v-model="ruleForm.repassword" type='password' placeholder='请再次输入新密码' autocomplete="new-password"></el-input>
</el-form-item>
<el-form-item>
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button @click="handlePasswordDialogClose">取 消</el-button>
<el-button type="primary" @click="submitForm('ruleForm')">确 定</el-button>
</el-form-item>
</el-form>
......@@ -133,7 +133,7 @@
<el-input v-model="smsForm.repassword" type='password' placeholder='请再次输入新密码' autocomplete="new-password"></el-input>
</el-form-item>
<el-form-item>
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button @click="handlePasswordDialogClose">取 消</el-button>
<el-button type="primary" @click="submitSmsForm('smsForm')">确 定</el-button>
</el-form-item>
</el-form>
......@@ -747,14 +747,17 @@
this.userinfo = window.userInfo;
// 检查是否为初始密码
if (this.userinfo.is_init_passwd == 1) {
this.changePwd();
setTimeout(() => {
this.$message({
message: '请及时更换初始密码',
type: 'warning',
duration: 3000
});
}, 100);
var passwordDialogClosed = Util.getCookie('password_dialog_closed') || '';
if (!passwordDialogClosed) {
this.changePwd();
setTimeout(() => {
this.$message({
message: '请及时更换初始密码',
type: 'warning',
duration: 3000
});
}, 100);
}
}
} else {
this.$http('get', "/api/user/getuserinfo").then(res => {
......@@ -763,14 +766,17 @@
window.userInfo = res.data;
// 检查是否为初始密码
if (res.data.is_init_passwd == 1) {
this.changePwd();
setTimeout(() => {
this.$message({
message: '请及时更换初始密码',
type: 'warning',
duration: 3000
});
}, 100);
var passwordDialogClosed = Util.getCookie('password_dialog_closed') || '';
if (!passwordDialogClosed) {
this.changePwd();
setTimeout(() => {
this.$message({
message: '请及时更换初始密码',
type: 'warning',
duration: 3000
});
}, 100);
}
}
}
})
......@@ -862,6 +868,12 @@
})
},
changePwd() {
// 检查cookie是否已经关闭过弹窗
var passwordDialogClosed = Util.getCookie('password_dialog_closed') || '';
if (passwordDialogClosed) {
return; // 如果已经关闭过,则不显示弹窗
}
this.dialogVisible = true;
this.verifyType = 'password'; // 默认原密码验证
// 初始化表单数据
......@@ -882,6 +894,14 @@
this.countdown = 60;
},
/**
* 处理密码弹窗关闭
*/
handlePasswordDialogClose() {
// 用户关闭弹窗,设置cookie标记
Util.setCookie('password_dialog_closed', true, 1);
this.dialogVisible = false;
},
/**
* 发送短信验证码
*/
sendSmsCode() {
......
......@@ -413,6 +413,9 @@
localStorage.setItem('futures_cp_time_day', res.data.futures_cp_time_day);
Util.setCookie("token", res.data.api_token, 1);
// 清除密码弹窗关闭标记,重新登录时重新检查
Util.delCookie('password_dialog_closed');
//登录时,识别到账号未绑定手机号,则显示绑定手机号窗口
if (!res.data.is_bind_mobile) {
......@@ -475,6 +478,10 @@
localStorage.setItem('futures_cp_time_day', res.data.futures_cp_time_day);
Util.setCookie("token", res.data.api_token, 1);
// 清除密码弹窗关闭标记,重新登录时重新检查
Util.delCookie('password_dialog_closed');
//强制要求微信绑定
if (!res.data.is_bind_wechat) {
this.$http('get', "/api/login/getwxqrcode").then(res => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment