text: import React, { Component } from 'react';
  import { connect } from 'dva';
  import Link from 'umi/link';
  import { Alert } from 'antd';
  import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale';
  import Login from '@/components/Login';
  import styles from './Login.less';
  
  const { UserName, Password, Submit } = Login;
  
  @connect(({ login, loading }) => ({
    login,
    submitting: loading.effects['login/login'],
  }))
  class LoginPage extends Component {
    state = {
      // type: 'account',
      // autoLogin: true,
    };
  
    handleSubmit = (err, values) => {
      // const { type } = this.state;
      if (!err) {
        const { dispatch } = this.props;
        dispatch({
          type: 'login/login',
          payload: {
            ...values,
            // type,
          },
        });
      }
    };
  
    // changeAutoLogin = e => {
    //   this.setState({
    //     autoLogin: e.target.checked,
    //   });
    // };
  
    renderMessage = content => (
      <Alert style={{ marginBottom: 24 }} message={content} type="error" showIcon />
    );
  
    render() {
      const { login, submitting } = this.props;
      // const { autoLogin } = this.state;
      return (
        <div className={styles.main}>
          <Login
            onSubmit={this.handleSubmit}
            ref={form => {
              this.loginForm = form;
            }}
          >
            {login.status === 'error' &&
              // login.type === 'account' &&
              !submitting &&
              this.renderMessage(formatMessage({ id: 'app.login.message-invalid-credentials' }))}
            <UserName
              name="email"
              placeholder="email"
              rules={[
                {
                  required: true,
                  message: "email is required!",
                },
              ]}
            />
            <Password
              name="password"
              placeholder="password"
              rules={[
                {
                  required: true,
                  message: "password is required",
                },
              ]}
              onPressEnter={e => {
                e.preventDefault();
                this.loginForm.validateFields(this.handleSubmit);
              }}
            />
            <div>
              {/* <Checkbox checked={autoLogin} onChange={this.changeAutoLogin}>
                <FormattedMessage id="app.login.remember-me" />
              </Checkbox> */}
              <a style={{ float: 'right' }} href="">
                <FormattedMessage id="app.login.forgot-password" />
              </a>
            </div>
            <Submit loading={submitting}>
              <FormattedMessage id="app.login.login" />
            </Submit>
            <div className={styles.other}>
              <Link className={styles.register} to="/user/register">
                <FormattedMessage id="app.login.signup" />
              </Link>
            </div>
          </Login>
        </div>
      );
    }
  }
  
  export default LoginPage;
  