|
@@ -2,20 +2,25 @@
|
|
* @Author: Johnhong9527
|
|
* @Author: Johnhong9527
|
|
* @Date: 2019-05-25 20:29:31
|
|
* @Date: 2019-05-25 20:29:31
|
|
* @Last Modified by: Johnhong9527
|
|
* @Last Modified by: Johnhong9527
|
|
- * @Last Modified time: 2019-05-25 22:26:52
|
|
|
|
|
|
+ * @Last Modified time: 2019-05-26 14:42:02
|
|
*/
|
|
*/
|
|
|
|
|
|
import React from 'react';
|
|
import React from 'react';
|
|
-import { Row, Col, PageHeader, Input, Button } from 'antd';
|
|
|
|
|
|
+import { Row, Col, PageHeader, Input, Button, message } from 'antd';
|
|
import PageTitle from 'component/page-title/index.jsx';
|
|
import PageTitle from 'component/page-title/index.jsx';
|
|
-
|
|
|
|
|
|
+import User from 'api/user.jsx';
|
|
|
|
+import MUtil from 'util/mutil.jsx';
|
|
|
|
+// import axios from 'axios';
|
|
|
|
+const _user = new User();
|
|
|
|
+const _mutil = new MUtil();
|
|
import './index.scss';
|
|
import './index.scss';
|
|
export default class Login extends React.Component {
|
|
export default class Login extends React.Component {
|
|
constructor(props) {
|
|
constructor(props) {
|
|
super(props);
|
|
super(props);
|
|
this.state = {
|
|
this.state = {
|
|
username: 'admin',
|
|
username: 'admin',
|
|
- password: 'admin'
|
|
|
|
|
|
+ password: 'admin',
|
|
|
|
+ redirect: _mutil.getUrlParams('redirect') || '/'
|
|
};
|
|
};
|
|
}
|
|
}
|
|
componentWillMount() {
|
|
componentWillMount() {
|
|
@@ -26,6 +31,40 @@ export default class Login extends React.Component {
|
|
[e.target.name]: e.target.value
|
|
[e.target.name]: e.target.value
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ sublime() {
|
|
|
|
+ const loginInfo = {
|
|
|
|
+ username: this.state.username,
|
|
|
|
+ password: this.state.password
|
|
|
|
+ },
|
|
|
|
+ checkResult = _user.checkLoginInfo(loginInfo);
|
|
|
|
+ if (!checkResult.status) {
|
|
|
|
+ _mutil.errorTips(checkResult.msg);
|
|
|
|
+ } else {
|
|
|
|
+ const loading = message.loading('正在提交中!', 0);
|
|
|
|
+ _user.login(loginInfo).then(
|
|
|
|
+ res => {
|
|
|
|
+ if (res.msg === '登录成功') {
|
|
|
|
+ setTimeout(loading, 1300);
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ message.success('登陆成功,', 0.5).then(() => {
|
|
|
|
+ window.localStorage.setItem('userInfo', JSON.stringify(res));
|
|
|
|
+ message.loading('正在跳转到登录前的页面', 1.5).then(() => {
|
|
|
|
+ this.props.history.push('/');
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }, 1600);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ errMsg => {
|
|
|
|
+ setTimeout(loading, 10);
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ _mutil.errorTips(errMsg);
|
|
|
|
+ }, 300);
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
render() {
|
|
render() {
|
|
return (
|
|
return (
|
|
<div className="login-wrapper">
|
|
<div className="login-wrapper">
|
|
@@ -33,8 +72,7 @@ export default class Login extends React.Component {
|
|
<Col span={8} push={8}>
|
|
<Col span={8} push={8}>
|
|
<div className="login">
|
|
<div className="login">
|
|
{/*
|
|
{/*
|
|
- <PageHeader className="ant-page-header" style={{ textAlign: 'center' }} title="欢迎登录 - MMALL管理系统" />
|
|
|
|
-
|
|
|
|
|
|
+ <PageHeader className="ant-page-header" style={{ textAlign: 'center' }} title="欢迎登录 - MMALL管理系统" />
|
|
*/}
|
|
*/}
|
|
<PageHeader title="欢迎登录 - MMALL管理系统" />
|
|
<PageHeader title="欢迎登录 - MMALL管理系统" />
|
|
|
|
|
|
@@ -45,6 +83,8 @@ export default class Login extends React.Component {
|
|
placeholder="User Name"
|
|
placeholder="User Name"
|
|
type="text"
|
|
type="text"
|
|
name="username"
|
|
name="username"
|
|
|
|
+ value={this.state.username}
|
|
|
|
+ onPressEnter={e => this.sublime(e)}
|
|
onChange={e => {
|
|
onChange={e => {
|
|
this.onInputChange(e);
|
|
this.onInputChange(e);
|
|
}}
|
|
}}
|
|
@@ -54,14 +94,21 @@ export default class Login extends React.Component {
|
|
<br />
|
|
<br />
|
|
<Row>
|
|
<Row>
|
|
<Col span={22} push={1}>
|
|
<Col span={22} push={1}>
|
|
- <Input type="password" name="password" placeholder="Password" onChange={e => this.onInputChange(e)} />
|
|
|
|
|
|
+ <Input
|
|
|
|
+ type="password"
|
|
|
|
+ name="password"
|
|
|
|
+ value={this.state.password}
|
|
|
|
+ placeholder="Password"
|
|
|
|
+ onPressEnter={e => this.sublime(e)}
|
|
|
|
+ onChange={e => this.onInputChange(e)}
|
|
|
|
+ />
|
|
</Col>
|
|
</Col>
|
|
</Row>
|
|
</Row>
|
|
<br />
|
|
<br />
|
|
<Row>
|
|
<Row>
|
|
<Col span={22} push={1}>
|
|
<Col span={22} push={1}>
|
|
- <Button block type="primary">
|
|
|
|
- 登陆1
|
|
|
|
|
|
+ <Button block type="primary" size="large" onClick={e => this.sublime(e)}>
|
|
|
|
+ 登陆
|
|
</Button>
|
|
</Button>
|
|
</Col>
|
|
</Col>
|
|
</Row>
|
|
</Row>
|