From d485b34e278525db030257a82edbc047e2f16cf8 Mon Sep 17 00:00:00 2001 From: xiongchengqiang Date: Thu, 21 May 2020 09:11:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BC=98=E5=8C=96=E7=99=BB=E9=99=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E6=A0=A1=E9=AA=8C"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/common/login.vue | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/views/common/login.vue b/src/views/common/login.vue index ec01ff0..7683459 100644 --- a/src/views/common/login.vue +++ b/src/views/common/login.vue @@ -23,7 +23,12 @@ - + - + @@ -47,6 +57,7 @@ import { apiLogin } from '@/api/api_sys' export default { data () { return { + isloading: false, dataForm: { username: '', password: '', @@ -73,13 +84,21 @@ export default { // 登录提交表单 handleLogin () { let param = Object.assign(this.dataForm, { 'uuid': this.dataForm.uuid }) - apiLogin(param).then(res => { - if (res && res.code === 0) { - this.$cookie.set('token', res.token) - this.$router.replace({ name: 'home' }) + this.$refs.dataForm.validate((valid) => { + if (valid) { + this.isloading = true + 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 { - this.$message.error(res.msg) - this.handleGetImgCaptcha() + return false } }) }