|
@@ -63,6 +63,24 @@
|
|
|
placeholder="密码"
|
|
placeholder="密码"
|
|
|
/>
|
|
/>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
+ <el-form-item prop="captcha">
|
|
|
|
|
+ <span class="svg-container">
|
|
|
|
|
+ <svg-icon icon-class="password"/>
|
|
|
|
|
+ </span>
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ name="captcha"
|
|
|
|
|
+ v-model="loginForm.captchaCode"
|
|
|
|
|
+ @keyup.enter.native="handleLogin"
|
|
|
|
|
+ placeholder="验证码"
|
|
|
|
|
+ style="width: 200px !important;"
|
|
|
|
|
+ />
|
|
|
|
|
+ <img
|
|
|
|
|
+ :src="captchaUrl"
|
|
|
|
|
+ @click="refreshCaptcha"
|
|
|
|
|
+ class="captcha-img"
|
|
|
|
|
+ alt="验证码"
|
|
|
|
|
+ >
|
|
|
|
|
+ </el-form-item>
|
|
|
<el-form-item
|
|
<el-form-item
|
|
|
prop="authcode"
|
|
prop="authcode"
|
|
|
v-if="showCode"
|
|
v-if="showCode"
|
|
@@ -121,6 +139,7 @@
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
// import drawCanvas from './canvas'
|
|
// import drawCanvas from './canvas'
|
|
|
|
|
+import { getCaptcha } from '@/api/login'
|
|
|
import { encrypt } from '@/utils'
|
|
import { encrypt } from '@/utils'
|
|
|
|
|
|
|
|
const blocks = [
|
|
const blocks = [
|
|
@@ -153,19 +172,32 @@ export default {
|
|
|
loginForm: {
|
|
loginForm: {
|
|
|
projectName: project,
|
|
projectName: project,
|
|
|
userName,
|
|
userName,
|
|
|
- password
|
|
|
|
|
|
|
+ password,
|
|
|
|
|
+ captchaId: '',
|
|
|
|
|
+ captchaCode: ''
|
|
|
},
|
|
},
|
|
|
loginRules: {
|
|
loginRules: {
|
|
|
projectName: [{required: true, trigger: 'blur', message: '请输入项目名'}],
|
|
projectName: [{required: true, trigger: 'blur', message: '请输入项目名'}],
|
|
|
userName: [{required: true, trigger: 'blur', message: '请输入用户名'}],
|
|
userName: [{required: true, trigger: 'blur', message: '请输入用户名'}],
|
|
|
- password: [{required: true, trigger: 'blur', message: '请输入密码'}]
|
|
|
|
|
|
|
+ password: [{required: true, trigger: 'blur', message: '请输入密码'}],
|
|
|
|
|
+ captchaCode: [{required: true, trigger: 'blur', message: '请输入验证码'}]
|
|
|
},
|
|
},
|
|
|
loading: false,
|
|
loading: false,
|
|
|
pwdType: 'password',
|
|
pwdType: 'password',
|
|
|
|
|
+ captchaUrl: '',
|
|
|
count: 31
|
|
count: 31
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ refreshCaptcha () {
|
|
|
|
|
+ getCaptcha()
|
|
|
|
|
+ .then(res => {
|
|
|
|
|
+ this.loginForm.captchaId = res.headers['captcha-id'] || ''
|
|
|
|
|
+ this.captchaUrl = res.data
|
|
|
|
|
+ }).catch(() => {
|
|
|
|
|
+ this.$message.error('获取验证码失败,请重试')
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
showPwd () {
|
|
showPwd () {
|
|
|
if (this.pwdType === 'password') {
|
|
if (this.pwdType === 'password') {
|
|
|
this.pwdType = ''
|
|
this.pwdType = ''
|
|
@@ -174,11 +206,13 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
handleLogin () {
|
|
handleLogin () {
|
|
|
- const { projectName, userName, password } = this.loginForm
|
|
|
|
|
|
|
+ const { projectName, userName, password, captchaCode, captchaId } = this.loginForm
|
|
|
let params = {
|
|
let params = {
|
|
|
projectName: projectName.trim(),
|
|
projectName: projectName.trim(),
|
|
|
userName: userName.trim(),
|
|
userName: userName.trim(),
|
|
|
- password: encrypt(password)
|
|
|
|
|
|
|
+ password: encrypt(password),
|
|
|
|
|
+ captchaCode: captchaCode.trim(),
|
|
|
|
|
+ captchaId: captchaId.trim()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (this.savePwd) {
|
|
if (this.savePwd) {
|
|
@@ -199,6 +233,7 @@ export default {
|
|
|
this.$router.push('/index/dashboard')
|
|
this.$router.push('/index/dashboard')
|
|
|
}).catch(() => {
|
|
}).catch(() => {
|
|
|
this.loading = false
|
|
this.loading = false
|
|
|
|
|
+ this.refreshCaptcha()
|
|
|
})
|
|
})
|
|
|
} else {
|
|
} else {
|
|
|
console.log('error submit!!')
|
|
console.log('error submit!!')
|
|
@@ -213,6 +248,7 @@ export default {
|
|
|
this.loginForm.projectName = window.localStorage.getItem('projectName') || ''
|
|
this.loginForm.projectName = window.localStorage.getItem('projectName') || ''
|
|
|
this.loginForm.password = window.localStorage.getItem('password') || ''
|
|
this.loginForm.password = window.localStorage.getItem('password') || ''
|
|
|
this.savePwd = !!this.loginForm.password
|
|
this.savePwd = !!this.loginForm.password
|
|
|
|
|
+ this.refreshCaptcha()
|
|
|
},
|
|
},
|
|
|
beforeDestroy () {
|
|
beforeDestroy () {
|
|
|
this.stopCanvasAnimate = true
|
|
this.stopCanvasAnimate = true
|
|
@@ -227,6 +263,7 @@ $light_gray: #eee;
|
|
|
/* reset element-ui css */
|
|
/* reset element-ui css */
|
|
|
.login-container {
|
|
.login-container {
|
|
|
.el-form-item__content {
|
|
.el-form-item__content {
|
|
|
|
|
+ display: flex;
|
|
|
line-height: 36px;
|
|
line-height: 36px;
|
|
|
color: #454545;
|
|
color: #454545;
|
|
|
border: 1px solid #C3D5E8;
|
|
border: 1px solid #C3D5E8;
|
|
@@ -279,8 +316,8 @@ $light_gray: #eee;
|
|
|
position: absolute;
|
|
position: absolute;
|
|
|
z-index: 20;
|
|
z-index: 20;
|
|
|
top: 50%;
|
|
top: 50%;
|
|
|
- margin-top: -300px;
|
|
|
|
|
- height: 600px;
|
|
|
|
|
|
|
+ margin-top: -280px;
|
|
|
|
|
+ height: 620px;
|
|
|
left: calc(50% - 480px);
|
|
left: calc(50% - 480px);
|
|
|
display: flex;
|
|
display: flex;
|
|
|
background: #fff;
|
|
background: #fff;
|
|
@@ -372,6 +409,17 @@ $light_gray: #eee;
|
|
|
margin: 4px 0;
|
|
margin: 4px 0;
|
|
|
border-right: 1px solid #C3D5E8;
|
|
border-right: 1px solid #C3D5E8;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ .captcha-img {
|
|
|
|
|
+ width: 100px;
|
|
|
|
|
+ height: 36px;
|
|
|
|
|
+ margin-top: 2px;
|
|
|
|
|
+ margin-left: 20px;
|
|
|
|
|
+ vertical-align: middle;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ border: 1px solid #C3D5E8;
|
|
|
|
|
+ border-radius: 4px;
|
|
|
|
|
+ }
|
|
|
.show-pwd {
|
|
.show-pwd {
|
|
|
position: absolute; top: 7px; right: 10px; font-size: 16px; color: $dark_gray; cursor: pointer; user-select: none;
|
|
position: absolute; top: 7px; right: 10px; font-size: 16px; color: $dark_gray; cursor: pointer; user-select: none;
|
|
|
}
|
|
}
|