index.js 1.04 KB
Newer Older
zhanghaozhe committed
1 2 3 4 5 6 7 8 9
import React, { Component } from 'react';
import { initCaptcha } from '@/utils';

const CAPTCHAID = '6b0f5f6c8f334f3693ee754ba5692e36'


class Captcha extends Component {
    componentDidMount() {
        const {getInstance, handleError, onVerify} = this.props
xuzhenghua committed
10 11
        const el = document.getElementById('captcha')
        el && initCaptcha(function () {
zhanghaozhe committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
            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 (
xuzhenghua committed
33
            <div id={'captcha'} style={{'marginBottom':  this.props.mrBtm}}></div>
zhanghaozhe committed
34 35 36 37 38
        );
    }
}

export default Captcha;