import React from 'react'; import { Form, Icon, Input, Button, Checkbox, Spin, message } from 'antd'; import './login.less'; import ajax from 'jquery/src/ajax/xhr.js' import $ from 'jquery/src/ajax'; import ForgetPw from './forgetPw.jsx'; const FormItem = Form.Item; const LoginForm = Form.create()(React.createClass({ getInitialState() { return { loading: false }; }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { if (!err) { this.props.spinState(true); $.ajax({ method: "POST", dataType: "json", url: globalConfig.context + "/signin", data: { "mobile": values.phone, "password": values.password, "type": this.props.loginProp, "remember": values.remember } }).done(function (res) { if (res.error && res.error.length) { message.warning(res.error[0].message); } else { let data = res.data; if (data && data.requestURI) { let path = globalConfig.context + data.requestURI if (data.queryString) { path += '?' + data.queryString; } if (window.location.hash) { path += window.location.hash; } window.location.href = path; } else { window.location.href = globalConfig.context + "/user/account/index.html"; } } }.bind(this)).always(function () { this.props.spinState(false); }.bind(this)); } }); }, render() { const { getFieldDecorator } = this.props.form; return (
); }, })); export default LoginForm;