|
@@ -12,10 +12,10 @@
|
|
|
<el-form-item label="密码" prop="password">
|
|
<el-form-item label="密码" prop="password">
|
|
|
<el-input type="password" v-model="loginForm.password" placeholder="请输入密码" show-password />
|
|
<el-input type="password" v-model="loginForm.password" placeholder="请输入密码" show-password />
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
- <el-form-item label="验证码" prop="code">
|
|
|
|
|
|
|
+ <el-form-item label="验证码" prop="code" v-if="captchaOnOff">
|
|
|
<div style="display:flex;align-items:center;">
|
|
<div style="display:flex;align-items:center;">
|
|
|
<el-input v-model="loginForm.code" placeholder="请输入验证码" style="flex:1" @keyup.enter.native="handleLogin" />
|
|
<el-input v-model="loginForm.code" placeholder="请输入验证码" style="flex:1" @keyup.enter.native="handleLogin" />
|
|
|
- <img :src="codeUrl" @click="getCode" class="code-img" title="点击刷新" />
|
|
|
|
|
|
|
+ <img v-if="codeUrl" :src="codeUrl" @click="getCode" class="code-img" title="点击刷新" />
|
|
|
</div>
|
|
</div>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
<el-form-item>
|
|
@@ -35,6 +35,7 @@ export default {
|
|
|
return {
|
|
return {
|
|
|
loading: false,
|
|
loading: false,
|
|
|
codeUrl: '',
|
|
codeUrl: '',
|
|
|
|
|
+ captchaOnOff: true,
|
|
|
loginForm: {
|
|
loginForm: {
|
|
|
username: '',
|
|
username: '',
|
|
|
password: '',
|
|
password: '',
|
|
@@ -54,8 +55,11 @@ export default {
|
|
|
methods: {
|
|
methods: {
|
|
|
getCode() {
|
|
getCode() {
|
|
|
getCodeImg().then(res => {
|
|
getCodeImg().then(res => {
|
|
|
- this.codeUrl = "data:image/gif;base64," + res.img
|
|
|
|
|
- this.loginForm.uuid = res.uuid
|
|
|
|
|
|
|
+ this.captchaOnOff = res.captchaOnOff === undefined ? true : res.captchaOnOff
|
|
|
|
|
+ if (this.captchaOnOff) {
|
|
|
|
|
+ this.codeUrl = "data:image/gif;base64," + res.img
|
|
|
|
|
+ this.loginForm.uuid = res.uuid
|
|
|
|
|
+ }
|
|
|
}).catch(() => {
|
|
}).catch(() => {
|
|
|
this.codeUrl = ''
|
|
this.codeUrl = ''
|
|
|
})
|
|
})
|
|
@@ -65,7 +69,15 @@ export default {
|
|
|
if (!valid) return
|
|
if (!valid) return
|
|
|
this.loading = true
|
|
this.loading = true
|
|
|
try {
|
|
try {
|
|
|
- const response = await login(this.loginForm)
|
|
|
|
|
|
|
+ const data = {
|
|
|
|
|
+ username: this.loginForm.username,
|
|
|
|
|
+ password: this.loginForm.password
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.captchaOnOff) {
|
|
|
|
|
+ data.code = this.loginForm.code
|
|
|
|
|
+ data.uuid = this.loginForm.uuid
|
|
|
|
|
+ }
|
|
|
|
|
+ const response = await login(data)
|
|
|
if (response.code === 200) {
|
|
if (response.code === 200) {
|
|
|
this.$store.dispatch('setToken', response.token)
|
|
this.$store.dispatch('setToken', response.token)
|
|
|
if (response.proxyInfo) {
|
|
if (response.proxyInfo) {
|
|
@@ -74,11 +86,15 @@ export default {
|
|
|
this.$router.push('/dashboard')
|
|
this.$router.push('/dashboard')
|
|
|
} else {
|
|
} else {
|
|
|
this.$message.error(response.msg || '登录失败')
|
|
this.$message.error(response.msg || '登录失败')
|
|
|
- this.getCode()
|
|
|
|
|
|
|
+ if (this.captchaOnOff) {
|
|
|
|
|
+ this.getCode()
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.$message.error('登录失败')
|
|
this.$message.error('登录失败')
|
|
|
- this.getCode()
|
|
|
|
|
|
|
+ if (this.captchaOnOff) {
|
|
|
|
|
+ this.getCode()
|
|
|
|
|
+ }
|
|
|
} finally {
|
|
} finally {
|
|
|
this.loading = false
|
|
this.loading = false
|
|
|
}
|
|
}
|