This commit is contained in:
2021-07-01 13:17:12 +08:00
parent 40d7bef357
commit 95cb5b4483
3 changed files with 69 additions and 44 deletions

View File

@@ -13,6 +13,8 @@ export default class index extends Component {
focusUser: false,
focusPassword: false,
btnDisabled: true,
}
backgroundImage = require(`assets/image/login-bg-0${Math.floor(Math.random() * 4)}.jpg`)
@@ -49,15 +51,26 @@ export default class index extends Component {
}
render() {
const { loading, focusUser, focusPassword, btnDisabled } = this.state
return (
<div className="yo-login">
<img src={this.backgroundImage.default} alt="" />
<div className="yo-login--placeholder">
<Container mode="sm">
<Form ref={this.form} layout="vertical" onFinish={this.onLogin}>
<Form
ref={this.form}
layout="vertical"
onFinish={this.onLogin}
onValuesChange={(changedValues, values) => {
this.setState({
btnDisabled: !values.account || !values.password,
})
}}
>
<Form.Item
name="account"
className={!this.state.focusUser && 'yo-login--label'}
className={!focusUser && 'yo-login--label'}
colon={false}
label="用户名"
>
@@ -76,7 +89,7 @@ export default class index extends Component {
</Form.Item>
<Form.Item
name="password"
className={!this.state.focusPassword && 'yo-login--label'}
className={!focusPassword && 'yo-login--label'}
colon={false}
label="密码"
>
@@ -96,8 +109,8 @@ export default class index extends Component {
</Form.Item>
<Form.Item className="mt-lg">
<Button
disabled={this.form.user === '' || this.form.password === ''}
loading={this.state.loading}
disabled={btnDisabled}
loading={loading}
block
htmlType="submit"
size="large"