修复h5记事本不显示问题

This commit is contained in:
2026-08-18 09:25:51 +08:00
parent aed71d237d
commit 0e797c39f4
11 changed files with 911 additions and 452 deletions
+38 -7
View File
@@ -36,24 +36,47 @@ function showGeetest4H5(captchaId) {
reject(new Error('极验 SDK 未加载'))
return
}
let settled = false
const settle = (fn) => {
if (settled) return
settled = true
fn()
}
window.initGeetest4(
{
captchaId,
product: 'bind',
language: 'zh-CN'
language: 'zh-CN',
https: true
},
(instance) => {
instance.onSuccess(() => {
resolve(normalizeValidate(instance.getValidate(), captchaId))
if (typeof instance.destroy === 'function') {
instance.destroy()
const teardown = () => {
try {
if (typeof instance.hideCaptcha === 'function') instance.hideCaptcha()
if (typeof instance.destroy === 'function') instance.destroy()
} catch {
// ignore
}
}
instance.onSuccess(() => {
const result = normalizeValidate(instance.getValidate(), captchaId)
teardown()
settle(() => resolve(result))
})
instance.onFail(() => {
reject(new Error('人机验证未通过'))
teardown()
settle(() => reject(new Error('人机验证未通过')))
})
instance.onError(() => {
reject(new Error('人机验证加载失败'))
teardown()
settle(() => reject(new Error('人机验证加载失败')))
})
instance.onClose?.(() => {
setTimeout(() => {
if (settled) return
teardown()
settle(() => reject(new Error('已取消人机验证')))
}, 400)
})
instance.showCaptcha()
}
@@ -64,6 +87,14 @@ function showGeetest4H5(captchaId) {
// #ifdef APP-PLUS
function showGeetest4App(captchaId) {
// 清理可能残留的原生 Webview
if (typeof plus !== 'undefined' && plus.webview) {
try {
const old = plus.webview.getWebviewById('geetest-captcha-overlay')
if (old) old.close('none')
} catch (e) {}
}
return new Promise((resolve, reject) => {
uni.navigateTo({
url: `/pages/login/geetest-webview?captchaId=${encodeURIComponent(captchaId)}`,