import React, { Component } from 'react';
import { connect } from 'dva';
import { routerRedux, Link } from 'dva/router';
import { Form, Input, Tabs, Button, Icon, Checkbox, Row, Col, Alert } from 'antd';
import styles from './Login.less';
const FormItem = Form.Item;
const TabPane = Tabs.TabPane;
@connect(state => ({
login: state.login,
}))
@Form.create()
export default class Login extends Component {
state = {
count: 0,
type: 'account',
}
componentWillReceiveProps(nextProps) {
if (nextProps.login.status === 'ok') {
this.props.dispatch(routerRedux.push('/'));
}
}
componentWillUnmount() {
clearInterval(this.interval);
}
onSwitch = (key) => {
this.setState({
type: key,
});
}
onGetCaptcha = () => {
let count = 59;
this.setState({ count });
this.interval = setInterval(() => {
count -= 1;
this.setState({ count });
if (count === 0) {
clearInterval(this.interval);
}
}, 1000);
}
handleSubmit = (e) => {
e.preventDefault();
const { type } = this.state;
this.props.form.validateFields({ force: true },
(err, values) => {
if (!err) {
this.props.dispatch({
type: `login/${type}Submit`,
payload: values,
});
}
}
);
}
msg = (message) => {
return (