feat:优化登陆页面的校验"
This commit is contained in:
parent
6f0ba03418
commit
d485b34e27
@ -23,7 +23,12 @@
|
|||||||
<el-form-item prop="captcha">
|
<el-form-item prop="captcha">
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="14">
|
<el-col :span="14">
|
||||||
<el-input clearable v-model="dataForm.captcha" placeholder="验证码"></el-input>
|
<el-input
|
||||||
|
@key.enter.native="handleLogin"
|
||||||
|
clearable
|
||||||
|
v-model="dataForm.captcha"
|
||||||
|
placeholder="验证码"
|
||||||
|
></el-input>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="10" class="login-captcha">
|
<el-col :span="10" class="login-captcha">
|
||||||
<img :src="captchaPath" @click="handleGetImgCaptcha" />
|
<img :src="captchaPath" @click="handleGetImgCaptcha" />
|
||||||
@ -31,7 +36,12 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button class="login-btn-submit" type="primary" @click="handleLogin()">登录</el-button>
|
<el-button
|
||||||
|
class="login-btn-submit"
|
||||||
|
type="primary"
|
||||||
|
:loading="isloading"
|
||||||
|
@click="handleLogin"
|
||||||
|
>登录</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
@ -47,6 +57,7 @@ import { apiLogin } from '@/api/api_sys'
|
|||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
isloading: false,
|
||||||
dataForm: {
|
dataForm: {
|
||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
@ -73,13 +84,21 @@ export default {
|
|||||||
// 登录提交表单
|
// 登录提交表单
|
||||||
handleLogin () {
|
handleLogin () {
|
||||||
let param = Object.assign(this.dataForm, { 'uuid': this.dataForm.uuid })
|
let param = Object.assign(this.dataForm, { 'uuid': this.dataForm.uuid })
|
||||||
apiLogin(param).then(res => {
|
this.$refs.dataForm.validate((valid) => {
|
||||||
if (res && res.code === 0) {
|
if (valid) {
|
||||||
this.$cookie.set('token', res.token)
|
this.isloading = true
|
||||||
this.$router.replace({ name: 'home' })
|
apiLogin(param).then(res => {
|
||||||
|
this.isloading = false
|
||||||
|
if (res && res.code === 0) {
|
||||||
|
this.$cookie.set('token', res.token)
|
||||||
|
this.$router.replace({ name: 'home' })
|
||||||
|
} else {
|
||||||
|
this.$message.error(res.msg)
|
||||||
|
this.handleGetImgCaptcha()
|
||||||
|
}
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(res.msg)
|
return false
|
||||||
this.handleGetImgCaptcha()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user