import React, { Component } from 'react';
import { initCaptcha } from '@/utils';

const CAPTCHAID = '6b0f5f6c8f334f3693ee754ba5692e36'


class Captcha extends Component {

    componentDidMount() {
        const {getInstance, handleError, onVerify} = this.props
        initCaptcha(function () {
            initNECaptcha({
                    element: '#captcha',
                    captchaId: CAPTCHAID,
                    mode: 'float',
                    width: 'auto',
                    onVerify: function (err, data) {
                        onVerify(err,data)
                    }
                },
                instance => {
                    getInstance && getInstance(instance)
                },
                err => {
                    handleError && handleError(err)
                }
            )
        })
    }

    render() {
        return (
            <div id={'captcha'} style={{'marginBottom': '33px'}}></div>
        );
    }
}

export default Captcha;