var handlerEmbed = function(captchaObj) { captchaObj.onReady(function () { document.getElementById("captcha_wait").style.display = "none"; document.getElementById("captcha_btn").style.display = "inline-block"; }).onSuccess(function () { var result = captchaObj.getValidate(); if (!result) { return false; } document.getElementById("captcha_wait").style.display = "flex"; document.getElementById("captcha_btn").style.display = "none"; fetch("https://www.szsy.net.cn/api/captcha.php?method=getToken&g_challenge=" + result.geetest_challenge + "&g_validate=" + result.geetest_validate + "&g_seccode=" + result.geetest_seccode + "&t=" + (new Date()).getTime(),{ method: "GET" }).then((response) => { return response.json(); }).then((data) => { document.getElementById("captcha_wait").style.display = "none"; document.getElementById("captcha_btn").style.display = "inline-block"; if(data["code"]==200){ document.getElementById("captcha_btn").disabled=true; document.getElementById("captcha_btn").style.color = "green"; document.getElementById("captcha_btn").innerHTML = "验证成功"; document.getElementById("captcha_btn").onclick = function() { return false; } window.location.reload(); }else{ document.getElementById("captcha_btn").style.color = "red"; document.getElementById("captcha_btn").innerHTML = "验证失败,请重试"; } }); }); document.getElementById("captcha_btn").onclick = function() { captchaObj.verify(); } }; window.onload = function (){ fetch("https://www.szsy.net.cn/api/geetest/verifyOne.php?type=pc&t=" + (new Date()).getTime(),{ method: "GET" }).then((response) => { return response.json(); }).then((data) => { initGeetest({ gt: data["gt"], challenge: data["challenge"], product: "bind", width: '100%', offline: !data["success"] }, handlerEmbed); }) } function request(obj) { return new Promise(function (resolve, reject) { var xhr = new XMLHttpRequest(); switch(obj.type) { case 'get': xhr.open('GET', obj.url, true); xhr.onload = function() { resolve(obj.success(JSON.parse(this.responseText))) }; xhr.onError= function () { reject(obj.error({ status: this.status, statusText: xhr.statusText })); }; break; case 'post': xhr.open('POST', obj.url, true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.onreadystatechange = function() { if (this.readyState === XMLHttpRequest.DONE && this.status === 200) { resolve(obj.success(JSON.parse(this.responseText))) } }; break; } xhr.send(JSON.stringify(obj.data)); }); }