张延森 3 years ago
parent
commit
f11a0f0360

+ 1
- 1
config/defaultSettings.js View File

12
   menu: {
12
   menu: {
13
     locale: false,
13
     locale: false,
14
   },
14
   },
15
-  title: '新 联 ',
15
+  title: '新 联 ',
16
   pwa: false,
16
   pwa: false,
17
   iconfontUrl: '',
17
   iconfontUrl: '',
18
 };
18
 };

+ 1
- 1
src/components/Poster/Preview.jsx View File

24
       <Row gutter={24} style={{padding: '2em'}}>
24
       <Row gutter={24} style={{padding: '2em'}}>
25
         <Col span={6}><Avatar size={78} src={avatar} /></Col>
25
         <Col span={6}><Avatar size={78} src={avatar} /></Col>
26
         <Col span={10}>
26
         <Col span={10}>
27
-          <Title level={4}>新联</Title>
27
+          <Title level={4}>新联</Title>
28
           <div>长按识别看房</div>
28
           <div>长按识别看房</div>
29
         </Col>
29
         </Col>
30
         <Col span={8}><img src={qrCode} alt="" style={qrStyle} /></Col>
30
         <Col span={8}><img src={qrCode} alt="" style={qrStyle} /></Col>

+ 2
- 2
src/layouts/UserLayout.jsx View File

42
           <SelectLang />
42
           <SelectLang />
43
         </div> */}
43
         </div> */}
44
         <div className={styles.content}>
44
         <div className={styles.content}>
45
-          <div className={styles.top}>
45
+          {/* <div className={styles.top}>
46
             <div className={styles.header}>
46
             <div className={styles.header}>
47
               <Link to="/">
47
               <Link to="/">
48
                 <img alt="logo" className={styles.logo} src={logo} />
48
                 <img alt="logo" className={styles.logo} src={logo} />
50
               </Link>
50
               </Link>
51
             </div>
51
             </div>
52
             <div className={styles.desc}>Ant Design 是西湖区最具影响力的 Web 设计规范</div>
52
             <div className={styles.desc}>Ant Design 是西湖区最具影响力的 Web 设计规范</div>
53
-          </div>
53
+          </div> */}
54
           {children}
54
           {children}
55
         </div>
55
         </div>
56
         <GlobalFooter />
56
         <GlobalFooter />

+ 57
- 97
src/pages/user/login/index.jsx View File

1
-import { Alert, Icon } from 'antd';
2
-import { FormattedMessage, formatMessage } from 'umi-plugin-react/locale';
3
-import React, { Component } from 'react';
1
+import React, { useState } from 'react';
4
 import { connect } from 'dva';
2
 import { connect } from 'dva';
5
 import md5 from "md5";
3
 import md5 from "md5";
6
-import LoginComponents from './components/Login';
4
+import { Form, Input, Button } from 'antd'
7
 import styles from './style.less';
5
 import styles from './style.less';
8
-import { defineLocale } from 'moment';
9
 
6
 
10
-const { UserName, Password, Submit } = LoginComponents;
7
+const buttonItemLayout = {
8
+  wrapperCol: { span: 14, offset: 4 },
9
+}
11
 
10
 
