import React from 'react'; import { connect } from 'dva'; import router from 'umi/router'; import store from '@/utils/store'; import { Input, Icon, Button, message } from 'antd'; import config from '@/config'; import styles from './index.less'; @connect() class Login extends React.Component { state = { username: '', password: '', }; localOnChangeUserName = e => { this.setState({ username: e.target.value }); }; localOnChangePassWord = e => { this.setState({ password: e.target.value }); }; login = () => { const { username, password } = this.state; const { dispatch } = this.props; dispatch({ type: 'login/login', payload: { userName: username, password }, }).then(({ code, data }) => { if (code === 'sys.success') { const { token, userId } = data; // message.success("登录成功"); store.set('token', token); store.set('userId', userId); router.push(config.home || '/profile/message'); } }); }; render() { return (