|
@@ -153,12 +153,9 @@ const _sfc_main = {
|
|
|
common_vendor.index.showLoading({
|
|
|
title: "上传中..."
|
|
|
});
|
|
|
- this.uploadMedia((url) => {
|
|
|
- this.photoUrl = url;
|
|
|
- this.submitPhotoUrl();
|
|
|
- });
|
|
|
+ this.submitPhotoUrl();
|
|
|
},
|
|
|
- // 上传媒体文件方法
|
|
|
+ // 上传媒体文件方法 - 不再使用
|
|
|
uploadMedia(callback) {
|
|
|
const openid = JSON.parse(common_vendor.index.getStorageSync("userInfo")).openid || "";
|
|
|
const tenant_id = 1;
|
|
@@ -203,11 +200,11 @@ const _sfc_main = {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- // 提交照片URL到指定接口
|
|
|
+ // 提交照片URL到指定接口 - 修改为直接上传文件
|
|
|
submitPhotoUrl() {
|
|
|
const openid = JSON.parse(common_vendor.index.getStorageSync("userInfo")).openid || "";
|
|
|
const tenant_id = 1;
|
|
|
- if (!this.photoUrl) {
|
|
|
+ if (!this.mediaSource) {
|
|
|
common_vendor.index.hideLoading();
|
|
|
common_vendor.index.showToast({
|
|
|
title: "照片信息不完整,请重试",
|
|
@@ -215,37 +212,65 @@ const _sfc_main = {
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
- api_user.fillUserInfo({
|
|
|
- application_id: common_vendor.index.getStorageSync("appId"),
|
|
|
- openid,
|
|
|
- tenant_id,
|
|
|
- avatar: this.photoUrl
|
|
|
- }).then((res) => {
|
|
|
- common_vendor.index.hideLoading();
|
|
|
- console.log(res);
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "照片上传成功",
|
|
|
- icon: "success"
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
- common_vendor.index.navigateTo({
|
|
|
- url: "/pages/identity-verify/identity-verify",
|
|
|
- fail: (err) => {
|
|
|
- console.error("页面跳转失败:", err);
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "页面跳转失败",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
+ common_vendor.index.uploadFile({
|
|
|
+ url: `${common_config.apiBaseUrl}/job/upload_posture_photo`,
|
|
|
+ filePath: this.mediaSource,
|
|
|
+ name: "photo_file",
|
|
|
+ // 确保文件参数名称正确
|
|
|
+ formData: {
|
|
|
+ // 使用formData传递参数
|
|
|
+ "application_id": common_vendor.index.getStorageSync("appId"),
|
|
|
+ "tenant_id": tenant_id,
|
|
|
+ "openid": openid,
|
|
|
+ "description": "面部照片"
|
|
|
+ },
|
|
|
+ success: (uploadRes) => {
|
|
|
+ console.log("照片上传成功:", uploadRes);
|
|
|
+ let result;
|
|
|
+ try {
|
|
|
+ if (typeof uploadRes.data === "string") {
|
|
|
+ result = JSON.parse(uploadRes.data);
|
|
|
+ } else {
|
|
|
+ result = uploadRes.data;
|
|
|
+ }
|
|
|
+ console.log("解析后的上传结果:", result);
|
|
|
+ if (result.data && result.data.url) {
|
|
|
+ this.photoUrl = result.data.url;
|
|
|
}
|
|
|
+ common_vendor.index.showToast({
|
|
|
+ title: "照片上传成功",
|
|
|
+ icon: "success"
|
|
|
+ });
|
|
|
+ setTimeout(() => {
|
|
|
+ common_vendor.index.navigateTo({
|
|
|
+ url: "/pages/identity-verify/identity-verify",
|
|
|
+ fail: (err) => {
|
|
|
+ console.error("页面跳转失败:", err);
|
|
|
+ common_vendor.index.showToast({
|
|
|
+ title: "页面跳转失败",
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }, 1500);
|
|
|
+ } catch (e) {
|
|
|
+ console.error("解析上传结果失败:", e);
|
|
|
+ common_vendor.index.showToast({
|
|
|
+ title: "处理响应失败",
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ console.error("照片上传失败:", err);
|
|
|
+ common_vendor.index.showToast({
|
|
|
+ title: "照片上传失败,请重试",
|
|
|
+ icon: "none"
|
|
|
});
|
|
|
- }, 1500);
|
|
|
- }).catch((err) => {
|
|
|
- common_vendor.index.hideLoading();
|
|
|
- console.error("提交失败:", err);
|
|
|
- common_vendor.index.showToast({
|
|
|
- title: "网络错误,请重试",
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ common_vendor.index.hideLoading();
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
updateLocalUserInfo() {
|