/
Login.jsx
208 lines (196 loc) · 4.84 KB
/
Login.jsx
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/* eslint react/no-string-refs:0 */
import React, { Component } from 'react';
import { Input, Button, Checkbox, Grid, Message, Icon, Form } from '@alifd/next';
import './Login.scss';
const { Row, Col } = Grid;
const Item = Form.Item;
export default class Login extends Component {
static displayName = 'Login';
static propTypes = {};
static defaultProps = {};
constructor(props) {
super(props);
this.state = {
value: {
account: '',
password: '',
checkbox: false,
},
};
}
formChange = (value) => {
this.setState({
value,
});
};
handleSubmit = (values, errors) => {
if (errors) {
console.log('errors', errors);
return;
}
console.log('values:', values);
Message.success('登录成功');
// 登录成功后做对应的逻辑处理
};
render() {
return (
<div style={styles.container} className="user-login">
<div style={styles.header}>
<a href="#" style={styles.meta}>
<img
style={styles.logo}
src={require('./images/TB13UQpnYGYBuNjy0FoXXciBFXa-242-134.png')}
alt="logo"
/>
<span style={styles.title}>飞冰</span>
</a>
<p style={styles.desc}>飞冰让前端开发简单而友好</p>
</div>
<div style={styles.formContainer}>
<h4 style={styles.formTitle}>登 录</h4>
<Form
value={this.state.value}
onChange={this.formChange}
size="large"
ref="form"
>
<Item required requiredMessage="必填">
<Input
name="account"
innerBefore={<Icon
type="account"
size="small"
style={styles.inputIcon}
/>}
size="large"
maxLength={20}
placeholder="管理员账号"
/>
</Item>
<Item required requiredMessage="必填">
<Input
name="password"
innerBefore={<Icon type="account" size="small" style={styles.inputIcon} test="lock" />}
size="large"
htmlType="password"
placeholder="密码"
/>
</Item>
<Item >
<Checkbox name="checkbox" style={styles.checkbox}>记住账号</Checkbox>
</Item>
<Row style={styles.formItem}>
<Form.Submit
type="primary"
onClick={this.handleSubmit}
style={styles.submitBtn}
validate
>
登 录
</Form.Submit>
</Row>
<Row className="tips" style={styles.tips}>
<a href="/" style={styles.link}>
立即注册
</a>
<span style={styles.line}>|</span>
<a href="/" style={styles.link}>
忘记密码
</a>
</Row>
</Form>
</div>
</div>
);
}
}
const styles = {
container: {
position: 'relative',
width: '100%',
height: '100vh',
paddingTop: '100px',
background: '#f0f2f5',
backgroundImage: `url${require('./images/TB1kOoAqv1TBuNjy0FjXXajyXXa-600-600.png')}`,
},
header: {
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
marginBottom: '40px',
},
meta: {
display: 'flex',
alignItems: 'center',
textDecoration: 'none',
},
title: {
textAlign: 'center',
fontSize: '33px',
color: 'rgba(0, 0, 0, 0.85)',
fontFamily: 'Myriad Pro, Helvetica Neue, Arial, Helvetica, sans-serif',
fontWeight: '600',
},
desc: {
margin: '10px 0',
fontSize: '14px',
color: 'rgba(0, 0, 0, 0.45)',
},
logo: {
marginRight: '10px',
width: '48px',
},
formContainer: {
display: 'flex',
justifyContent: 'center',
flexDirection: 'column',
maxWidth: '368px',
margin: '0 auto',
},
formItem: {
position: 'relative',
marginBottom: '25px',
flexDirection: 'column',
padding: '0',
},
formItemCol: {
position: 'relative',
padding: '0',
},
formTitle: {
textAlign: 'center',
margin: '0 0 20px',
color: 'rgba(0, 0, 0, 0.85)',
fontWeight: 'bold',
},
inputIcon: {
position: 'absolute',
left: '12px',
top: '50%',
transform: 'translateY(-50%)',
color: '#999',
},
submitBtn: {
fontSize: '16px',
height: '40px',
lineHeight: '40px',
background: '#3080fe',
borderRadius: '4px',
},
checkbox: {
marginLeft: '5px',
},
tips: {
justifyContent: 'center',
},
link: {
color: '#999',
textDecoration: 'none',
fontSize: '13px',
},
line: {
color: '#dcd6d6',
margin: '0 8px',
},
};