dujian 2 дней назад
Родитель
Сommit
59a5a987e0
4 измененных файлов с 23 добавлено и 19 удалено
  1. 2 5
      src/api/modules/aiImageUpload.ts
  2. 4 8
      src/api/upload.js
  3. 3 0
      src/utils/config.ts
  4. 14 6
      src/views/home/components/go-flow.vue

+ 2 - 5
src/api/modules/aiImageUpload.ts

@@ -2,7 +2,7 @@
  * Web 端:Tus 分片上传(与 Apifox / uni 版协议对齐);独立审核走上传服务 /upload/simple 等,不再调用 verify 审核域
  */
 import { useUserStore } from "@/stores/modules/user";
-import { AI_UPLOAD_FILES_PUBLIC_BASE, BASE_AI_URL, SIMPLE_UPLOAD_REQUEST_BASE } from "@/utils/config";
+import { AI_UPLOAD_FILES_PUBLIC_BASE, BASE_AI_URL, SIMPLE_UPLOAD_URL } from "@/utils/config";
 import { withSimpleUploadOverlay } from "@/utils/withSimpleUploadOverlay";
 
 const TUS_VERSION = "1.0.0";
@@ -117,11 +117,8 @@ function normalizeSimpleUploadUrls(body: unknown, fileUrl: string): { fileUrl: s
   return { fileUrl: url, coverUrl: coverUrl || undefined };
 }
 
