YingXingAI/utils/faceVerify.js

29 lines
979 B
JavaScript
Raw Permalink 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.

/**
* 前往人脸核验
*/
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;
});
}