29 lines
979 B
JavaScript
29 lines
979 B
JavaScript
|
/**
|
|||
|
* 前往人脸核验
|
|||
|
*/
|
|||
|
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;
|
|||
|
});
|
|||
|
}
|