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: "get",
            dataType: "json",
            crossDomain: false,
            url: globalConfig.context + "/api/user/identFailed",
            data: {
            }
        }).done(function (data) {
            if (!data.error.length) {
                message.success('已提交重新审核！');
                this.props.changeStep(1);
            } 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({
                        auditStatus: data.data.auditStatus
                    });
                } else {
                    message.warning(data.error[0].message);
                };
            }.bind(this),
        });
    },
    render() {
        const _me = this;
        return (
            <Spin spinning={this.state.loading} className="certify-spin">
                {(() => {
                    switch (this.state.auditStatus) {
                        case 4:
                            return <div className="certify-result-box">
                                <p className="certify-title"
                                    style={{ 'textAlign': 'center' }}
                                >输入的金额正确后，即时审核您填写的身份信息，请耐心等待2秒钟;如审核通过，即认证申请成功</p>
                                <div className="certify-result-state">
                                    <Icon type="check" />
                                    <p>您已通过了实名认证</p>
                                    <p>建议您下载数字证书，保障您的支付安全。</p>
                                </div>
                            </div>;
                        case 5:
                            return <div className="certify-result-box">
                                <p className="certify-title"
                                    style={{ 'textAlign': 'center' }}
                                >若输入金额错误，则实名认证不通过。可重新申请实名认证。</p>
                                <div className="certify-result-state">
                                    <Icon type="exclamation-circle" />
                                    <p>您未能通过实名认证审核</p>
                                    <p>可能的原因是：</p>
                                    <p>您提交的认证资料不符合要求，未能通过实名认证；</p>
                                    <p>您输入的金额有误，未能通过实名认证；</p>
                                    <p>您未及时在规定的5天期限内输入金额，未能通过实名认证；</p>
                                    <Button className="set-submit" type="primary" htmlType="submit">重新申请实名认证</Button>
                                </div>
                            </div>;
                    };
                })()}
            </Spin >
        );
    },
}));

export default Content;