From 8a968bcc9d96c6ac88c6ec85b27be63ae40aef36 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 09 七月 2024 17:37:31 +0800
Subject: [PATCH] 密码强制修改实现
---
src/api/user.js | 1
src/views/login/index.vue | 79 ++++++++++++++++++++++++++++++++-------
2 files changed, 66 insertions(+), 14 deletions(-)
diff --git a/src/api/user.js b/src/api/user.js
index 34afe94..b870d15 100644
--- a/src/api/user.js
+++ b/src/api/user.js
@@ -12,4 +12,5 @@
selectByUserName: query => post('/api/admin/user/selectByUserName', query),
studentList: () => get('/api/admin/user/student/list'),
getClassesCurrentUserList: (param) => get('/api/admin/user/classes/students', param),
+ updatePassword: (data) => post('/api/admin/user/update/password', data)
}
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index 6b3f396..4fc37a6 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -1,6 +1,7 @@
<template>
<div class="login-container">
- <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
+ <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on"
+ label-position="left">
<div class="title-container">
<h3 class="title">姹熻タ璇煶瑙嗛鍩硅绯荤粺</h3>
@@ -8,7 +9,7 @@
<el-form-item prop="userName">
<span class="svg-container">
- <svg-icon icon-class="user" />
+ <svg-icon icon-class="user"/>
</span>
<el-input
ref="userName"
@@ -24,7 +25,7 @@
<el-tooltip v-model="capsTooltip" content="Caps lock is On" placement="right" manual>
<el-form-item prop="password">
<span class="svg-container">
- <svg-icon icon-class="password" />
+ <svg-icon icon-class="password"/>
</span>
<el-input
:key="passwordType"
@@ -40,17 +41,40 @@
@keyup.enter.native="handleLogin"
/>
<span class="show-pwd" @click="showPwd">
- <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
+ <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"/>
</span>
</el-form-item>
</el-tooltip>
<el-checkbox v-model="loginForm.remember" style="margin-bottom: 20px;margin-left: 5px;">璁颁綇瀵嗙爜</el-checkbox>
- <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin">鐧诲綍</el-button>
+ <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;"
+ @click.native.prevent="handleLogin">鐧诲綍
+ </el-button>
</el-form>
+ <el-dialog
+ title="淇敼瀵嗙爜"
+ :visible.sync="forceUpdateShow"
+ :close-on-click-modal="false"
+ :close-on-press-escape="false"
+ width="400px"
+ :show-close="false"
+ >
+ <el-form :model="updatePasswordForm">
+ <el-form-item label="鏂板瘑鐮�">
+ <el-input v-model="updatePasswordForm.newPassword" placeholder="搴斿寘鍚ぇ灏忓啓銆佹暟瀛�" show-password></el-input>
+ </el-form-item>
+ <el-form-item label="纭瀵嗙爜">
+ <el-input v-model="updatePasswordForm.confirmPassword" placeholder="纭瀵嗙爜" show-password></el-input>
+ </el-form-item>
+ </el-form>
+ <span slot="footer" class="dialog-footer">
+ <el-button @click="forceUpdateShow = false">鍏� 闂�</el-button>
+ <el-button type="primary" @click="updatePassword">淇� 鏀�</el-button>
+ </span>
+ </el-dialog>
</div>
</template>
@@ -58,6 +82,7 @@
<script>
import { mapMutations } from 'vuex'
import loginApi from '@/api/login'
+import UserApi from '@/api/user'
export default {
name: 'Login',
@@ -77,6 +102,12 @@
}
}
return {
+ forceUpdateShow: false,
+ updatePasswordForm: {
+ userId: null,
+ newPassword: '',
+ confirmPassword: ''
+ },
loginForm: {
userName: '',
password: '',
@@ -106,6 +137,19 @@
// window.removeEventListener('storage', this.afterQRScan)
},
methods: {
+ updatePassword () {
+ if (this.updatePasswordForm.newPassword !== this.updatePasswordForm.confirmPassword) {
+ this.$message.error("涓ゆ杈撳叆鐨勫瘑鐮佷笉涓�鑷�")
+ return
+ }
+ UserApi.updatePassword(this.updatePasswordForm).then(res => {
+ if (res.code === 1) {
+ this.$message.success('瀵嗙爜淇敼鎴愬姛銆傝閲嶆柊鐧诲綍')
+ this.loginForm.password = ''
+ this.forceUpdateShow = false
+ }
+ })
+ },
checkCapslock ({ shiftKey, key } = {}) {
if (key && key.length === 1) {
// eslint-disable-next-line no-mixed-operators
@@ -134,7 +178,14 @@
this.$refs.loginForm.validate(valid => {
if (valid) {
this.loading = true
- loginApi.login(this.loginForm).then(function (result) {
+ loginApi.login(this.loginForm).then(result => {
+ // 濡傛灉code涓�205锛屽垯寮哄埗淇敼瀵嗙爜
+ if (result && result.code === 205) {
+ this.updatePasswordForm.userId = result.data
+ this.forceUpdateShow = true
+ this.loading = false
+ return
+ }
if (result && result.code === 1) {
_this.setUserName(_this.loginForm.userName)
_this.$router.push({ path: '/dashboard' })
@@ -162,8 +213,8 @@
/* 淇input 鑳屾櫙涓嶅崗璋� 鍜屽厜鏍囧彉鑹� */
/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
-$bg:#283443;
-$light_gray:#fff;
+$bg: #283443;
+$light_gray: #fff;
$cursor: #fff;
@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
@@ -204,12 +255,12 @@
</style>
<style lang="scss" scoped>
-$bg:#2d3a4b;
-$dark_gray:#889aa4;
-$light_gray:#eee;
+$bg: #2d3a4b;
+$dark_gray: #889aa4;
+$light_gray: #eee;
.login-container {
- background-image:url('../../assets/loginBackground.png');
+ background-image: url('../../assets/loginBackground.png');
background-size: cover;
background-attachment: fixed;
min-height: 100%;
@@ -221,8 +272,8 @@
position: relative;
width: 520px;
max-width: 100%;
- padding:30px 50px 10px 50px;
- margin:200px auto auto auto;
+ padding: 30px 50px 10px 50px;
+ margin: 200px auto auto auto;
overflow: hidden;
background: white;
}
--
Gitblit v1.8.0