import React from 'react'; import { Form, Icon, Input, Button, Checkbox, Spin } from 'antd'; import './login.less'; import ajax from 'jquery/src/ajax/xhr.js' import $ from 'jquery/src/ajax'; 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.setState({ loading: true }); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/signin", data: { user: values.userName, pwd: values.password, remember:values.remember, group: this.props.loginProp === "2" ? true : false } }).done(function (data) { if (!data.error.length) { window.location.href = "warning.html" } else { this.tips(data.error[0].message); } }.bind(this)).always(function () { this.setState({ loading: false }); }.bind(this)); } }); }, render() { const { getFieldDecorator } = this.props.form; return (
{getFieldDecorator('userName', { rules: [{ required: true, message: 'Please input your username!' }], })( } placeholder="Username" /> )} {getFieldDecorator('password', { rules: [{ required: true, message: 'Please input your Password!' }], })( } type="password" placeholder="Password" /> )} {getFieldDecorator('remember', { valuePropName: 'checked', initialValue: true, })( 记住我 )} 忘记密码
); }, })); export default LoginForm;