12
-@connect(({ login, loading }) => ({
13
-  userLogin: login,
14
-  submitting: loading.effects['login/login'],
15
-}))
16
-class Login extends Component {
17
-  loginForm = undefined;
11
+const formItemLayout = {
12
+  labelCol: { span: 6 },
13
+  wrapperCol: { span: 18 },
14
+}
18
 
15
 
19
-  handleSubmit = (err, values) => {
20
-    if (!err) {
21
-      const { dispatch } = this.props;
22
-      try {
23
-        dispatch({
24
-          type: 'login/login',
25
-          payload: { ...values, loginPassword: md5(values.loginPassword) },
26
-        });
27
-      } catch (e) {
28
-        console.error(e)
29
-      }
30
-    }
16
+const LoginForm = React.forwardRef((props, ref) => {
17
+  const { form, dispatch } = props;
18
+  const { getFieldDecorator, validateFields } = form;
31
 
19
 
32
-  };
20
+  const [loading, setLoading] = useState(false)
33
 
21
 
34
-  renderMessage = (content) => (
35
-    <Alert
36
-      style={{
37
-        marginBottom: 24,
38
-      }}
39
-      message={content}
40
-      type="error"
41
-      showIcon
42
-    />
43
-  );
22
+  const handleSubmit = (e) => {
23
+    e.preventDefault();
24
+    validateFields((err, values) => {
25
+      if (!err) {
26
+        try {
27
+          setLoading(true)
28
+          dispatch({
29
+            type: 'login/login',
30
+            payload: { ...values, loginPassword: md5(values.loginPassword) },
31
+          }).then(() => {
32
+            setLoading(false)
33
+          });
34
+        } catch (e) {
35
+          console.error(e)
36
+          setLoading(false)
37
+        }
38
+      }
39
+    });
40
+  }
44
 
41
 
45
-  render() {
46
-    const { userLogin = {}, submitting } = this.props;
47
-    const { status } = userLogin;
48
-    // const { type, autoLogin } = this.state;
49
-    return (
50
-      <div className={styles.main}>
51
-        <LoginComponents
52
-          onTabChange={this.onTabChange}
53
-          onSubmit={this.handleSubmit}
54
-          onCreate={(form) => {
55
-            this.loginForm = form;
56
-          }}
57
-          >
58
-          {status === 'error' &&
59
-            !submitting &&
60
-            this.renderMessage(
61
-              formatMessage({
62
-                id: 'user-login.login.message-invalid-credentials',
63
-              }),
64
-            )}
65
-          <UserName
66
-            name="loginName"
67
-            placeholder={`${formatMessage({
68
-              id: 'user-login.login.userName',
69
-            })}: admin or user`}
70
-            rules={[
71
-              {
72
-                required: true,
73
-                message: formatMessage({
74
-                  id: 'user-login.userName.required',
75
-                }),
76
-              },
77
-            ]}
78
-          />
79
-          <Password
80
-            name="loginPassword"
81
-            placeholder={`${formatMessage({
82
-              id: 'user-login.login.password',
83
-            })}: ant.design`}
84
-            rules={[
85
-              {
86
-                required: true,
87
-                message: formatMessage({
88
-                  id: 'user-login.password.required',
89
-                }),
90
-              },
91
-            ]}
92
-            onPressEnter={(e) => {
93
-              e.preventDefault();
42
+  return (
43
+    <div className={styles.main}>
44
+      <div></div>
45
+      <div>
46
+        <Form onSubmit={handleSubmit}>
47
+          <Form.Item label="用户名" {...formItemLayout} colon={false}>
48
+            {getFieldDecorator('loginName', {
49
+              rules: [{ required: true, message: '请输入用户名' }]
50
+            })(<Input />)}          
51
+          </Form.Item>
52
+          <Form.Item label="密 码" {...formItemLayout} colon={false}>
53
+            {getFieldDecorator('loginPassword', {
54
+              rules: [{ required: true, message: '请输入密码' }]
55
+            })(<Input.Password visibilityToggle={false}/>)}          
56
+          </Form.Item>
94
 
57
 
95
-              if (this.loginForm) {
96
-                this.loginForm.validateFields(this.handleSubmit);
97
-              }
98
-            }}
99
-          />
100
-          <Submit loading={submitting}>
101
-            <FormattedMessage id="user-login.login.login" />
102
-          </Submit>
103
-        </LoginComponents>
58
+          <Button
59
+            loading={loading}
60
+            htmlType="submit"
61
+            className={styles['login-form-button']}
62
+          >登录</Button>
63
+        </Form>
104
       </div>
64
       </div>
105
-    );
106
-  }
107
-}
65
+    </div>
66
+  )
67
+});
108
 
68
 
109
 export default connect(({ login, loading }) => ({
69
 export default connect(({ login, loading }) => ({
110
   userLogin: login,
70
   userLogin: login,
111
   submitting: loading.effects['login/login'],
71
   submitting: loading.effects['login/login'],
112
-}))(Login);
72
+}))(Form.create({})(LoginForm));

+ 48
- 2
src/pages/user/login/style.less View File

1
 @import '~antd/es/style/themes/default.less';
1
 @import '~antd/es/style/themes/default.less';
2
 
2
 
3
 .main {
3
 .main {
4
-  width: 368px;
5
-  margin: 0 auto;
4
+  width: 840px;
5
+  margin: 20vh auto 0;
6
+  background: rgba(17, 40, 81, 0.41);
7
+  box-shadow: 0px 8px 38px 0px rgba(4, 0, 0, 0.12);
8
+  border-radius: 24px;
9
+  box-sizing: border-box;
10
+  padding: 87px 0 120px;
11
+  display: flex;
6
   @media screen and (max-width: @screen-sm) {
12
   @media screen and (max-width: @screen-sm) {
7
     width: 95%;
13
     width: 95%;
8
   }
14
   }
9
 
15
 
16
+  & > div {
17
+    flex: none;
18
+    width: 50%;
19
+  }
20
+
10
   .icon {
21
   .icon {
11
     margin-left: 16px;
22
     margin-left: 16px;
12
     color: rgba(0, 0, 0, 0.2);
23
     color: rgba(0, 0, 0, 0.2);
30
     }
41
     }
31
   }
42
   }
32
 
43
 
44
+  .login-form-button {
45
+    width: 100%;
46
+    font-size: 18px;
47
+    line-height: 48px;
48
+    height: 48px !important;
49
+    color: #fff !important;
50
+    background: #1548B6 !important;
51
+    border-radius: 48px;
52
+    border: none !important;
53
+  }
54
+
33
   :global {
55
   :global {
56
+    .ant-form {
57
+      width: 260px;
58
+      margin-left: 60px;
59
+    }
60
+
61
+    .ant-form-item {
62
+      border-bottom: 2px solid #fff;
63
+    }
64
+
65
+    .ant-form-item-label > label {
66
+      color: #fff;
67
+    }
68
+
69
+    .ant-input {
70
+      color: #fff;
71
+      border: none;
72
+      background: transparent;
73
+      outline: none;
74
+
75
+      &:focus {
76
+        box-shadow: none;
77
+      }
78
+    }
79
+
34
     .antd-pro-login-submit {
80
     .antd-pro-login-submit {
35
       width: 100%;
81
       width: 100%;
36
       margin-top: 24px;
82
       margin-top: 24px;

+ 2
- 2
src/utils/request.js View File

46
 
46
 
47
   return (
47
   return (
48
     {
48
     {
49
-      // url: 'https://xlk.njyz.tech' + apiURL,
50
-      url: apiURL,
49
+      url: 'https://xlk.njyz.tech' + apiURL,
50
+      // url: apiURL,
51
       options: {
51
       options: {
52
         ...opts,
52
         ...opts,
53
         headers: {
53
         headers: {