Login.js
2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import React from 'react';
import { connect } from 'react-redux';
import { submit } from 'redux-form';
import { Form, Icon, Input, Button, Checkbox } from 'antd';
import cx from 'classnames';
import ReduxFormWrap from '../components/reduxForm/ReduxFormWrap';
import InputField from '../components/reduxForm/InputField';
import { required } from '../components/reduxForm/validate';
import api from '../utils/api';
import './login.less';
class Login extends React.Component {
static propTypes = {
}
constructor(props) {
super(props);
this.submitLogin = this.submitLogin.bind(this);
this.backLogin = this.backLogin.bind(this);
this.state = {
key: '1'
};
}
componentDidMount() {
}
submitLogin(values) {
const { dispatch } = this.props;
api.postLogin(values).then(data => {
console.log(data);
})
console.log("#########:::::::", values);
// if (values.grant_type == 'password') { //密码登录
// dispatch(login(values));
// } else if (values.grant_type == 'smscode') {//验证码登录
// dispatch(login(values));
// } else if (values.grant_type == 'change_tenant') {//选择tenant
// dispatch(changeTenant(values));
// }
}
backLogin() {
const { dispatch } = this.props;
dispatch({
type: types.UAA_TENANTS,
payload: {}
});
}
render() {
const { key } = this.state;
const { dispatch, uaa_tenants } = this.props;
return (
<div className={cx('login_wrap')}>
<div className={cx('login_form_wrap', 'padding-16')}>
<div className={cx('login_form_bgm')}></div>
<ReduxFormWrap form="login_password" initialValues={{ grant_type: 'password', scope: 'global_access:tenant_admin', username: '18510929499', password: 'a123456' }} className={'mtop-40'}
onSubmit={this.submitLogin}>
<InputField width="auto" prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.75)' }} />} placeholder="用户名" name="username" validate={[required]} />
<InputField width="auto" prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.75)' }} />} placeholder="密码" name="password" validate={[required]} />
<div className={cx('login_form_item')}>
<Button type="primary" block onClick={() => {
dispatch(submit('login_password'))
}}>登录</Button>
</div>
</ReduxFormWrap>
</div>
</div >
);
}
}
const mapState = (state) => {
const {
router: { location = {} }
} = state;
return {
location
};
};
export default connect(mapState)(Login);