update 完善编码信息读取
This commit is contained in:
@@ -8,47 +8,46 @@ import { token } from 'common/token'
|
||||
import './index.less'
|
||||
|
||||
export default class index extends Component {
|
||||
|
||||
state = {
|
||||
loading: false,
|
||||
|
||||
focusUser: false,
|
||||
focusPassword: false
|
||||
focusPassword: false,
|
||||
}
|
||||
|
||||
backgroundImage = require(`assets/image/login-bg-0${Math.floor(Math.random() * 4)}.jpg`)
|
||||
|
||||
focus = {
|
||||
user: false,
|
||||
password: false
|
||||
password: false,
|
||||
}
|
||||
|
||||
form = React.createRef()
|
||||
|
||||
onLogin = (values) => {
|
||||
this.setState({
|
||||
loading: true
|
||||
})
|
||||
onLogin = values => {
|
||||
this.setState({ loading: true })
|
||||
|
||||
let { account, password } = values
|
||||
password = encryptByRSA(password, RSA_PUBLIC_KEY)
|
||||
api.login({ account, password }).then(({ success, data, message }) => {
|
||||
if (success) {
|
||||
token.value = data
|
||||
Message.success('登录成功')
|
||||
this.props.history.replace('/')
|
||||
} else {
|
||||
Message.error(message)
|
||||
}
|
||||
}).catch(({ message }) => {
|
||||
if (typeof message === 'object' && message[0]) {
|
||||
Message.error(message[0].messages[0])
|
||||
}
|
||||
})
|
||||
api.login({ account, password })
|
||||
.then(({ success, data, message }) => {
|
||||
if (success) {
|
||||
token.value = data
|
||||
Message.success('登录成功')
|
||||
this.props.history.replace('/')
|
||||
} else {
|
||||
Message.error(message)
|
||||
}
|
||||
})
|
||||
.catch(({ message }) => {
|
||||
if (typeof message === 'object' && message[0]) {
|
||||
Message.error(message[0].messages[0])
|
||||
}
|
||||
this.setState({ loading: false })
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
return (
|
||||
<div className="yo-login">
|
||||
<img src={this.backgroundImage.default} alt="" />
|
||||
@@ -62,8 +61,14 @@ export default class index extends Component {
|
||||
label="用户名"
|
||||
>
|
||||
<Input
|
||||
onBlur={() => { this.setState({ focusUser: !!this.form.current.getFieldValue('account') }); }}
|
||||
onFocus={() => { this.setState({ focusUser: true }) }}
|
||||
onBlur={() => {
|
||||
this.setState({
|
||||
focusUser: !!this.form.current.getFieldValue('account'),
|
||||
})
|
||||
}}
|
||||
onFocus={() => {
|
||||
this.setState({ focusUser: true })
|
||||
}}
|
||||
size="large"
|
||||
autoComplete="off"
|
||||
/>
|
||||
@@ -75,8 +80,15 @@ export default class index extends Component {
|
||||
label="密码"
|
||||
>
|
||||
<Input.Password
|
||||
onBlur={() => { this.setState({ focusPassword: !!this.form.current.getFieldValue('password') }) }}
|
||||
onFocus={() => { this.setState({ focusPassword: true }) }}
|
||||
onBlur={() => {
|
||||
this.setState({
|
||||
focusPassword:
|
||||
!!this.form.current.getFieldValue('password'),
|
||||
})
|
||||
}}
|
||||
onFocus={() => {
|
||||
this.setState({ focusPassword: true })
|
||||
}}
|
||||
size="large"
|
||||
autoComplete="off"
|
||||
/>
|
||||
@@ -89,7 +101,9 @@ export default class index extends Component {
|
||||
htmlType="submit"
|
||||
size="large"
|
||||
type="primary"
|
||||
>登录</Button>
|
||||
>
|
||||
登录
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Container>
|
||||
|
||||
Reference in New Issue
Block a user