| @@ -198,9 +198,9 @@ async function toCloseStyle() { | |||||
| uploadState.value = 3; | uploadState.value = 3; | ||||
| console.log(showImgUrl.value); | console.log(showImgUrl.value); | ||||
| console.log(showImgUrl2.value.path); | console.log(showImgUrl2.value.path); | ||||
| // 人脸识别接口 | |||||
| // 百度敏感信息检测 | |||||
| uni.uploadFile({ | 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, | filePath: showImgUrl2.value.path, | ||||
| name: "file", | name: "file", | ||||
| formData: { | formData: { | ||||
| @@ -210,66 +210,99 @@ async function toCloseStyle() { | |||||
| // Authorization: userInfoModulesPinia.token, | // Authorization: userInfoModulesPinia.token, | ||||
| token: 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(); | uni.hideLoading(); | ||||
| uploadState.value = 4; | uploadState.value = 4; | ||||
| return; | return; | ||||
| } | } | ||||
| // 上传接口 | |||||
| // 人脸识别接口 | |||||
| uni.uploadFile({ | 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, | filePath: showImgUrl2.value.path, | ||||
| name: "file", | name: "file", | ||||
| formData: { | formData: { | ||||
| user: "test", | user: "test", | ||||
| }, | }, | ||||
| header: { | header: { | ||||
| "Content-Type": "multipart/form-data", | |||||
| // Authorization: userInfoModulesPinia.token, | |||||
| token: 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(); | uni.hideLoading(); | ||||
| uploadState.value = 5; | |||||
| uni.showToast({ | |||||
| title: "网络被数字人偷走了, 请稍后重试", | |||||
| icon: "none", | |||||
| }); | |||||
| uploadState.value = 4; | |||||
| return; | 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: () => { | fail: () => { | ||||
| uploadState.value = 5; | |||||
| uploadState.value = 1; | |||||
| uni.hideLoading(); | uni.hideLoading(); | ||||
| uni.showToast({ | uni.showToast({ | ||||
| title: "网络被数字人偷走了, 请稍后重试", | title: "网络被数字人偷走了, 请稍后重试", | ||||
| icon: "none", | icon: "none", | ||||
| }); | }); | ||||
| }, | }, | ||||
| // complete: (complete) => { | |||||
| // uni.hideLoading(); | |||||
| // }, | |||||
| }); | }); | ||||
| }, | }, | ||||
| fail: () => { | fail: () => { | ||||
| @@ -280,9 +313,6 @@ async function toCloseStyle() { | |||||
| icon: "none", | icon: "none", | ||||
| }); | }); | ||||
| }, | }, | ||||
| // complete: (complete) => { | |||||
| // uni.hideLoading(); | |||||
| // }, | |||||
| }); | }); | ||||
| } | } | ||||
| } | } | ||||