findme-miniprogram-frontend/subpackages/realname/faceid-webview.js
2025-12-27 17:16:03 +08:00

42 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Page({
data:{ url: '' },
onLoad(options){
if(options && options.url){
try{
const decoded = decodeURIComponent(options.url);
this.setData({ url: decoded });
}catch(e){
this.setData({ url: options.url });
}
}
else{
// 如果没有URL直接跳转到验证成功页面
wx.redirectTo({
url: '/subpackages/realname/verify-success'
});
}
},
// 监听网页传来的消息
onWebViewMessage(e){
console.log('收到网页消息:', e.detail.data);
const data = e.detail.data || {};
// 检查是否是认证成功消息
// 根据腾讯云 FaceID 的实际回调格式调整判断条件
if(data.type === 'verify_success' || data.success === true || data.status === 'success' || data.verifySuccess){
// 跳转到验证成功页面
setTimeout(() => {
wx.redirectTo({
url: '/subpackages/realname/verify-success'
});
}, 500); // 延迟500ms确保网页消息处理完成
}
},
// 页面显示时检查认证状态
onShow(){
// 如果认证已完成,可以直接跳转
// 注意:实际逻辑可能需要根据腾讯云 FaceID 的回调方式调整
}
});