Files
yunzerwebsiteallinone/uniapp/static/html/geetest-captcha.html
T
2026-07-15 22:38:33 +08:00

75 lines
1.8 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>人机验证</title>
<style>
html, body {
margin: 0;
padding: 0;
background: rgba(0, 0, 0, 0.45);
height: 100%;
}
</style>
<script src="./gt4.js"></script>
<script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.4.js"></script>
</head>
<body>
<script>
(function () {
var params = new URLSearchParams(window.location.search)
var captchaId = params.get('captchaId') || ''
function postToUni(payload) {
if (window.uni && typeof uni.postMessage === 'function') {
uni.postMessage({ data: payload })
}
}
function closePage() {
if (window.uni && typeof uni.navigateBack === 'function') {
setTimeout(function () { uni.navigateBack() }, 120)
}
}
if (!captchaId || typeof initGeetest4 !== 'function') {
postToUni({ type: 'fail', msg: '极验初始化失败' })
closePage()
return
}
initGeetest4({
captchaId: captchaId,
product: 'bind',
language: 'zh-CN'
}, function (instance) {
instance.onSuccess(function () {
var result = instance.getValidate() || {}
postToUni({
type: 'success',
result: {
captcha_id: result.captcha_id || captchaId,
lot_number: result.lot_number || '',
pass_token: result.pass_token || '',
gen_time: result.gen_time || '',
captcha_output: result.captcha_output || ''
}
})
closePage()
})
instance.onFail(function () {
postToUni({ type: 'fail', msg: '人机验证未通过' })
closePage()
})
instance.onError(function () {
postToUni({ type: 'fail', msg: '人机验证加载失败' })
closePage()
})
instance.showCaptcha()
})
})()
</script>
</body>
</html>