修复h5记事本不显示问题
This commit is contained in:
+38
-7
@@ -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)}`,
|
||||
|
||||
Reference in New Issue
Block a user