Commit f00e92e9 by liangjianmin

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

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