-const DEV_SIMPLE_UPLOAD_PATH = "/upload/simple";
-
 function buildDevSimpleUploadRequestUrl(): string {
-  const base = String(SIMPLE_UPLOAD_REQUEST_BASE || "").replace(/\/$/, "");
-  return `${base}${DEV_SIMPLE_UPLOAD_PATH}`;
+  return String(SIMPLE_UPLOAD_URL || "").trim();
 }
 
 /**

+ 4 - 8
src/api/upload.js

@@ -1,12 +1,9 @@
 import { useUserStore } from "@/stores/modules/user";
 import { useSimpleUploadOverlayStore } from "@/stores/modules/simpleUploadOverlay";
 import { ElMessage } from "element-plus";
-import { AI_UPLOAD_FILES_PUBLIC_BASE, SIMPLE_UPLOAD_REQUEST_BASE } from "@/utils/config";
+import { AI_UPLOAD_FILES_PUBLIC_BASE, SIMPLE_UPLOAD_URL } from "@/utils/config";
 import { withSimpleUploadOverlay } from "@/utils/withSimpleUploadOverlay";
 
-/** 简单上传的路径(不含 base) */
-const SIMPLE_UPLOAD_PATH = "/upload/simple";
-
 /**
  * 已由 uploadFilesToOss 弹出过 ElMessage,调用方勿重复 error
  * @param {unknown} err
@@ -389,9 +386,9 @@ function assertSimpleUploadBusinessOk(parsed) {
  * @returns {Promise<{ url: string; downloadUrl: string; parsed: unknown }>}
  */
 async function postFileToSimpleUploadDetailed(file, fetchOptions = {}) {
-  const base = String(SIMPLE_UPLOAD_REQUEST_BASE || "").replace(/\/$/, "");
-  if (!base) {
-    throw new Error("简单上传服务址未配置");
+  const uploadUrl = String(SIMPLE_UPLOAD_URL || "").trim();
+  if (!uploadUrl) {
+    throw new Error("简单上传服务址未配置");
   }
 
   const formData = new FormData();
@@ -406,7 +403,6 @@ async function postFileToSimpleUploadDetailed(file, fetchOptions = {}) {
 
   const { signal } = fetchOptions;
 
-  const uploadUrl = `${base}${SIMPLE_UPLOAD_PATH}`;
   let res;
   try {
     res = await fetch(uploadUrl, {

+ 3 - 0
src/utils/config.ts

@@ -13,6 +13,9 @@ export const BASE_AI_URL = trimSlash(String(import.meta.env.VITE_AI_UPLOAD_BASE
  */
 export const SIMPLE_UPLOAD_REQUEST_BASE = trimSlash("https://uat.ailien.shop");
 
+/** 全站 multipart 简单上传完整 URL(商家入驻证件、价目表等统一使用) */
+export const SIMPLE_UPLOAD_URL = `${SIMPLE_UPLOAD_REQUEST_BASE}/upload/simple`;
+
 /** 上传完成后对外可访问的文件 URL:`${AI_UPLOAD_FILES_PUBLIC_BASE}/${uploadId}` */
 export const AI_UPLOAD_FILES_PUBLIC_BASE = trimSlash(
   String(import.meta.env.VITE_AI_FILES_PUBLIC_BASE || "").trim() || "https://uat.ailien.shop/files"

+ 14 - 6
src/views/home/components/go-flow.vue

@@ -27,6 +27,7 @@
             <div class="upload-label">正面</div>
             <el-upload
               v-model:file-list="idCardFrontList"
+              action="#"
               :http-request="handleHttpUpload"
               list-type="picture-card"
               :limit="1"
@@ -52,6 +53,7 @@
             <div class="upload-label">反面</div>
             <el-upload
               v-model:file-list="idCardBackList"
+              action="#"
               :http-request="handleHttpUpload"
               list-type="picture-card"
               :limit="1"
@@ -234,6 +236,7 @@
               <el-form-item label="营业执照" prop="businessLicenseAddress">
                 <el-upload
                   v-model:file-list="step2Form.businessLicenseAddress"
+                  action="#"
                   :http-request="handleHttpUpload"
                   list-type="picture-card"
                   :limit="1"
@@ -251,6 +254,7 @@
               <el-form-item label="其他资质证明" prop="disportLicenceImgList">
                 <el-upload
                   v-model:file-list="step2Form.disportLicenceImgList"
+                  action="#"
                   :http-request="handleHttpUpload"
                   :limit="20"
                   list-type="picture-card"
@@ -338,7 +342,8 @@ import { ElMessage, ElMessageBox, type FormInstance, type FormRules, UploadUserF
 import { Plus, ArrowRightBold, Check } from "@element-plus/icons-vue";
 
 import { applyStore, getMerchantByPhone, getThirdLevelList, verifyIdInfo } from "@/api/modules/homeEntry";
-import { getInputPrompt, getDistrict, uploadImg, ocrRequestUrl, getAiapprovestoreInfo } from "@/api/modules/newLoginApi";
+import { getInputPrompt, getDistrict, ocrRequestUrl, getAiapprovestoreInfo } from "@/api/modules/newLoginApi";
+import { uploadFileToOss } from "@/api/upload.js";
 import GoBusinessHours from "./go-businessHours.vue";
 import { localGet, localSet } from "@/utils/index";
 import { useAuthStore } from "@/stores/modules/auth";
@@ -881,13 +886,16 @@ const selectAddress = async () => {
   latShow.value = true;
 };
 
-//文件上传
+/** 商家入驻证件/资质上传:固定 POST https://uat.ailien.shop/upload/simple */
 const handleHttpUpload = async (options: UploadRequestOptions) => {
-  let formData = new FormData();
-  formData.append("file", options.file);
+  const raw = options.file;
+  const file = raw instanceof File ? raw : (raw as UploadUserFile)?.raw;
+  if (!(file instanceof File)) {
+    options.onError(new Error("无效的上传文件") as any);
+    return;
+  }
   try {
-    const res: any = await uploadImg(formData);
-    const fileUrl = res?.data?.fileUrl || res?.data?.[0] || res?.fileUrl;
+    const fileUrl = await uploadFileToOss(file, "image", { skipSimpleUploadOverlay: true });
     if (fileUrl) {
       options.onSuccess({ fileUrl });
     } else {