import request from "@/utils/request"; const AK = "OAnbVZhEuY5UNB9WbDeqstbj"; const SK = "1mMtAGw9ZgoblmNpTrk0SQFikFHFVsbh"; /** * 使用 AK,SK 生成鉴权签名(Access Token) * @return string 鉴权签名信息(Access Token) */ const getAccessToken = () => { let options = { method: 'POST', url: `/bdapi/oauth/2.0/token?client_id=${AK}&client_secret=${SK}&grant_type=client_credentials`, // url: `/bdapi/oauth/2.0/token`, headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, // data: { // grant_type: 'client_credentials', // client_id: AK, // client_secret: SK // }, } return new Promise((resolve, reject) => { request(options) .then(res => { resolve(res.access_token) }) .catch(error => { reject(error) }) }) } // 百度人脸识别(获取verify_token) export const getBaiduFace = async (data = {}) => { return request({ url: `/bdapi/rpc/2.0/brain/solution/faceprint/verifyToken/generate?access_token=${await getAccessToken()}`, method: "post", headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, data: JSON.stringify(data), }); } // 获取认证人脸结果 export const getBaiduFaceDetail = async (data = {}) => { return request({ url: '/bdapi/rpc/2.0/brain/solution/faceprint/result/detail?access_token=' + await getAccessToken(), method: "post", headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, data: JSON.stringify(data), }); } // 获取活体采集人脸图片 export const getBaiduResultSimple = async (data = {}) => { return request({ url: '/bdapi/rpc/2.0/brain/solution/faceprint/result/simple?access_token=' + await getAccessToken(), method: "post", headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, data, }); } // 获取身份证OCR识别 export const getBaiduIdcard = async (data = {}) => { return request({ url: '/bdapi/rest/2.0/ocr/v1/idcard?access_token=' + await getAccessToken(), method: "post", headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json' }, data, }); } // 翔云电子票务识别 export const getNetocr = async (data = {}) => { return request({ url: 'https://netocr.com/api/v2/recogInvoive.do', method: "post", headers: { 'Content-Type': 'multipart/form-data' }, data, }); } // 考培上传非税发票数据u export const savePayment = async (data = {}) => { return request({ url: '/obpm/magic-api/tax/payment', method: "post", data, }); } // 文件上传到V5 export const uploadFileToV5Api = async (data = {}) => { return request({ url: `/v5api/v3/shared/common/resources`, method: "post", // headers: { // Authorization: "Bearer " + "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VySW5mbyI6IntcImVtcGxveWVlSWRcIjpcIkxoNGV1TUM5XCIsXCJpbmR1c3RyeUNvZGVcIjpcIjAxXCIsXCJvcmdhbml6YXRpb25MZXZlbHNcIjpbMV0sXCJhcmVhQ29kZVwiOlwiMTEwMDAwXCIsXCJpZFwiOlwiYVN1WENFZnpcIixcImluc3RpdHV0aW9uYWxDb2RlXCI6XCIwMTAyXCJ9IiwiaXNzIjoiYXV0aDAiLCJleHAiOjE3NDE2MTExNTN9.zHnDxhoaUKyndjWRn1r4tkiq09h6_u9mmfUCWY0nzX4", // }, data, }); } // base64位图片上传 export const uploadBase64ImgToV5Api = async (data = {}) => { return request({ url: `/v5api/v3/shared/common/resources/base64`, method: "post", data, }); } // 身份核验 export const confirmCheckStatus = async (data = {}, headers) => { return request({ url: `/v5api/v3/wechat/cgi-bin/confirm-check-status`, method: "post", data, headers, }); } //人脸比对 export function matchFaceApi(params, baseUrl) { return request(`${baseUrl}/identify/api/baidu/match-face`, { method: "post", headers: { "Content-Type": "application/x-www-form-urlencoded", }, data: { bizFaceMode: "UNIAPP", vtp: 70, appointChannel: "UNIAPP", ...params, }, }); } // 获取华为云token export const gethwtoken = async () => { return request({ url: '/hwapi/v3/auth/tokens', method: "post", headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, data: { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "bcxin_yw", "password": "Bcxin#202103#5186", "domain": { "name": "bcxin_yw" } } } }, "scope": { "project": { "name": "cn-north-4" } } } }, }); } // 华为静默活体检测 export const hwLiveDetectFace = async (data ,header) => { return request({ url: '/hwfaceapi/v2/967cb11fa5304894816463bde95c8a78/face-detect', method: "post", headers: { ...header }, data, }); } // // base64位图片上传 // export function uploadBase64ImgToV5Api(file) { // return new Promise((resolve, rej) => { // teemRequest(`/v3/shared/common/resources/base64`, { // method: "post", // data: { // bStream: file, // }, // }).then((res) => { // console.log(res); // if (res.status == 200) { // if (res.data) { // // let fullFile = filePathConfig.contextPathV3 + res.data; // console.log("base64", res.data); // var fullFile, file; // if (res.data.indexOf("/uploads") > -1) { // if (!isDev) { // fullFile = res.data.replace( // "/uploads", // "https://02obs.baibaodun.cn" // ); // file = res.data.replace( // "/uploads", // "https://02obs.baibaodun.cn" // ); // } else { // fullFile = filePathConfig.contextPathV3 + res.data; // file = res.data; // } // } // resolve({ // // file: res.data, //相对文件地址 // file: file, // fullFile, //完整文件地址 // }); // } else { // //获取不到res.data生成图片返回的路径 // uni.hideLoading(); // uni.showToast({ // title: "网络异常,请重试", // duration: 2000, // icon: "none", // }); // } // } else { // console.log(res); // uni.hideLoading(); // uni.showToast({ // title: "网络异常,请重试", // duration: 2000, // icon: "none", // }); // } // }); // }); // } // 文件上传到V5 // export function uploadFileToV5Api(file) { // let url = // teemLinkBaseUrl + v5ObpmConfig.contextPathV3 + "/shared/common/resources"; // return new Promise((resolve, rej) => { // uni.uploadFile({ // url, // filePath: file, // name: "file", // header: { // Authorization: "Bearer " + uni.getStorageSync("token"), // }, // success: (res) => { // if (res.statusCode == 200) { // let data = res.data && JSON.parse(res.data); // if(data.status == 200){ // let fullFile = filePathConfig.contextPathV3 + data.data; // resolve({ // file: data.data, //相对文件地址 // fullFile, //完整文件地址 // }); // } else { // uni.hideLoading(); // uni.showToast({ // title: "网络异常,请重试", // duration: 2000, // icon: "none", // }); // } // } else { // uni.hideLoading(); // uni.showToast({ // title: "网络异常,请重试", // duration: 2000, // icon: "none", // }); // } // }, // fail: (err) => { // console.log(err); // uni.hideLoading(); // uni.showToast({ // title: "网络异常,请重试", // duration: 2000, // icon: "none", // }); // rej(err); // }, // }); // }); // }