浏览代码

上传非真实的营业执照、经营许可证,OCR识别失败可提交成功

zhuli 1 周之前
父节点
当前提交
4c7e8ed33e
共有 2 个文件被更改,包括 99 次插入15 次删除
  1. 4 0
      src/api/modules/newLoginApi.ts
  2. 95 15
      src/views/home/components/go-flow.vue

+ 4 - 0
src/api/modules/newLoginApi.ts

@@ -65,3 +65,7 @@ export const getCheckSmsCode = params => {
 export const ocrRequestUrl = params => {
   return httpLogin.post<Upload.ResFileUrl>(`/alienStore/ali/ocrRequestUrl`, params);
 };
+//ai入驻审核
+export const getAiapprovestoreInfo = params => {
+  return httpLogin.post<Upload.ResFileUrl>(`/alienStore/store/info/aiApproveStoreInfo`, params);
+};

+ 95 - 15
src/views/home/components/go-flow.vue

@@ -222,7 +222,7 @@
                   list-type="picture-card"
                   :limit="1"
                   :on-exceed="handleExceed"
-                  :on-success="(response, file) => handleUploadSuccess(response, file, 'BUSINESS_LICENSE')"
+                  :on-success="(response, file) => handleUploadSuccess(response, file, 'BUSINESS_LICENSE', '营业执照')"
                   :on-preview="handlePictureCardPreview"
                 >
                   <el-icon><Plus /></el-icon>
@@ -239,7 +239,7 @@
                   list-type="picture-card"
                   :limit="20"
                   :on-exceed="handleExceed"
-                  :on-success="(response, file) => handleUploadSuccess(response, file, '')"
+                  :on-success="(response, file) => handleUploadSuccess(response, file, '', '合同图片')"
                   :on-preview="handlePictureCardPreview"
                 >
                   <el-icon><Plus /></el-icon>
@@ -256,7 +256,7 @@
                   list-type="picture-card"
                   :limit="1"
                   :on-exceed="handleExceed"
-                  :on-success="(response, file) => handleUploadSuccess(response, file, 'FOOD_MANAGE_LICENSE')"
+                  :on-success="(response, file) => handleUploadSuccess(response, file, 'FOOD_MANAGE_LICENSE', '食品经营许可证')"
                   :on-preview="handlePictureCardPreview"
                 >
                   <el-icon><Plus /></el-icon>
@@ -273,7 +273,7 @@
                   list-type="picture-card"
                   :limit="1"
                   :on-exceed="handleExceed"
-                  :on-success="(response, file) => handleUploadSuccess(response, file, 'BUSINESS_LICENSE')"
+                  :on-success="(response, file) => handleUploadSuccess(response, file, 'BUSINESS_LICENSE', '娱乐经营许可证')"
                   :on-preview="handlePictureCardPreview"
                 >
                   <el-icon><Plus /></el-icon>
@@ -324,7 +324,7 @@ import {
   getThirdLevelList,
   verifyIdInfo
 } from "@/api/modules/homeEntry";
-import { getInputPrompt, getDistrict, uploadImg, ocrRequestUrl } from "@/api/modules/newLoginApi";
+import { getInputPrompt, getDistrict, uploadImg, ocrRequestUrl, getAiapprovestoreInfo } from "@/api/modules/newLoginApi";
 import { localGet, localSet } from "@/utils/index";
 import { useAuthStore } from "@/stores/modules/auth";
 
@@ -378,6 +378,11 @@ const entertainmentLicenceExpirationTime = ref<string>("");
 // 是否正在识别中
 const isOcrProcessing = ref(false);
 
+// OCR识别状态:'success' | 'failed' | 'none'(未识别)
+const businessLicenseOcrStatus = ref<"success" | "failed" | "none">("none"); // 营业执照OCR状态
+const foodLicenseOcrStatus = ref<"success" | "failed" | "none">("none"); // 食品经营许可证OCR状态
+const entertainmentLicenseOcrStatus = ref<"success" | "failed" | "none">("none"); // 娱乐经营许可证OCR状态
+
 // 日期格式转换函数:支持两种格式
 // 1. "20220508" -> "2022-05-08"
 // 2. "2024年01月14日" -> "2024-01-14"
@@ -946,7 +951,7 @@ const handleHttpUpload = async (options: UploadRequestOptions) => {
 };
 
 // 自动调用 OCR 识别
-const autoOcrRecognition = async (ocrType: string) => {
+const autoOcrRecognition = async (ocrType: string, name: string) => {
   // 如果正在识别中,不重复调用
   if (isOcrProcessing.value) {
     return;
@@ -984,9 +989,9 @@ const autoOcrRecognition = async (ocrType: string) => {
     // 营业执照或娱乐经营许可证:检查是否已上传
     // 优先检查营业执照,如果没有再检查娱乐经营许可证
     let fileList: UploadUserFile[] = [];
-    if (step2Form.businessLicenseAddress.length > 0) {
+    if (name == "营业执照") {
       fileList = step2Form.businessLicenseAddress;
-    } else if (step2Form.disportLicenceImgList.length > 0) {
+    } else if (name == "娱乐经营许可证") {
       fileList = step2Form.disportLicenceImgList;
     } else {
       return;
@@ -1096,9 +1101,11 @@ const autoOcrRecognition = async (ocrType: string) => {
           }
         }
 
-        if (isBusinessLicense) {
+        if (name == "营业执照") {
+          businessLicenseOcrStatus.value = "success";
           ElMessage.success("营业执照识别成功");
-        } else {
+        } else if (name == "娱乐经营许可证") {
+          entertainmentLicenseOcrStatus.value = "success";
           ElMessage.success("娱乐经营许可证识别成功");
         }
       } else if (ocrType === "FOOD_MANAGE_LICENSE") {
@@ -1111,14 +1118,28 @@ const autoOcrRecognition = async (ocrType: string) => {
             console.log(foodLicenceExpirationTime.value);
           }
         }
+        foodLicenseOcrStatus.value = "success";
         ElMessage.success("食品经营许可证识别成功");
       }
     } else {
       console.warn("OCR 识别失败:", res?.msg);
+      if (name === "营业执照") {
+        businessLicenseOcrStatus.value = "failed";
+      } else if (name === "娱乐经营许可证") {
+        entertainmentLicenseOcrStatus.value = "failed";
+      } else if (ocrType === "FOOD_MANAGE_LICENSE") {
+        foodLicenseOcrStatus.value = "failed";
+      }
       ElMessage.error(res?.msg || "识别失败,请重试");
     }
   } catch (error) {
-    console.error("OCR 识别失败:", error);
+    if (name === "营业执照") {
+      businessLicenseOcrStatus.value = "failed";
+    } else if (name === "娱乐经营许可证") {
+      entertainmentLicenseOcrStatus.value = "failed";
+    } else if (ocrType === "FOOD_MANAGE_LICENSE") {
+      foodLicenseOcrStatus.value = "failed";
+    }
     ElMessage.error("识别失败,请重试");
   } finally {
     isOcrProcessing.value = false;
@@ -1126,16 +1147,23 @@ const autoOcrRecognition = async (ocrType: string) => {
 };
 
 // 文件上传成功回调
-const handleUploadSuccess = (response: any, uploadFile: UploadUserFile, ocrType: string) => {
+const handleUploadSuccess = (response: any, uploadFile: UploadUserFile, ocrType: string, name: string) => {
   if (response?.fileUrl) {
     uploadFile.url = response.fileUrl;
   }
-
   // 只有指定的类型才进行 OCR 识别
   if (ocrType && (ocrType === "ID_CARD" || ocrType === "BUSINESS_LICENSE" || ocrType === "FOOD_MANAGE_LICENSE")) {
+    if (name === "营业执照") {
+      businessLicenseOcrStatus.value = "none";
+    } else if (name === "娱乐经营许可证") {
+      entertainmentLicenseOcrStatus.value = "none";
+    } else if (ocrType === "FOOD_MANAGE_LICENSE") {
+      foodLicenseOcrStatus.value = "none";
+    }
+
     // 延迟一下,确保文件状态已更新,然后检查是否需要自动 OCR
     setTimeout(() => {
-      autoOcrRecognition(ocrType);
+      autoOcrRecognition(ocrType, name);
     }, 100);
   }
 };
@@ -1189,6 +1217,18 @@ const handleRemove = (file: UploadUserFile) => {
   // 文件移除时,清空 OCR 识别结果
   ocrResult.value = {};
   isOcrProcessing.value = false;
+
+  // 根据文件所属列表重置对应的OCR状态
+  if (step2Form.businessLicenseAddress.some((f: UploadUserFile) => f.uid === file.uid)) {
+    // 移除的是营业执照
+    businessLicenseOcrStatus.value = "none";
+  } else if (step2Form.foodLicenceImgList.some((f: UploadUserFile) => f.uid === file.uid)) {
+    // 移除的是食品经营许可证
+    foodLicenseOcrStatus.value = "none";
+  } else if (step2Form.disportLicenceImgList.some((f: UploadUserFile) => f.uid === file.uid)) {
+    // 移除的是娱乐经营许可证
+    entertainmentLicenseOcrStatus.value = "none";
+  }
 };
 
 // 提取文件列表中的URL
@@ -1235,13 +1275,52 @@ const buildWhereAddress = async (regionCodes: string[]) => {
   }
   return whereAddress;
 };
-
+const handleAi = async () => {
+  const businessLicenseUrls = getFileUrls(step2Form.businessLicenseAddress);
+  const contractImageUrls = getFileUrls(step2Form.contractImageList);
+  const foodLicenceUrls = getFileUrls(step2Form.foodLicenceImgList);
+  const disportLicenceUrls = getFileUrls(step2Form.disportLicenceImgList);
+
+  const licenseImages = [...businessLicenseUrls, ...contractImageUrls, ...foodLicenceUrls, ...disportLicenceUrls].filter(Boolean);
+
+  const params: any = {
+    business_scope: step2Form.storeBlurb,
+    contact_email: "",
+    contact_name: userInfo.name,
+    contact_phone: userInfo.phone,
+    license_images: licenseImages,
+    merchant_name: step2Form.storeName,
+    userId: userInfo.id
+  };
+  const res: any = await getAiapprovestoreInfo(params);
+  if (res && res.code == 200) {
+    ElMessage.success("AI智能审核通过");
+  } else {
+    ElMessage.error(res?.msg || "AI智能审核失败");
+  }
+};
 // 提交
 const handleSubmit = async () => {
   if (!step2FormRef.value) return;
 
   await step2FormRef.value.validate(async valid => {
     if (valid) {
+      // 检查OCR识别状态,如果有识别失败的证照,提示用户重新上传
+      const failedLicenses: string[] = [];
+      if (step2Form.businessLicenseAddress.length > 0 && businessLicenseOcrStatus.value === "failed") {
+        failedLicenses.push("营业执照");
+      }
+      if (step2Form.foodLicenceImgList.length > 0 && foodLicenseOcrStatus.value === "failed") {
+        failedLicenses.push("食品经营许可证");
+      }
+      if (step2Form.disportLicenceImgList.length > 0 && entertainmentLicenseOcrStatus.value === "failed") {
+        failedLicenses.push("娱乐经营许可证");
+      }
+
+      if (failedLicenses.length > 0) {
+        ElMessage.warning("请重新上传证照");
+        return;
+      }
       const businessLicenseUrls = getFileUrls(step2Form.businessLicenseAddress);
       const contractImageUrls = getFileUrls(step2Form.contractImageList);
       const foodLicenceUrls = getFileUrls(step2Form.foodLicenceImgList);
@@ -1369,6 +1448,7 @@ const handleSubmit = async () => {
               ElMessage.success(res.msg);
               callGetUserInfo();
               setStep(0);
+              handleAi();
             } else {
               ElMessage.error(res.msg || "提交失败");
             }