|
|
|
@ -4,21 +4,9 @@ |
|
|
|
|
<!-- <img src="~@/assets/logo.svg" class="logo" alt="logo" /> --> |
|
|
|
|
<span class="title">管理后台登录</span> |
|
|
|
|
</div> |
|
|
|
|
<a-form |
|
|
|
|
id="formLogin" |
|
|
|
|
class="user-layout-login" |
|
|
|
|
ref="formLogin" |
|
|
|
|
:form="form" |
|
|
|
|
@submit="handleSubmit" |
|
|
|
|
> |
|
|
|
|
<a-form id="formLogin" class="user-layout-login" ref="formLogin" :form="form" @submit="handleSubmit"> |
|
|
|
|
<!-- 错误提示 --> |
|
|
|
|
<a-alert |
|
|
|
|
v-if="isLoginError" |
|
|
|
|
type="error" |
|
|
|
|
showIcon |
|
|
|
|
style="margin-bottom: 24px;" |
|
|
|
|
:message="loginErrorMsg" |
|
|
|
|
/> |
|
|
|
|
<a-alert v-if="isLoginError" type="error" showIcon style="margin-bottom: 24px" :message="loginErrorMsg" /> |
|
|
|
|
<a-form-item> |
|
|
|
|
<a-input |
|
|
|
|
size="large" |
|
|
|
@ -26,7 +14,7 @@ |
|
|
|
|
placeholder="请输入用户名" |
|
|
|
|
v-decorator="[ |
|
|
|
|
'username', |
|
|
|
|
{rules: [{ required: true, message: '您还没有输入用户名' }], validateTrigger: 'change'} |
|
|
|
|
{ rules: [{ required: true, message: '您还没有输入用户名' }], validateTrigger: 'change' }, |
|
|
|
|
]" |
|
|
|
|
> |
|
|
|
|
<a-icon slot="prefix" type="user" :style="{ color: 'rgba(0,0,0,.25)' }" /> |
|
|
|
@ -41,14 +29,14 @@ |
|
|
|
|
placeholder="请输入用户密码" |
|
|
|
|
v-decorator="[ |
|
|
|
|
'password', |
|
|
|
|
{rules: [{ required: true, message: '您还没有输入用户密码' }], validateTrigger: 'blur'} |
|
|
|
|
{ rules: [{ required: true, message: '您还没有输入用户密码' }], validateTrigger: 'blur' }, |
|
|
|
|
]" |
|
|
|
|
> |
|
|
|
|
<a-icon slot="prefix" type="lock" :style="{ color: 'rgba(0,0,0,.25)' }" /> |
|
|
|
|
</a-input> |
|
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
<a-form-item style="margin-top:24px"> |
|
|
|
|
<a-form-item style="margin-top: 24px"> |
|
|
|
|
<a-button |
|
|
|
|
size="large" |
|
|
|
|
type="primary" |
|
|
|
@ -56,7 +44,8 @@ |
|
|
|
|
class="login-button" |
|
|
|
|
:loading="state.loginBtn" |
|
|
|
|
:disabled="state.loginBtn" |
|
|
|
|
>确定</a-button> |
|
|
|
|
>确定</a-button |
|
|
|
|
> |
|
|
|
|
</a-form-item> |
|
|
|
|
</a-form> |
|
|
|
|
</div> |
|
|
|
@ -67,7 +56,7 @@ import { mapActions } from 'vuex' |
|
|
|
|
import { timeFix } from '@/utils/util' |
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
data () { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
// 是否登录错误 |
|
|
|
|
isLoginError: false, |
|
|
|
@ -76,21 +65,21 @@ export default { |
|
|
|
|
// 表单组件 |
|
|
|
|
form: this.$form.createForm(this), |
|
|
|
|
// 页面状态 |
|
|
|
|
state: { loginBtn: false } |
|
|
|
|
state: { loginBtn: false }, |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
created () { }, |
|
|
|
|
created() {}, |
|
|
|
|
methods: { |
|
|
|
|
...mapActions(['Login', 'Logout']), |
|
|
|
|
/** |
|
|
|
|
* 表单提交: 确定登录 |
|
|
|
|
*/ |
|
|
|
|
handleSubmit (e) { |
|
|
|
|
handleSubmit(e) { |
|
|
|
|
e.preventDefault() |
|
|
|
|
const { |
|
|
|
|
form: { validateFields }, |
|
|
|
|
state, |
|
|
|
|
Login |
|
|
|
|
Login, |
|
|
|
|
} = this |
|
|
|
|
|
|
|
|
|
state.loginBtn = true |
|
|
|
@ -99,8 +88,8 @@ export default { |
|
|
|
|
validateFields(['username', 'password'], { force: true }, (err, values) => { |
|
|
|
|
if (!err) { |
|
|
|
|
Login(values) |
|
|
|
|
.then(res => this.loginSuccess(res)) |
|
|
|
|
.catch(err => this.loginFailed(err)) |
|
|
|
|
.then((res) => this.loginSuccess(res)) |
|
|
|
|
.catch((err) => this.loginFailed(err)) |
|
|
|
|
.finally(() => { |
|
|
|
|
state.loginBtn = false |
|
|
|
|
}) |
|
|
|
@ -115,13 +104,13 @@ export default { |
|
|
|
|
/** |
|
|
|
|
* 登录成功 |
|
|
|
|
*/ |
|
|
|
|
loginSuccess (res) { |
|
|
|
|
this.$router.push({ path: '/' }) |
|
|
|
|
loginSuccess(res) { |
|
|
|
|
this.$router.push('/goods/index') |
|
|
|
|
// 显示欢迎信息 |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.$notification.success({ |
|
|
|
|
message: '欢迎', |
|
|
|
|
description: `${timeFix()},欢迎回来` |
|
|
|
|
description: `${timeFix()},欢迎回来`, |
|
|
|
|
}) |
|
|
|
|
}, 1000) |
|
|
|
|
this.isLoginError = false |
|
|
|
@ -130,11 +119,11 @@ export default { |
|
|
|
|
/** |
|
|
|
|
* 登录请求失败 |
|
|
|
|
*/ |
|
|
|
|
loginFailed (response) { |
|
|
|
|
loginFailed(response) { |
|
|
|
|
this.isLoginError = true |
|
|
|
|
this.loginErrorMsg = response.message |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|