YingXingAI/utils/faceVerify.js

29 lines
979 B
JavaScript
Raw Permalink Normal View History

2025-06-30 14:43:02 +08:00
/**
* 前往人脸核验
*/
export function toBaiduApi(vm) {
vm.$u.api.getAPIToken().then((res) => {
const token = res.result.verify_token;
// 获取当前域名
const currentDomain = window.location.origin;
// 编码回调URL - 使用相对路径让uni-app处理路由
// 百度人脸核验会在回调URL后附加verify_result和verify_info参数
const successUrl = encodeURIComponent(
`${currentDomain}/#/pages/login/recognitionResult/recognitionResult?token=${token}`
);
const failedUrl = encodeURIComponent(
`${currentDomain}/#/pages/login/recognitionResult/recognitionFailed?token=${token}`
);
// 构建跳转URL
const verifyUrl = `https://brain.baidu.com/face/print/verify/verify?token=${token}&successUrl=${successUrl}&failedUrl=${failedUrl}`;
console.log("跳转到百度人脸核验页面:", verifyUrl);
// 直接跳转到百度人脸核验页面
window.location.href = verifyUrl;
});
}