content: import React from 'react'
  import { Form, Input, message as msgTool } from 'antd'
  import { resultEnum } from '../../utils'
  import styles from './index.less'
  const FormItem = Form.Item;
  class LoginByPassword extends React.Component {
      componentWillReceiveProps( nextProps ) {
          const { validator, form: { setFields, getFieldValue, } } = nextProps;
          if ( validator.timeTamp == this.props.validator.timeTamp ) return;
          const { field, message } = validator;
          const value = getFieldValue( field );
          setFields( { [ field ]: { errors: [ new Error( message + '[' + value + ']' ) ] } } );
          //自动更新验证码
          this.props.captchaProps.update();
      }
  
      render() {
          const { form: { getFieldDecorator, }, handleLogin, captchaProps: { code, update, ...captchaOther } } = this.props;
          return (
              <div>
                  <FormItem hasFeedback>
                      { getFieldDecorator( 'username', {
                          rules: [
                              {
                                  required: true,
                                  whitespace: true,
                                  message: '请填写用户名',
                              },
                          ],
                      } )( <Input size="large" onPressEnter={ handleLogin } placeholder="用户名" /> ) }
                  </FormItem>
                  <FormItem hasFeedback>
                      { getFieldDecorator( 'password', {
                          rules: [
                              {
                                  required: true,
                                  message: '请填写密码',
                              },
                          ],
                      } )( <Input size="large" type="password" onPressEnter={ handleLogin } placeholder="密码" /> ) }
                  </FormItem>
                  <FormItem hasFeedback>
                      { getFieldDecorator( 'captcha', {
                          rules: [ {
                              required: true,
                              whitespace: true,
                              pattern: new RegExp( `^${ code }$` ),
                              message: '请填写有效的验证码'
                          }]
                      } )( <Input size="large" onPressEnter={ handleLogin } placeholder="验证码" addonAfter={ <img className={ styles.code_img } {...captchaOther} /> } /> )
                      }
                  </FormItem>
              </div>
          )
      }
  }
  export default LoginByPassword;