yangg 2 bulan lalu
induk
melakukan
6b61d138c6

+ 1 - 1
common/config.js

@@ -1,7 +1,7 @@
 // API base URL configuration
 //线上 https://minlong.raycos.com.cn
 //测试 http://192.168.66.187:8083
-export const apiBaseUrl = 'https://minlong.raycos.com.cn';
+export const apiBaseUrl = 'http://192.168.66.187:8083';
 
 // You can add other global configuration settings here
 export const appVersion = '1.0.0';

+ 71 - 43
pages/face-photo/face-photo.vue

@@ -211,16 +211,11 @@ export default {
         title: '上传中...'
       });
       
-      // 上传当前照片
-      this.uploadMedia((url) => {
-        // 保存照片URL
-        this.photoUrl = url;
-        // 直接提交照片URL到指定接口
-        this.submitPhotoUrl();
-      });
+      // 直接上传照片
+      this.submitPhotoUrl();
     },
     
-    // 上传媒体文件方法
+    // 上传媒体文件方法 - 不再使用
     uploadMedia(callback) {
       // 获取openid和tenant_id,可以从缓存或全局状态获取
       const openid = JSON.parse(uni.getStorageSync('userInfo')).openid || '';
@@ -272,12 +267,12 @@ export default {
       });
     },
     
-    // 提交照片URL到指定接口
+    // 提交照片URL到指定接口 - 修改为直接上传文件
     submitPhotoUrl() {
       const openid = JSON.parse(uni.getStorageSync('userInfo')).openid || '';
       const tenant_id = 1 || '';
       
-      if (!this.photoUrl) {
+      if (!this.mediaSource) {
         uni.hideLoading();
         uni.showToast({
           title: '照片信息不完整,请重试',
@@ -286,41 +281,74 @@ export default {
         return;
       }
       
-      // 使用fillUserInfo方法进行上传
-      fillUserInfo({
-        application_id: uni.getStorageSync('appId'),
-        openid: openid,
-        tenant_id: tenant_id,
-        avatar: this.photoUrl,
-      }).then(res => {
-        uni.hideLoading();
-        console.log(res);
-        // this.updateLocalUserInfo();
-       
+      // 使用uni.uploadFile直接上传文件,类似interview页面的实现
+      uni.uploadFile({
+        url: `${apiBaseUrl}/job/upload_posture_photo`,
+        filePath: this.mediaSource,
+        name: 'photo_file',  // 确保文件参数名称正确
+        formData: {  // 使用formData传递参数
+          'application_id': uni.getStorageSync('appId'),
+          'tenant_id': tenant_id,
+          'openid': openid,
+          'description': '面部照片'
+        },
+        success: (uploadRes) => {
+          console.log('照片上传成功:', uploadRes);
+          
+          // 解析返回的JSON字符串
+          let result;
+          try {
+            if (typeof uploadRes.data === 'string') {
+              result = JSON.parse(uploadRes.data);
+            } else {
+              result = uploadRes.data;
+            }
+            console.log('解析后的上传结果:', result);
+            
+            // 保存返回的URL
+            if (result.data && result.data.url) {
+              this.photoUrl = result.data.url;
+            }
+            
+            // 更新本地用户信息
+            // this.updateLocalUserInfo();
+            
+            uni.showToast({
+              title: '照片上传成功',
+              icon: 'success'
+            });
+            
+            // 上传成功后跳转到下一页
+            setTimeout(() => {
+              uni.navigateTo({
+                url: '/pages/identity-verify/identity-verify',
+                fail: (err) => {
+                  console.error('页面跳转失败:', err);
+                  uni.showToast({
+                    title: '页面跳转失败',
+                    icon: 'none'
+                  });
+                }
+              });
+            }, 1500);
+          } catch (e) {
+            console.error('解析上传结果失败:', e);
+            uni.showToast({
+              title: '处理响应失败',
+              icon: 'none'
+            });
+          }
+        },
+        fail: (err) => {
+          console.error('照片上传失败:', err);
           uni.showToast({
-            title: '照片上传成功',
-            icon: 'success'
+            title: '照片上传失败,请重试',
+            icon: 'none'
           });
-          // 上传成功后跳转到下一页
-          setTimeout(() => {
-            uni.navigateTo({
-              url: '/pages/identity-verify/identity-verify',
-              fail: (err) => {
-                console.error('页面跳转失败:', err);
-                uni.showToast({
-                  title: '页面跳转失败',
-                  icon: 'none'
-                });
-              }
-            });
-          }, 1500);
-      }).catch(err => {
-        uni.hideLoading();
-        console.error('提交失败:', err);
-        uni.showToast({
-          title: '网络错误,请重试',
-          icon: 'none'
-        });
+        },
+        complete: () => {
+          uni.hideLoading();
+        }
       });
     },
     updateLocalUserInfo() {

+ 1 - 1
unpackage/dist/dev/mp-weixin/common/config.js

@@ -1,3 +1,3 @@
 "use strict";
-const apiBaseUrl = "https://minlong.raycos.com.cn";
+const apiBaseUrl = "http://192.168.66.187:8083";
 exports.apiBaseUrl = apiBaseUrl;

+ 61 - 36
unpackage/dist/dev/mp-weixin/pages/face-photo/face-photo.js

@@ -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() {

+ 1 - 1
unpackage/dist/dev/mp-weixin/project.config.json

@@ -8,7 +8,7 @@
     "urlCheck": false,
     "es6": true,
     "postcss": false,
-    "minified": true,
+    "minified": false,
     "newFeature": true,
     "bigPackageSizeSupport": true,
     "babelSetting": {