chengkun
2025-04-27 a0402d122fee696e2b7684ef7edfc504ade12640
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
$(document).ready(function(){
 
 
var handlerPopup = function (captchaObj) {
    // 成功的回调
    
    captchaObj.onSuccess(function () {
 
        var validate = captchaObj.getValidate();
        
        if(validate){
 
            
            $("input[name='verify_token']").val(validate.geetest_challenge+'*'+validate.geetest_validate+'*'+validate.geetest_seccode);
 
            //提交操作
            
            var type = $('#bind-captcha').attr('data-type');
            var dataid = $('#bind-captcha').attr('data-id');
            //提交表单
            if(type=='submit'){
                $('#'+dataid).submit();
            }else{
                //模拟点击
                $("#"+dataid).trigger("click");
            }
        }
 
    });
 
    $("#bind-submit").click(function(){
        captchaObj.verify();
    });
    $("#popup-submit").click(function(){
        $("input[name='verify_token']").val('');
        
        captchaObj.reset();
    });
    
    // 将验证码加到id为captcha的元素里
    
    //captchaObj.appendTo("#bind-captcha");
    // 更多接口参考:http://www.geetest.com/install/sections/idx-client-sdk.html
 
};
 
if($("#bind-captcha").length>0){
    $.ajax({
            url: weburl+"/index.php?m=geetest&t=" + (new Date()).getTime(), // 加随机数防止缓存
            type: "get",
            dataType: "json",
            success: function (data) {
                // 使用initGeetest接口
                // 参数1:配置参数
                // 参数2:回调,回调的第一个参数验证码对象,之后可以使用它做appendTo之类的事件
                initGeetest({
                    gt: data.gt,
                    challenge: data.challenge,
                    product: "bind", // 产品形式,包括:float,embed,popup。注意只对PC版验证码有效
                    width:"100%",
                    offline: !data.success, // 表示用户后台检测极验服务器是否宕机,一般不需要关注
                    new_captcha: data.new_captcha
                }, handlerPopup);
            }
    });
}
 
});