congzc 1 year ago
parent
commit
c4660d19d3
2 changed files with 17 additions and 7 deletions
  1. +5
    -1
      src/pages/index/index.vue
  2. +12
    -6
      src/pages/uploadPhoto/uploadPhoto.vue

+ 5
- 1
src/pages/index/index.vue View File

@@ -140,7 +140,11 @@ const pageClass = computed(() => {
//#endregion
//#region 头像
const avatarUrl = ref(null);
function chooseAvatar(params) {
function chooseAvatar() {
uni.navigateTo({
url: "/pages/uploadPhoto/uploadPhoto",
});
return;
uni.chooseImage({
count: 1, // 最多可以选择的图片张数,这里设置为1,只选择一张图片
success: async (res) => {


+ 12
- 6
src/pages/uploadPhoto/uploadPhoto.vue View File

@@ -85,8 +85,8 @@ const userInfoModulesPinia = userInfoModules();
//#region 选择图片
const uploadState = ref(1); //上传状态
const showImgUrl = ref(null); //回显路径
const showImgUrl2 = ref(null); //回显路径
const showImgUrl = ref(null); //回显路径 压缩
const showImgUrl2 = ref(null); //回显路径 未压缩
const showImgData = ref(null); //上传数据
function chooseImage() {
// 调用uni.chooseImage方法选择图片
@@ -100,7 +100,7 @@ function chooseImage() {
if (userInfoModulesPinia.platForm != 1) {
uni.compressImage({
src: res.tempFilePaths[0],
quality: 80,
quality: 40,
success: (res2) => {
showImgUrl.value = res2.tempFilePath;
},
@@ -140,10 +140,12 @@ 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
filePath: showImgUrl.value,
filePath: showImgUrl2.value.path,
name: "file",
formData: {
user: "test",
@@ -161,7 +163,7 @@ async function toCloseStyle() {
// 上传接口
uni.uploadFile({
url: "https://test.metavatar.cc/C/api/upload/awsImgUpload", //上传图片api
filePath: showImgUrl.value,
filePath: showImgUrl2.value.path,
name: "file",
formData: {
user: "test",
@@ -202,7 +204,11 @@ async function toCloseStyle() {
});
},
fail: () => {
uploadState.value = 4;
uploadState.value = 1;
uni.showToast({
title: "网络被数字人偷走了, 请稍后重试",
icon: "none",
});
},
});
}


Loading…
Cancel
Save