Browse Source

百度识别

master
congzc 1 year ago
parent
commit
572858338e
1 changed files with 69 additions and 39 deletions
  1. +69
    -39
      src/pages/uploadPhoto/uploadPhoto.vue

+ 69
- 39
src/pages/uploadPhoto/uploadPhoto.vue View File

@@ -198,9 +198,9 @@ async function toCloseStyle() {
uploadState.value = 3;
console.log(showImgUrl.value);
console.log(showImgUrl2.value.path);
// 人脸识别接口
// 百度敏感信息检测
uni.uploadFile({
url: "https://test.metavatar.cc/C/api/userDigital/checkPhoto", //上传图片api
url: "https://test.metavatar.cc/C/api/baidu/checkPhoto", //上传图片api
filePath: showImgUrl2.value.path,
name: "file",
formData: {
@@ -210,66 +210,99 @@ async function toCloseStyle() {
// Authorization: userInfoModulesPinia.token,
token: userInfoModulesPinia.token,
},
success: (res) => {
if (JSON.parse(res.data).code != 200) {
success: (res0) => {
if (JSON.parse(res0.data).code != 200) {
uni.hideLoading();
uploadState.value = 4;
return;
}
// 上传接口
// 人脸识别接口
uni.uploadFile({
url: "https://test.metavatar.cc/C/api/upload/awsImgUpload", //上传图片api
url: "https://test.metavatar.cc/C/api/userDigital/checkPhoto", //上传图片api
filePath: showImgUrl2.value.path,
name: "file",
formData: {
user: "test",
},
header: {
"Content-Type": "multipart/form-data",
// Authorization: userInfoModulesPinia.token,
token: userInfoModulesPinia.token,
},
success: async (res2) => {
let moment = res2;
if (JSON.parse(res2.data).code != 200) {
success: (res) => {
if (JSON.parse(res.data).code != 200) {
uni.hideLoading();
uploadState.value = 5;
uni.showToast({
title: "网络被数字人偷走了, 请稍后重试",
icon: "none",
});
uploadState.value = 4;
return;
}
// 保存接口
// 上传接口
uni.uploadFile({
url: "https://test.metavatar.cc/C/api/upload/awsImgUpload", //上传图片api
filePath: showImgUrl2.value.path,
name: "file",
formData: {
user: "test",
},
header: {
"Content-Type": "multipart/form-data",
token: userInfoModulesPinia.token,
},
success: async (res2) => {
let moment = res2;
if (JSON.parse(res2.data).code != 200) {
uni.hideLoading();
uploadState.value = 5;
uni.showToast({
title: "网络被数字人偷走了, 请稍后重试",
icon: "none",
});
return;
}
// 保存接口
const res3 = await addImageApi({
image: JSON.parse(res2.data).data.url,
});
const res3 = await addImageApi({
image: JSON.parse(res2.data).data.url,
});
if (res3.code == 200) {
// 改变全局的头像
userInfoModulesPinia.myAvatar = JSON.parse(moment.data).data.url;
uploadState.value = 1;
uni.hideLoading();
showImgUrl.value = null;
uni.navigateTo({
url: "/pages/uploadPhoto/success",
});
} else {
uni.hideLoading();
uni.showToast({
title: "网络被数字人偷走了, 请稍后重试",
icon: "none",
});
}
if (res3.code == 200) {
// 改变全局的头像
userInfoModulesPinia.myAvatar = JSON.parse(
moment.data
).data.url;
uploadState.value = 1;
uni.hideLoading();
showImgUrl.value = null;
uni.navigateTo({
url: "/pages/uploadPhoto/success",
});
} else {
uni.hideLoading();
uni.showToast({
title: "网络被数字人偷走了, 请稍后重试",
icon: "none",
});
}
},
fail: () => {
uploadState.value = 5;
uni.hideLoading();
uni.showToast({
title: "网络被数字人偷走了, 请稍后重试",
icon: "none",
});
},
});
},
fail: () => {
uploadState.value = 5;
uploadState.value = 1;
uni.hideLoading();
uni.showToast({
title: "网络被数字人偷走了, 请稍后重试",
icon: "none",
});
},
// complete: (complete) => {
// uni.hideLoading();
// },
});
},
fail: () => {
@@ -280,9 +313,6 @@ async function toCloseStyle() {
icon: "none",
});
},
// complete: (complete) => {
// uni.hideLoading();
// },
});
}
}


Loading…
Cancel
Save