|
|
@@ -137,6 +137,7 @@
|
|
|
:limit="1"
|
|
|
:on-exceed="handleExceed"
|
|
|
:on-success="handleUploadSuccess"
|
|
|
+ :on-preview="handlePictureCardPreview"
|
|
|
>
|
|
|
<el-icon><Plus /></el-icon>
|
|
|
<template #tip>
|
|
|
@@ -153,6 +154,7 @@
|
|
|
:limit="20"
|
|
|
:on-exceed="handleExceed"
|
|
|
:on-success="handleUploadSuccess"
|
|
|
+ :on-preview="handlePictureCardPreview"
|
|
|
>
|
|
|
<el-icon><Plus /></el-icon>
|
|
|
<template #tip>
|
|
|
@@ -169,6 +171,7 @@
|
|
|
:limit="1"
|
|
|
:on-exceed="handleExceed"
|
|
|
:on-success="handleUploadSuccess"
|
|
|
+ :on-preview="handlePictureCardPreview"
|
|
|
>
|
|
|
<el-icon><Plus /></el-icon>
|
|
|
<template #tip>
|
|
|
@@ -196,6 +199,14 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+
|
|
|
+ <!-- 图片预览 -->
|
|
|
+ <el-image-viewer
|
|
|
+ v-if="imageViewerVisible"
|
|
|
+ :url-list="imageViewerUrlList"
|
|
|
+ :initial-index="imageViewerInitialIndex"
|
|
|
+ @close="imageViewerVisible = false"
|
|
|
+ />
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
import { ref, reactive, watch, onMounted } from "vue";
|
|
|
@@ -213,13 +224,16 @@ import { Plus } from "@element-plus/icons-vue";
|
|
|
import { verifyIdInfo, applyStore, getMerchantByPhone } from "@/api/modules/homeEntry";
|
|
|
import { getBusinessSection, getBusinessSectionTypes, getInputPrompt, getDistrict, uploadImg } from "@/api/modules/newLoginApi";
|
|
|
import { localGet, localSet } from "@/utils/index";
|
|
|
+import { useAuthStore } from "@/stores/modules/auth";
|
|
|
+
|
|
|
+const authStore = useAuthStore();
|
|
|
const userInfo = localGet("geeker-user")?.userInfo || {};
|
|
|
const latShow = ref(false);
|
|
|
-onMounted(() => {
|
|
|
- getBusinessSectionList();
|
|
|
- getBusinessTypes(null);
|
|
|
- callGetUserInfo();
|
|
|
-});
|
|
|
+
|
|
|
+// 图片预览相关
|
|
|
+const imageViewerVisible = ref(false);
|
|
|
+const imageViewerUrlList = ref<string[]>([]);
|
|
|
+const imageViewerInitialIndex = ref(0);
|
|
|
const entryList = ref([
|
|
|
{
|
|
|
title: "个人实名"
|
|
|
@@ -237,6 +251,7 @@ const entryList = ref([
|
|
|
|
|
|
const step2Rules: FormRules = {
|
|
|
storeName: [{ required: true, message: "请输入店铺名称", trigger: "blur" }],
|
|
|
+ storeCapacity: [{ required: true, message: "请输入容纳人数", trigger: "blur" }],
|
|
|
storeArea: [{ required: true, message: "请选择门店面积", trigger: "change" }],
|
|
|
storeBlurb: [{ required: true, message: "请输入门店简介", trigger: "change" }],
|
|
|
storeIntro: [{ required: true, message: "请输入门店简介", trigger: "blur" }],
|
|
|
@@ -286,6 +301,117 @@ watch(
|
|
|
if (typeof val === "number") storeApplicationStatus.value = val;
|
|
|
}
|
|
|
);
|
|
|
+
|
|
|
+// 隐藏财务管理菜单的函数
|
|
|
+const hideFinancialManagementMenu = () => {
|
|
|
+ const hideMenus = (menuList: any[]) => {
|
|
|
+ menuList.forEach(menu => {
|
|
|
+ // 根据菜单名称判断是否需要隐藏财务管理
|
|
|
+ if (menu.name && menu.name === "financialManagement") {
|
|
|
+ menu.meta.isHide = true;
|
|
|
+ }
|
|
|
+ // 递归处理子菜单
|
|
|
+ if (menu.children && menu.children.length > 0) {
|
|
|
+ hideMenus(menu.children);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ if (authStore.authMenuList && authStore.authMenuList.length > 0) {
|
|
|
+ hideMenus(authStore.authMenuList);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 显示财务管理菜单的函数
|
|
|
+const showFinancialManagementMenu = () => {
|
|
|
+ const showMenus = (menuList: any[]) => {
|
|
|
+ menuList.forEach(menu => {
|
|
|
+ // 根据菜单名称判断是否需要显示财务管理
|
|
|
+ if (menu.name && menu.name === "financialManagement") {
|
|
|
+ menu.meta.isHide = false;
|
|
|
+ }
|
|
|
+ // 递归处理子菜单
|
|
|
+ if (menu.children && menu.children.length > 0) {
|
|
|
+ showMenus(menu.children);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ if (authStore.authMenuList && authStore.authMenuList.length > 0) {
|
|
|
+ showMenus(authStore.authMenuList);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 更新缓存中的 storeId
|
|
|
+const updateStoreIdInCache = async () => {
|
|
|
+ try {
|
|
|
+ const geekerUser = localGet("geeker-user");
|
|
|
+ if (!geekerUser || !geekerUser.userInfo || !geekerUser.userInfo.phone) {
|
|
|
+ console.error("用户信息不存在");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const phone = geekerUser.userInfo.phone;
|
|
|
+ const res: any = await getMerchantByPhone({ phone });
|
|
|
+ if (res && res.code == 200 && res.data && res.data.storeId) {
|
|
|
+ // 更新缓存中的 storeId
|
|
|
+ geekerUser.userInfo.storeId = res.data.storeId;
|
|
|
+ localSet("geeker-user", geekerUser);
|
|
|
+ // 同时更新 createdId 缓存
|
|
|
+ if (res.data.storeId) {
|
|
|
+ localSet("createdId", res.data.storeId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error("更新 storeId 缓存失败:", error);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 监听步骤和审核状态,如果是待审核或审核拒绝,则更新 storeId
|
|
|
+watch([() => currentStep.value, () => storeApplicationStatus.value], ([step, status]) => {
|
|
|
+ if (step === 3 && (status === 0 || status === 2)) {
|
|
|
+ updateStoreIdInCache();
|
|
|
+ }
|
|
|
+ // 如果是审核拒绝状态,隐藏财务管理菜单
|
|
|
+ if (status === 2) {
|
|
|
+ hideFinancialManagementMenu();
|
|
|
+ }
|
|
|
+ // 如果是审核通过状态,显示财务管理菜单
|
|
|
+ if (status === 1) {
|
|
|
+ showFinancialManagementMenu();
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+// 监听菜单列表变化,根据审核状态显示或隐藏财务管理菜单
|
|
|
+watch(
|
|
|
+ () => authStore.authMenuList.length,
|
|
|
+ newLength => {
|
|
|
+ if (newLength > 0) {
|
|
|
+ // 如果审核状态是拒绝,隐藏财务管理菜单
|
|
|
+ if (storeApplicationStatus.value === 2) {
|
|
|
+ hideFinancialManagementMenu();
|
|
|
+ }
|
|
|
+ // 如果审核状态是通过,显示财务管理菜单
|
|
|
+ if (storeApplicationStatus.value === 1) {
|
|
|
+ showFinancialManagementMenu();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+);
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getBusinessSectionList();
|
|
|
+ getBusinessTypes(null);
|
|
|
+ callGetUserInfo();
|
|
|
+ // 如果当前已经是待审核或审核拒绝状态,则更新 storeId
|
|
|
+ if (currentStep.value === 3 && (storeApplicationStatus.value === 0 || storeApplicationStatus.value === 2)) {
|
|
|
+ updateStoreIdInCache();
|
|
|
+ }
|
|
|
+ // 根据审核状态显示或隐藏财务管理菜单
|
|
|
+ if (storeApplicationStatus.value === 2) {
|
|
|
+ hideFinancialManagementMenu();
|
|
|
+ } else if (storeApplicationStatus.value === 1) {
|
|
|
+ showFinancialManagementMenu();
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
const changeRefuse = () => {
|
|
|
currentStep.value = 2;
|
|
|
};
|
|
|
@@ -451,14 +577,44 @@ const getLonAndLat = async (keyword: string) => {
|
|
|
}
|
|
|
};
|
|
|
const selectAddress = async (param: any) => {
|
|
|
+ // 安全检查:确保 address 存在且是字符串类型
|
|
|
+ if (!step2Form.address || typeof step2Form.address !== "string") {
|
|
|
+ ElMessage.warning("地址格式不正确,请重新选择");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查是否包含逗号(经纬度格式应该是 "经度,纬度")
|
|
|
+ if (!step2Form.address.includes(",")) {
|
|
|
+ ElMessage.warning("地址格式不正确,缺少经纬度信息");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 安全地分割地址字符串
|
|
|
let locationList = step2Form.address.split(",");
|
|
|
+
|
|
|
+ // 检查分割后的数组长度
|
|
|
+ if (locationList.length < 2) {
|
|
|
+ ElMessage.warning("地址格式不正确,无法获取经纬度");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查找对应的地址名称
|
|
|
addressList.value.forEach((item: any) => {
|
|
|
if (item.location == step2Form.address) {
|
|
|
queryAddress.value = item.name;
|
|
|
}
|
|
|
});
|
|
|
- step2Form.storePositionLongitude = locationList[0];
|
|
|
- step2Form.storePositionLatitude = locationList[1];
|
|
|
+
|
|
|
+ // 设置经纬度,并去除可能的空格
|
|
|
+ step2Form.storePositionLongitude = locationList[0]?.trim() || "";
|
|
|
+ step2Form.storePositionLatitude = locationList[1]?.trim() || "";
|
|
|
+
|
|
|
+ // 验证经纬度是否为有效数字
|
|
|
+ if (!step2Form.storePositionLongitude || !step2Form.storePositionLatitude) {
|
|
|
+ ElMessage.warning("无法获取有效的经纬度信息");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
latShow.value = true;
|
|
|
};
|
|
|
//文件上传
|
|
|
@@ -488,6 +644,47 @@ const handleUploadSuccess = (response: any, uploadFile: UploadUserFile) => {
|
|
|
uploadFile.url = response.fileUrl;
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+// 图片预览处理函数
|
|
|
+const handlePictureCardPreview = (file: UploadUserFile) => {
|
|
|
+ // 如果文件正在上传中,允许预览(使用本地预览)
|
|
|
+ if (file.status === "uploading" && file.url) {
|
|
|
+ imageViewerUrlList.value = [file.url];
|
|
|
+ imageViewerInitialIndex.value = 0;
|
|
|
+ imageViewerVisible.value = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 获取当前上传组件的所有图片 URL 列表(只包含已上传成功的图片)
|
|
|
+ let urlList: string[] = [];
|
|
|
+ let currentFileList: UploadUserFile[] = [];
|
|
|
+
|
|
|
+ // 根据文件对象判断是哪个上传组件的文件
|
|
|
+ if (step2Form.businessLicenseAddress.some((f: UploadUserFile) => f.uid === file.uid)) {
|
|
|
+ currentFileList = step2Form.businessLicenseAddress;
|
|
|
+ } else if (step2Form.contractImageList.some((f: UploadUserFile) => f.uid === file.uid)) {
|
|
|
+ currentFileList = step2Form.contractImageList;
|
|
|
+ } else if (step2Form.foodLicenceImgList.some((f: UploadUserFile) => f.uid === file.uid)) {
|
|
|
+ currentFileList = step2Form.foodLicenceImgList;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取所有已上传成功的图片 URL
|
|
|
+ urlList = currentFileList
|
|
|
+ .filter((item: UploadUserFile) => item.status === "success" && (item.url || (item.response as any)?.fileUrl))
|
|
|
+ .map((item: UploadUserFile) => item.url || (item.response as any)?.fileUrl);
|
|
|
+
|
|
|
+ // 找到当前点击的图片索引
|
|
|
+ const currentUrl = file.url || (file.response as any)?.fileUrl;
|
|
|
+ const currentIndex = urlList.findIndex((url: string) => url === currentUrl);
|
|
|
+
|
|
|
+ if (currentIndex < 0) {
|
|
|
+ ElMessage.warning("图片尚未上传完成,无法预览");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ imageViewerUrlList.value = urlList;
|
|
|
+ imageViewerInitialIndex.value = currentIndex;
|
|
|
+ imageViewerVisible.value = true;
|
|
|
+};
|
|
|
// 下一步
|
|
|
const handleNextStep = async () => {
|
|
|
if (!step1FormRef.value) return;
|