import React from 'react';
import { Input, Button, Form, Icon, Spin, message, } from 'antd';
import './certify.less';
import ajax from 'jquery/src/ajax/xhr.js'
import $ from 'jquery/src/ajax';


const Content = Form.create()(React.createClass({
    getInitialState() {
        return {
            loading: false
        };
    },
    handleSubmit() {
        this.setState({
            loading: true
        });
        $.ajax({
            method: "POST",
            dataType: "json",
            crossDomain: false,
            url: globalConfig.context + "/api/user/orgNextPro",
            data: {
                process: 4
            }
        }).done(function (data) {
            if (!data.error.length) {
                message.success('保存成功！');
                this.props.changeStep(5);
            } else {
                message.warning(data.error[0].message);
            }
        }.bind(this)).always(function () {
            this.setState({
                loading: false
            });
        }.bind(this));
    },
    componentWillMount() {
        $.ajax({
            method: "get",
            dataType: "json",
            url: globalConfig.context + "/api/user/orgProcess",
            success: function (data) {
                if (data.data) {
                    this.setState({
                        bankCardNumber : data.data.bankCardNumber,
                        auditStatus : data.data.auditStatus
                    });
                };
            }.bind(this),
        }).done(function (data) {
            if (data.error.length) {
                message.warning(data.error[0].message);
            };
            this.setState({
                loading:false
            });
        }.bind(this));
    },
    render() {
        const FormItem = Form.Item;
        const { getFieldDecorator } = this.props.form;
        const formItemLayout = {
            labelCol: { span: 4 },
            wrapperCol: { span: 12 },
        };
        const _me = this;
        return (
            <Spin spinning={this.state.loading} className="certify-spin">
                <Form horizontal onSubmit={this.handleSubmit} className="certify-form">
                    <FormItem wrapperCol={{ span: 12, offset: 4 }}>
                        <p className="certify-title">信息提交成功</p>
                    </FormItem>
                    <FormItem wrapperCol={{ span: 18, offset: 4 }}>
                        <span>
                            认证系统将会在1-2个工作日内给您的银行卡{this.state.bankCardNumber}转入一笔1元以下的确认金额，
                            然后在下方正确填写正确的金额数目。
                            若打款成功，认证系统将会通过短信的方式通知您
                        </span>
                    </FormItem>
                    <FormItem wrapperCol={{ span: 12, offset: 4 }}>
                        <Button disabled={this.state.auditStatus == "3" ? false : true } className="set-submit" type="primary" htmlType="submit">输入打款金额</Button>
                    </FormItem>
                </Form >
            </Spin >
        );
    },
}));

export default Content;