Browse Source

门店头图功能增加

lxr 2 tháng trước cách đây
mục cha
commit
e55c7b60fb

+ 3 - 0
src/config/index.ts

@@ -3,6 +3,9 @@
 // 首页地址(默认)
 export const HOME_URL: string = "/home/index";
 
+// 门店头图上传页地址(未上传头图时弹框引导跳转)
+export const STORE_HEAD_IMAGE_PATH: string = "/storeDecoration/storeHeadMap";
+
 // 登录页地址(默认)
 export const LOGIN_URL: string = "/login";
 

+ 7 - 1
src/layouts/components/Menu/SubMenu.vue

@@ -23,7 +23,7 @@
 <script setup lang="ts">
 import { useRouter } from "vue-router";
 import { ElMessage } from "element-plus";
-import { checkMenuClickPermission } from "@/utils/permission";
+import { checkMenuClickPermission, checkHeadImageBeforeNavigate } from "@/utils/permission";
 
 defineProps<{ menuList: Menu.MenuOptions[] }>();
 
@@ -44,6 +44,12 @@ const handleClickMenu = async (subItem: Menu.MenuOptions) => {
     return;
   }
 
+  // 除首页外,未上传头图时弹框引导去上传头图页(参考商家端)
+  const canProceed = await checkHeadImageBeforeNavigate(subItem.path);
+  if (!canProceed) {
+    return;
+  }
+
   // 允许访问,执行路由跳转
   try {
     await router.push(subItem.path);

+ 38 - 1
src/utils/permission.ts

@@ -1,5 +1,7 @@
 import { localGet, localSet } from "@/utils/index";
-import { ElMessage } from "element-plus";
+import { ElMessage, ElMessageBox } from "element-plus";
+import router from "@/routers";
+import { HOME_URL, STORE_HEAD_IMAGE_PATH } from "@/config";
 import { getUserByPhone, getDetail, checkMenuPermissions } from "@/api/modules/homeEntry";
 
 /**
@@ -206,3 +208,38 @@ export async function checkMenuClickPermission(path?: string): Promise<{
     entertainmentBusinessLicense
   };
 }
+
+/**
+ * @description 除首页外,点击其他菜单时检查是否已上传头图;未上传则弹框引导去上传头图页(参考商家端)
+ * @param path 菜单路径
+ * @returns {Promise<boolean>} true 表示可继续跳转,false 表示已拦截(弹框中选择去上传或暂不上传)
+ */
+export async function checkHeadImageBeforeNavigate(path: string): Promise<boolean> {
+  if (!path || path === HOME_URL || path === STORE_HEAD_IMAGE_PATH) {
+    return true;
+  }
+  const storeId = localGet("createdId") || localGet("geeker-user")?.userInfo?.storeId;
+  if (!storeId) {
+    return true;
+  }
+  try {
+    const res: any = await getDetail({ id: storeId });
+    const headImgStatus = res?.data?.headImgStatus;
+    // 与商家端一致:headImgStatus === 2 表示未上传头图
+    if (headImgStatus !== 2) {
+      return true;
+    }
+    await ElMessageBox.confirm("请先上传头图后再进行下一步操作", "未上传头图", {
+      confirmButtonText: "去上传头图",
+      cancelButtonText: "暂不上传",
+      type: "warning"
+    });
+    router.push(STORE_HEAD_IMAGE_PATH);
+    return false;
+  } catch (err: any) {
+    if (err === "cancel" || err?.message === "cancel") {
+      return false;
+    }
+    return true;
+  }
+}

+ 12 - 2
src/views/home/components/go-flow.vue

@@ -40,7 +40,7 @@
             >
               <template v-if="idCardFrontList.length === 0">
                 <div class="upload-placeholder">
-                  <span class="placeholder-text">示例图</span>
+                  <el-image src="http://localhost:5173/static/img/idCard2.png" />
                 </div>
               </template>
             </el-upload>
@@ -64,7 +64,9 @@
             >
               <template v-if="idCardBackList.length === 0">
                 <div class="upload-placeholder">
-                  <span class="placeholder-text">示例图</span>
+                  <span class="placeholder-text">
+                    <el-image src="http://localhost:5173/static/img/idCard1.png" />
+                  </span>
                 </div>
               </template>
             </el-upload>
@@ -408,6 +410,7 @@ const handleNextStep = async () => {
       setStep(2);
     } else {
       ElMessage.error(res?.msg || "身份证识别失败");
+      idCardFrontList.value = [];
     }
   } catch (error: any) {
     console.log(error);
@@ -960,7 +963,11 @@ const autoOcrRecognition = async (ocrType: string, name: string) => {
       } else if (ocrType === "FOOD_MANAGE_LICENSE") {
         foodLicenseOcrStatus.value = "failed";
         step2Form.foodLicenceImgList = [];
+      } else if (ocrType === "ID_CARD") {
+        idCardFrontList.value = [];
+        idCardBackList.value = [];
       }
+
       ElMessage.error(res?.msg || "识别失败,已清除该图片,请重新上传");
     }
   } catch (error) {
@@ -973,6 +980,9 @@ const autoOcrRecognition = async (ocrType: string, name: string) => {
     } else if (ocrType === "FOOD_MANAGE_LICENSE") {
       foodLicenseOcrStatus.value = "failed";
       step2Form.foodLicenceImgList = [];
+    } else if (ocrType === "ID_CARD") {
+      idCardFrontList.value = [];
+      idCardBackList.value = [];
     }
     ElMessage.error("识别失败,已清除该图片,请重新上传");
   } finally {

+ 7 - 0
src/views/login/index.vue

@@ -1186,6 +1186,13 @@ onMounted(() => {
   document.onkeydown = (e: KeyboardEvent) => {
     if (e.code === "Enter" || e.code === "enter" || e.code === "NumpadEnter") {
       if (loading.value) return;
+      // 注册弹框打开时回车触发注册,否则触发登录
+      if (registerShow.value) {
+        e.preventDefault();
+        e.stopPropagation();
+        handleRegister();
+        return;
+      }
       handleLogin();
     }
   };

+ 22 - 7
src/views/storeDecoration/storeHeadMap/index.vue

@@ -148,12 +148,13 @@ import { uploadImg, getStoreOcrData } from "@/api/modules/newLoginApi";
 import { getStoreHeadImg, saveStoreHeadImg } from "@/api/modules/storeDecoration";
 import { getDetail } from "@/api/modules/homeEntry";
 import { localGet } from "@/utils";
+import { useRouter } from "vue-router";
 
 const loading = ref(false);
 const singleFormRef = ref<FormInstance>();
 const multipleFormRef = ref<FormInstance>();
 const sortableInstance = ref<Sortable | null>(null);
-
+const router = useRouter();
 const imgModeActive = ref(null);
 const storeName = ref("");
 const handleStoreOcrAfterUploadMore = async (imageUrl: string) => {
@@ -179,17 +180,30 @@ const handleStoreOcr = async (params: { imageUrl: string }) => {
   try {
     const res: any = await getStoreOcrData({ imageUrl: params.imageUrl, merchantName: storeName.value });
     if (res.code === 200) {
-      ElNotification({
-        title: "OCR识别成功",
-        message: `识别结果: ${res.msg || "无"}`,
-        type: "success",
-        duration: 5000
-      });
+      if (res.data.overall_match) {
+        ElNotification({
+          title: "OCR识别成功",
+          message: `识别结果: ${res.msg || "无"}`,
+          type: "success",
+          duration: 5000
+        });
+      } else {
+        ElNotification({
+          title: "OCR识别失败",
+          message: "图片不符合规范,请重新上传",
+          type: "error",
+          duration: 5000
+        });
+        formData.singleImage = "";
+        formData.multipleImages = [];
+      }
     } else {
       // 业务逻辑错误,只在这里显示错误消息
       const errorMsg = res?.msg || "未查询到OCR识别数据";
       ElMessage.error(errorMsg);
       const error = new Error(errorMsg);
+      formData.singleImage = "";
+      formData.multipleImages = [];
       (error as any).handled = true; // 标记错误已被处理
       throw error;
     }
@@ -567,6 +581,7 @@ const handleSave = async () => {
         type: "success",
         duration: 3000
       });
+      router.push("/home/index");
 
       // 根据返回的imgModeActive值设置当前模式
       // 0表示单图模式,其他值表示多图模式