go-flow.vue 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588
  1. <template>
  2. <div class="form-container">
  3. <div>
  4. <!-- 返回按钮 -->
  5. <el-button class="back-btn" @click="handleBack"> 返回 </el-button>
  6. <!-- 进度条 -->
  7. <div class="progress-container">
  8. <el-steps :active="currentStep" style="max-width: 1500px" align-center>
  9. <el-step v-for="(item, index) in entryList" :key="index">
  10. <template #title>
  11. <div class="step-title-wrapper">
  12. <span class="step-title">{{ item.title }}</span>
  13. </div>
  14. </template>
  15. </el-step>
  16. </el-steps>
  17. </div>
  18. </div>
  19. <!-- 第一步:个人实名 - 身份证正反面上传 -->
  20. <div v-if="currentStep === 1" class="step1-content">
  21. <div class="form-content">
  22. <h3 class="section-title">身份证正反面</h3>
  23. <div class="id-card-upload-container">
  24. <!-- 正面 -->
  25. <div class="upload-item">
  26. <div class="upload-label">正面</div>
  27. <el-upload
  28. v-model:file-list="idCardFrontList"
  29. :http-request="handleHttpUpload"
  30. list-type="picture-card"
  31. :limit="1"
  32. :on-exceed="handleExceed"
  33. :on-success="(response, file) => handleUploadSuccess(response, file, 'ID_CARD')"
  34. :on-preview="handlePictureCardPreview"
  35. :on-remove="handleRemove"
  36. accept="image/*"
  37. class="id-card-upload"
  38. :class="{ 'upload-complete': idCardFrontList.length > 0 }"
  39. >
  40. <template v-if="idCardFrontList.length === 0">
  41. <div class="upload-placeholder">
  42. <span class="placeholder-text">示例图</span>
  43. </div>
  44. </template>
  45. </el-upload>
  46. </div>
  47. <!-- 反面 -->
  48. <div class="upload-item">
  49. <div class="upload-label">反面</div>
  50. <el-upload
  51. v-model:file-list="idCardBackList"
  52. :http-request="handleHttpUpload"
  53. list-type="picture-card"
  54. :limit="1"
  55. :on-exceed="handleExceed"
  56. :on-success="(response, file) => handleUploadSuccess(response, file, 'ID_CARD')"
  57. :on-preview="handlePictureCardPreview"
  58. :on-remove="handleRemove"
  59. accept="image/*"
  60. class="id-card-upload"
  61. :class="{ 'upload-complete': idCardBackList.length > 0 }"
  62. >
  63. <template v-if="idCardBackList.length === 0">
  64. <div class="upload-placeholder">
  65. <span class="placeholder-text">示例图</span>
  66. </div>
  67. </template>
  68. </el-upload>
  69. </div>
  70. </div>
  71. <!-- OCR 识别结果展示 -->
  72. <div class="ocr-result-container" v-if="isIdCardUploadComplete">
  73. <div class="ocr-result-item" v-if="isOcrProcessing">
  74. <span class="label">识别中:</span>
  75. <span class="value">正在识别身份证信息,请稍候...</span>
  76. </div>
  77. <template v-else>
  78. <div class="ocr-result-item" v-if="ocrResult.name">
  79. <span class="label">姓名:</span>
  80. <span class="value">{{ ocrResult.name }}</span>
  81. </div>
  82. <div class="ocr-result-item" v-if="ocrResult.idCard">
  83. <span class="label">身份证号:</span>
  84. <span class="value">{{ ocrResult.idCard }}</span>
  85. </div>
  86. <div class="ocr-result-tip" v-if="!ocrResult.name && !ocrResult.idCard">请等待身份证识别完成</div>
  87. </template>
  88. </div>
  89. </div>
  90. <!-- 按钮 -->
  91. <div class="form-actions">
  92. <el-button type="primary" size="large" @click="handleNextStep"> 下一步 </el-button>
  93. </div>
  94. </div>
  95. <!-- 第二步:填写信息 -->
  96. <div v-if="currentStep === 2">
  97. <!-- 表单内容 -->
  98. <div class="form-content step2-form">
  99. <el-form :model="step2Form" :rules="step2Rules" ref="step2FormRef" label-width="125px">
  100. <div class="form-row">
  101. <!-- 左列 -->
  102. <div class="form-col">
  103. <el-form-item label="店铺名称" prop="storeName">
  104. <el-input v-model="step2Form.storeName" placeholder="请输入店铺名称" maxlength="30" />
  105. </el-form-item>
  106. <el-form-item label="容纳人数" prop="storeCapacity">
  107. <el-input-number v-model="step2Form.storeCapacity" :min="1" :max="9999" />
  108. </el-form-item>
  109. <el-form-item label="门店面积" prop="storeArea">
  110. <el-radio-group v-model="step2Form.storeArea">
  111. <el-radio label="小于20平米" value="1"> 小于20平米 </el-radio>
  112. <el-radio label="20-50平米" value="2"> 20-50平米 </el-radio>
  113. <el-radio label="50-100平米" value="3"> 50-100平米 </el-radio>
  114. <el-radio label="100-300平米" value="4"> 100-300平米 </el-radio>
  115. <el-radio label="500-1000平米" value="5"> 500-1000平米 </el-radio>
  116. <el-radio label="大于1000平米" value="6"> 大于1000平米 </el-radio>
  117. </el-radio-group>
  118. </el-form-item>
  119. <el-form-item label="所在地区" prop="region">
  120. <el-cascader :props="areaProps" v-model="step2Form.region" style="width: 100%" />
  121. </el-form-item>
  122. <el-form-item label="详细地址" prop="storeDetailAddress">
  123. <el-input v-model="step2Form.storeDetailAddress" type="textarea" :rows="3" placeholder="请输入" maxlength="255" />
  124. </el-form-item>
  125. <el-form-item label="门店简介" prop="storeBlurb">
  126. <el-input v-model="step2Form.storeBlurb" type="textarea" :rows="3" placeholder="请输入" maxlength="300" />
  127. </el-form-item>
  128. <el-form-item label="经营板块" prop="businessSection">
  129. <el-radio-group v-model="step2Form.businessSection" @change="changeBusinessSector">
  130. <el-radio
  131. v-for="businessSection in businessSectionList"
  132. :value="businessSection.dictId"
  133. :key="businessSection.dictId"
  134. >
  135. {{ businessSection.dictDetail }}
  136. </el-radio>
  137. </el-radio-group>
  138. </el-form-item>
  139. <!-- 如果有二级分类数据,显示经营种类 -->
  140. <el-form-item label="经营种类" prop="businessTypes" v-if="secondLevelList.length > 0">
  141. <el-radio-group v-model="step2Form.businessTypes" @change="changeBusinessSecondLevel">
  142. <el-radio v-for="item in secondLevelList" :value="item.dictId" :key="item.dictId">
  143. {{ item.dictDetail }}
  144. </el-radio>
  145. </el-radio-group>
  146. </el-form-item>
  147. <!-- 只有当有三级分类数据且已选中经营种类时,才显示分类(三级分类多选) -->
  148. <el-form-item
  149. label="分类"
  150. prop="businessSecondLevel"
  151. v-if="thirdLevelList && thirdLevelList.length > 0 && step2Form.businessTypes"
  152. >
  153. <el-checkbox-group v-model="step2Form.businessSecondLevel">
  154. <el-checkbox v-for="item in thirdLevelList" :key="item.dictId" :label="item.dictDetail" :value="item.dictId" />
  155. </el-checkbox-group>
  156. </el-form-item>
  157. <!-- <el-form-item label="分类" prop="businessSecondLevel">
  158. <el-radio-group v-model="step2Form.businessSecondLevel" @change="changeBusinessSecondLevel">
  159. <el-radio v-for="item in secondLevelList" :value="item.dictId" :key="item.dictId">
  160. {{ item.dictDetail }}
  161. </el-radio>
  162. </el-radio-group>
  163. </el-form-item> -->
  164. <el-form-item label="是否提供餐食" prop="businessSecondMeal" v-if="showMealOption">
  165. <el-radio-group v-model="step2Form.businessSecondMeal" @change="changeBusinessSecondMeal">
  166. <el-radio v-for="item in secondMealList" :value="item.value" :key="item.key">
  167. {{ item.dictDetail }}
  168. </el-radio>
  169. </el-radio-group>
  170. </el-form-item>
  171. </div>
  172. <!-- 右列 -->
  173. <div class="form-col">
  174. <el-form-item label="门店营业状态" prop="businessType">
  175. <el-radio-group v-model="step2Form.businessType">
  176. <el-radio label="正常营业"> 正常营业 </el-radio>
  177. <el-radio label="暂停营业"> 暂停营业 </el-radio>
  178. <el-radio label="筹建中"> 筹建中 </el-radio>
  179. </el-radio-group>
  180. </el-form-item>
  181. <el-form-item label="经度" prop="storePositionLongitude" v-show="latShow">
  182. <el-input disabled v-model="step2Form.storePositionLongitude" placeholder="请填写经度" clearable />
  183. </el-form-item>
  184. <el-form-item label="纬度" prop="storePositionLatitude" v-show="latShow">
  185. <el-input disabled v-model="step2Form.storePositionLatitude" placeholder="请填写纬度" clearable />
  186. </el-form-item>
  187. <el-form-item label="经纬度查询" prop="address">
  188. <el-select
  189. v-model="step2Form.address"
  190. filterable
  191. placeholder="请输入地址进行查询"
  192. remote
  193. reserve-keyword
  194. :remote-method="getLonAndLat"
  195. @change="selectAddress"
  196. >
  197. <el-option v-for="item in addressList" :key="item.id" :label="item.name" :value="item.location">
  198. <span style="float: left">{{ item.name }}</span>
  199. <span style="float: right; font-size: 13px; color: var(--el-text-color-secondary)">{{ item.district }}</span>
  200. </el-option>
  201. </el-select>
  202. </el-form-item>
  203. <el-form-item label="营业执照" prop="businessLicenseAddress">
  204. <el-upload
  205. v-model:file-list="step2Form.businessLicenseAddress"
  206. :http-request="handleHttpUpload"
  207. list-type="picture-card"
  208. :limit="1"
  209. :on-exceed="handleExceed"
  210. :on-success="(response, file) => handleUploadSuccess(response, file, 'BUSINESS_LICENSE')"
  211. :on-preview="handlePictureCardPreview"
  212. >
  213. <el-icon><Plus /></el-icon>
  214. <template #tip>
  215. <div class="el-upload__tip">({{ step2Form.businessLicenseAddress.length }}/1)</div>
  216. </template>
  217. </el-upload>
  218. </el-form-item>
  219. <el-form-item label="合同图片" prop="contractImageList">
  220. <el-upload
  221. v-model:file-list="step2Form.contractImageList"
  222. :http-request="handleHttpUpload"
  223. list-type="picture-card"
  224. :limit="20"
  225. :on-exceed="handleExceed"
  226. :on-success="(response, file) => handleUploadSuccess(response, file, '')"
  227. :on-preview="handlePictureCardPreview"
  228. >
  229. <el-icon><Plus /></el-icon>
  230. <template #tip>
  231. <div class="el-upload__tip">({{ step2Form.contractImageList.length }}/20)</div>
  232. </template>
  233. </el-upload>
  234. </el-form-item>
  235. <el-form-item label="食品经营许可证" prop="foodLicenceImgList" v-if="showFoodLicence">
  236. <el-upload
  237. v-model:file-list="step2Form.foodLicenceImgList"
  238. :http-request="handleHttpUpload"
  239. list-type="picture-card"
  240. :limit="1"
  241. :on-exceed="handleExceed"
  242. :on-success="(response, file) => handleUploadSuccess(response, file, 'FOOD_MANAGE_LICENSE')"
  243. :on-preview="handlePictureCardPreview"
  244. >
  245. <el-icon><Plus /></el-icon>
  246. <template #tip>
  247. <div class="el-upload__tip">({{ step2Form.foodLicenceImgList.length }}/1)</div>
  248. </template>
  249. </el-upload>
  250. </el-form-item>
  251. <el-form-item label="娱乐经营许可证" prop="disportLicenceImgList" v-if="showDisportLicence">
  252. <el-upload
  253. v-model:file-list="step2Form.disportLicenceImgList"
  254. :http-request="handleHttpUpload"
  255. list-type="picture-card"
  256. :limit="1"
  257. :on-exceed="handleExceed"
  258. :on-success="(response, file) => handleUploadSuccess(response, file, 'BUSINESS_LICENSE')"
  259. :on-preview="handlePictureCardPreview"
  260. >
  261. <el-icon><Plus /></el-icon>
  262. <template #tip>
  263. <div class="el-upload__tip">({{ step2Form.disportLicenceImgList.length }}/1)</div>
  264. </template>
  265. </el-upload>
  266. </el-form-item>
  267. </div>
  268. </div>
  269. </el-form>
  270. </div>
  271. <!-- 按钮 -->
  272. <div class="form-actions">
  273. <el-button type="primary" size="large" @click="handleSubmit"> 提交 </el-button>
  274. </div>
  275. </div>
  276. </div>
  277. <!-- 图片预览 -->
  278. <el-image-viewer
  279. v-if="imageViewerVisible"
  280. :url-list="imageViewerUrlList"
  281. :initial-index="imageViewerInitialIndex"
  282. @close="imageViewerVisible = false"
  283. />
  284. </template>
  285. <script setup lang="ts">
  286. import { ref, reactive, watch, onMounted, computed } from "vue";
  287. import {
  288. ElMessage,
  289. ElMessageBox,
  290. type FormInstance,
  291. type FormRules,
  292. UploadProps,
  293. UploadUserFile,
  294. UploadRequestOptions
  295. } from "element-plus";
  296. import { Plus } from "@element-plus/icons-vue";
  297. import {
  298. applyStore,
  299. getMerchantByPhone,
  300. getFirstLevelList,
  301. getSecondLevelList,
  302. getThirdLevelList,
  303. verifyIdInfo
  304. } from "@/api/modules/homeEntry";
  305. import { getInputPrompt, getDistrict, uploadImg, ocrRequestUrl } from "@/api/modules/newLoginApi";
  306. import { localGet, localSet } from "@/utils/index";
  307. import { useAuthStore } from "@/stores/modules/auth";
  308. const authStore = useAuthStore();
  309. const userInfo = localGet("geeker-user")?.userInfo || {};
  310. const latShow = ref(false);
  311. // 图片预览相关
  312. const imageViewerVisible = ref(false);
  313. const imageViewerUrlList = ref<string[]>([]);
  314. const imageViewerInitialIndex = ref(0);
  315. const entryList = ref([
  316. {
  317. title: "个人实名"
  318. },
  319. {
  320. title: "填写信息"
  321. },
  322. {
  323. title: "等待审核"
  324. },
  325. {
  326. title: "入驻成功"
  327. }
  328. ]);
  329. // 身份证正反面上传列表
  330. const idCardFrontList = ref<UploadUserFile[]>([]);
  331. const idCardBackList = ref<UploadUserFile[]>([]);
  332. //
  333. const showFoodLicence = ref(true);
  334. const changeBusinessSecondMeal = (value: any) => {
  335. if (value == 0) {
  336. showFoodLicence.value = false;
  337. } else {
  338. showFoodLicence.value = true;
  339. }
  340. };
  341. // OCR 识别结果
  342. const ocrResult = ref<{
  343. name?: string;
  344. idCard?: string;
  345. }>({});
  346. // 食品经营许可证到期时间(从 OCR 结果中提取)
  347. const foodLicenceExpirationTime = ref<string>("");
  348. // 娱乐经营许可证到期时间(从 OCR 结果中提取)
  349. const entertainmentLicenceExpirationTime = ref<string>("");
  350. // 是否正在识别中
  351. const isOcrProcessing = ref(false);
  352. // 日期格式转换函数:支持两种格式
  353. // 1. "20220508" -> "2022-05-08"
  354. // 2. "2024年01月14日" -> "2024-01-14"
  355. const formatDate = (dateStr: string): string => {
  356. if (!dateStr) {
  357. return "";
  358. }
  359. // 处理中文日期格式:2024年01月14日
  360. if (dateStr.includes("年") && dateStr.includes("月") && dateStr.includes("日")) {
  361. const match = dateStr.match(/(\d{4})年(\d{1,2})月(\d{1,2})日/);
  362. if (match) {
  363. const year = match[1];
  364. const month = match[2].padStart(2, "0"); // 补零,确保是两位数
  365. const day = match[3].padStart(2, "0"); // 补零,确保是两位数
  366. return `${year}-${month}-${day}`;
  367. }
  368. }
  369. // 处理8位数字格式:20220508
  370. if (dateStr.length === 8 && /^\d{8}$/.test(dateStr)) {
  371. const year = dateStr.substring(0, 4);
  372. const month = dateStr.substring(4, 6);
  373. const day = dateStr.substring(6, 8);
  374. return `${year}-${month}-${day}`;
  375. }
  376. return "";
  377. };
  378. // 计算是否已上传完成(正反面都上传完成)
  379. const isIdCardUploadComplete = computed(() => {
  380. return idCardFrontList.value.length > 0 && idCardBackList.value.length > 0;
  381. });
  382. // 计算是否需要显示娱乐经营许可证(酒吧或KTV时显示)
  383. const showDisportLicence = computed(() => {
  384. const sectionName = step2Form.businessSectionName;
  385. const sectionId = step2Form.businessSection;
  386. // 通过名称判断(最直接的方式)
  387. if (sectionName === "酒吧" || sectionName === "KTV" || sectionName === "ktv") {
  388. return true;
  389. }
  390. // 通过查找 businessSectionList 来判断(兼容 id 和 dictId)
  391. if (businessSectionList.value.length > 0 && sectionId) {
  392. const selectedSection = businessSectionList.value.find((item: any) => {
  393. // 匹配 id 或 dictId
  394. const isMatchId =
  395. item.id === sectionId ||
  396. item.dictId === sectionId ||
  397. String(item.id) === String(sectionId) ||
  398. String(item.dictId) === String(sectionId);
  399. // 匹配名称
  400. const isMatchName = item.dictDetail === "酒吧" || item.dictDetail === "KTV" || item.dictDetail === "ktv";
  401. return isMatchId && isMatchName;
  402. });
  403. if (selectedSection) {
  404. return true;
  405. }
  406. }
  407. // 通过 dictId 判断(KTV 的 dictId 通常是 "3")
  408. if (String(sectionId) === "3") {
  409. return true;
  410. }
  411. return false;
  412. });
  413. // 计算是否需要显示"是否提供餐食"(KTV、按摩足疗、丽人美发、运动健身、洗浴汗蒸时显示)
  414. const showMealOption = computed(() => {
  415. const sectionName = step2Form.businessSectionName;
  416. const sectionId = step2Form.businessSection;
  417. // 需要显示的经营板块名称列表
  418. const mealSectionNames = ["KTV", "ktv", "按摩足疗", "丽人美发", "运动健身", "洗浴汗蒸"];
  419. // 通过名称判断(最直接的方式)
  420. if (mealSectionNames.includes(sectionName)) {
  421. return true;
  422. }
  423. // 通过查找 businessSectionList 来判断(兼容 id 和 dictId)
  424. if (businessSectionList.value.length > 0 && sectionId) {
  425. const selectedSection = businessSectionList.value.find((item: any) => {
  426. // 匹配 id 或 dictId
  427. const isMatchId =
  428. item.dictId === sectionId ||
  429. item.dictId === sectionId ||
  430. String(item.dictId) === String(sectionId) ||
  431. String(item.dictId) === String(sectionId);
  432. // 匹配名称
  433. const isMatchName = mealSectionNames.includes(item.dictDetail);
  434. return isMatchId && isMatchName;
  435. });
  436. if (selectedSection) {
  437. return true;
  438. }
  439. }
  440. // 通过 dictId 判断(KTV=3, 按摩足疗=5, 丽人美发=6, 运动健身=7, 洗浴汗蒸=4)
  441. const mealSectionIds = ["3", "4", "5", "6", "7"];
  442. if (mealSectionIds.includes(String(sectionId))) {
  443. return true;
  444. }
  445. return false;
  446. });
  447. // 下一步 - 验证身份证正反面是否已上传
  448. const handleNextStep = async () => {
  449. // 识别成功,进入下一步
  450. try {
  451. const res: any = await verifyIdInfo({
  452. idCard: ocrResult.value.idCard,
  453. name: ocrResult.value.name,
  454. appType: 1
  455. });
  456. if (res.code === 200) {
  457. ElMessage.success("身份证识别成功");
  458. setStep(2);
  459. } else {
  460. ElMessage.error(res?.msg || "身份证识别失败");
  461. }
  462. } catch (error: any) {
  463. console.log(error);
  464. }
  465. };
  466. const secondMealList = ref([
  467. { key: 1, value: 1, dictDetail: "提供" },
  468. { key: 0, value: 0, dictDetail: "不提供" }
  469. ]);
  470. const step2Rules: FormRules = {
  471. storeName: [{ required: true, message: "请输入店铺名称", trigger: "blur" }],
  472. storeCapacity: [{ required: true, message: "请输入容纳人数", trigger: "blur" }],
  473. storeArea: [{ required: true, message: "请选择门店面积", trigger: "change" }],
  474. storeBlurb: [{ required: true, message: "请输入门店简介", trigger: "change" }],
  475. storeIntro: [{ required: true, message: "请输入门店简介", trigger: "blur" }],
  476. businessSection: [{ required: true, message: "请选择经营板块", trigger: "change" }],
  477. businessSecondLevel: [{ required: true, message: "请选择分类", trigger: "change" }],
  478. businessSecondMeal: [{ required: true, message: "请选择是否提供餐食", trigger: "change" }],
  479. businessTypes: [
  480. {
  481. required: true,
  482. message: "请选择经营种类",
  483. trigger: "change",
  484. validator: (rule: any, value: any, callback: any) => {
  485. if (!value || value.length === 0) {
  486. callback(new Error("请选择经营种类"));
  487. } else {
  488. callback();
  489. }
  490. }
  491. }
  492. ],
  493. address: [{ required: true, message: "请输入经纬度", trigger: "blur" }],
  494. businessLicenseAddress: [{ required: true, message: "请上传营业执照", trigger: "change" }],
  495. contractImageList: [{ required: true, message: "请上传合同图片", trigger: "change" }],
  496. foodLicenceImgList: [{ required: true, message: "请上传食品经营许可证", trigger: "change" }],
  497. disportLicenceImgList: [{ required: true, message: "请上传娱乐经营许可证", trigger: "change" }]
  498. };
  499. //地址集合
  500. const addressList = ref<any[]>([]);
  501. //查询地址名称
  502. const queryAddress = ref<string>("");
  503. const props = defineProps({
  504. currentStep: {
  505. type: Number,
  506. default: 1
  507. },
  508. storeApplicationStatus: {
  509. type: Number,
  510. default: 0
  511. }
  512. });
  513. const emit = defineEmits(["update:currentStep", "update:get-user-info"]);
  514. // 调用父组件的 getUserInfo 方法
  515. const callGetUserInfo = () => {
  516. emit("update:get-user-info");
  517. };
  518. // 内部步骤状态,和父组件同步
  519. const currentStep = ref<number>(props.currentStep || 1);
  520. const storeApplicationStatus = ref<number>(props.storeApplicationStatus || 0);
  521. watch(
  522. () => props.currentStep,
  523. val => {
  524. if (typeof val === "number") currentStep.value = val;
  525. }
  526. );
  527. watch(
  528. () => props.storeApplicationStatus,
  529. val => {
  530. if (typeof val === "number") storeApplicationStatus.value = val;
  531. }
  532. );
  533. // 隐藏财务管理菜单的函数
  534. const hideFinancialManagementMenu = () => {
  535. const hideMenus = (menuList: any[]) => {
  536. menuList.forEach(menu => {
  537. if (menu.name && menu.name === "financialManagement") {
  538. menu.meta.isHide = true;
  539. }
  540. if (menu.children && menu.children.length > 0) {
  541. hideMenus(menu.children);
  542. }
  543. });
  544. };
  545. if (authStore.authMenuList && authStore.authMenuList.length > 0) {
  546. hideMenus(authStore.authMenuList);
  547. }
  548. };
  549. // 显示财务管理菜单的函数
  550. const showFinancialManagementMenu = () => {
  551. const showMenus = (menuList: any[]) => {
  552. menuList.forEach(menu => {
  553. if (menu.name && menu.name === "financialManagement") {
  554. menu.meta.isHide = false;
  555. }
  556. if (menu.children && menu.children.length > 0) {
  557. showMenus(menu.children);
  558. }
  559. });
  560. };
  561. if (authStore.authMenuList && authStore.authMenuList.length > 0) {
  562. showMenus(authStore.authMenuList);
  563. }
  564. };
  565. // 更新缓存中的 storeId
  566. const updateStoreIdInCache = async () => {
  567. try {
  568. const geekerUser = localGet("geeker-user");
  569. if (!geekerUser || !geekerUser.userInfo || !geekerUser.userInfo.phone) {
  570. console.error("用户信息不存在");
  571. return;
  572. }
  573. const phone = geekerUser.userInfo.phone;
  574. const res: any = await getMerchantByPhone({ phone });
  575. if (res && res.code == 200 && res.data && res.data.storeId) {
  576. geekerUser.userInfo.storeId = res.data.storeId;
  577. localSet("geeker-user", geekerUser);
  578. if (res.data.storeId) {
  579. localSet("createdId", res.data.storeId);
  580. }
  581. }
  582. } catch (error) {
  583. console.error("更新 storeId 缓存失败:", error);
  584. }
  585. };
  586. // 监听步骤和审核状态
  587. watch([() => currentStep.value, () => storeApplicationStatus.value], ([step, status]) => {
  588. if (step === 3 && (status === 0 || status === 2)) {
  589. updateStoreIdInCache();
  590. }
  591. if (status === 2) {
  592. hideFinancialManagementMenu();
  593. }
  594. if (status === 1) {
  595. showFinancialManagementMenu();
  596. }
  597. });
  598. // 监听菜单列表变化
  599. watch(
  600. () => authStore.authMenuList.length,
  601. newLength => {
  602. if (newLength > 0) {
  603. if (storeApplicationStatus.value === 2) {
  604. hideFinancialManagementMenu();
  605. }
  606. if (storeApplicationStatus.value === 1) {
  607. showFinancialManagementMenu();
  608. }
  609. }
  610. }
  611. );
  612. onMounted(() => {
  613. getBusinessSectionList();
  614. callGetUserInfo();
  615. if (currentStep.value === 3 && (storeApplicationStatus.value === 0 || storeApplicationStatus.value === 2)) {
  616. updateStoreIdInCache();
  617. }
  618. if (storeApplicationStatus.value === 2) {
  619. hideFinancialManagementMenu();
  620. } else if (storeApplicationStatus.value === 1) {
  621. showFinancialManagementMenu();
  622. }
  623. });
  624. const setStep = (val: number) => {
  625. currentStep.value = val;
  626. emit("update:currentStep", val);
  627. };
  628. // 第二步表单
  629. const step2FormRef = ref<FormInstance>();
  630. const step2Form = reactive({
  631. businessSecondMeal: 1,
  632. storeName: "",
  633. storeCapacity: 1,
  634. storeArea: "1",
  635. isChain: 0,
  636. storeDetailAddress: "",
  637. region: [],
  638. administrativeRegionProvinceAdcode: "",
  639. administrativeRegionCityAdcode: "",
  640. administrativeRegionDistrictAdcode: "",
  641. storeAddress: "",
  642. storeBlurb: "",
  643. businessSection: "1",
  644. businessSectionName: "",
  645. businessSecondLevel: [] as string[],
  646. businessTypes: "" as string,
  647. businessTypesList: [] as string[],
  648. businessStatus: 0,
  649. storeStatus: 1,
  650. businessType: "正常营业",
  651. storePositionLongitude: "",
  652. storePositionLatitude: "",
  653. businessLicenseAddress: [] as UploadUserFile[],
  654. contractImageList: [] as UploadUserFile[],
  655. foodLicenceImgList: [] as UploadUserFile[],
  656. disportLicenceImgList: [] as UploadUserFile[],
  657. address: ""
  658. });
  659. // 返回按钮
  660. const handleBack = () => {
  661. if (currentStep.value === 1) {
  662. setStep(0);
  663. } else if (currentStep.value === 2) {
  664. setStep(1);
  665. } else if (currentStep.value === 3) {
  666. setStep(2);
  667. }
  668. };
  669. // 地区选择
  670. const areaProps: any = {
  671. lazy: true,
  672. async lazyLoad(node, resolve) {
  673. const { level } = node;
  674. try {
  675. let param = { adCode: node.data.adCode ? node.data.adCode : "" };
  676. const response: any = await getDistrict(param as any);
  677. const nodes = (response?.data?.districts?.[0]?.districts || []).map((item: any) => ({
  678. value: item.adcode,
  679. adCode: item.adcode,
  680. label: item.name,
  681. leaf: level >= 2
  682. }));
  683. resolve(nodes);
  684. } catch (error) {
  685. resolve([]);
  686. }
  687. }
  688. };
  689. watch(
  690. () => step2Form.region,
  691. (newVal: any[]) => {
  692. if (newVal.length > 0) {
  693. step2Form.administrativeRegionProvinceAdcode = newVal[0];
  694. step2Form.administrativeRegionCityAdcode = newVal[1];
  695. step2Form.administrativeRegionDistrictAdcode = newVal[2];
  696. }
  697. }
  698. );
  699. //经营板块 - 一级分类
  700. const businessSectionList = ref<any[]>([]);
  701. const getBusinessSectionList = async () => {
  702. try {
  703. const res: any = await getFirstLevelList({});
  704. if (res && res.code === 200 && res.data) {
  705. businessSectionList.value = res.data;
  706. // 如果有数据,自动加载第一个经营板块的二级分类(经营种类)
  707. if (res.data && res.data.length > 0) {
  708. const firstSection = res.data[0];
  709. const firstDictId = firstSection.dictId || firstSection.id;
  710. if (firstDictId) {
  711. try {
  712. const secondRes: any = await getSecondLevelList({ parentDictId: String(firstDictId) });
  713. if (secondRes && (secondRes.code === 200 || secondRes.code === "200") && secondRes.data) {
  714. secondLevelList.value = secondRes.data;
  715. }
  716. } catch (error) {
  717. console.error("获取二级分类失败:", error);
  718. }
  719. }
  720. }
  721. }
  722. } catch (error) {
  723. console.error("获取一级分类失败:", error);
  724. ElMessage.error("获取经营板块失败");
  725. }
  726. };
  727. // 二级分类列表
  728. const secondLevelList = ref<any[]>([]);
  729. // 三级分类列表
  730. const thirdLevelList = ref<any[]>([]);
  731. // 一级分类变化时,加载二级分类
  732. const changeBusinessSector = async (dictId: string | number | boolean | undefined) => {
  733. const dictIdStr = String(dictId || "");
  734. if (!dictIdStr) {
  735. secondLevelList.value = [];
  736. thirdLevelList.value = [];
  737. step2Form.businessSecondLevel = [];
  738. step2Form.businessTypes = "";
  739. step2Form.businessTypesList = [];
  740. step2Form.businessSection = "";
  741. step2Form.businessSectionName = "";
  742. return;
  743. }
  744. // 更新一级分类信息(模板中 :value 绑定的是 dictId,所以这里查找时优先使用 dictId)
  745. const selectedSection = businessSectionList.value.find(
  746. (item: any) => String(item.dictId) === dictIdStr || String(item.id) === dictIdStr
  747. );
  748. if (selectedSection) {
  749. // 保持与模板中 :value="businessSection.dictId" 绑定一致,使用 dictId
  750. step2Form.businessSection = String(selectedSection.dictId || selectedSection.id);
  751. step2Form.businessSectionName = selectedSection.dictDetail;
  752. } else {
  753. // 如果没找到,直接使用传入的值
  754. step2Form.businessSection = dictIdStr;
  755. step2Form.businessSectionName = "";
  756. }
  757. // 清空二级和三级分类
  758. secondLevelList.value = [];
  759. thirdLevelList.value = [];
  760. step2Form.businessSecondLevel = [];
  761. step2Form.businessTypes = "";
  762. step2Form.businessTypesList = [];
  763. // 加载二级分类(使用 dictId 作为 parentDictId)
  764. const parentDictId = selectedSection?.dictId || dictIdStr;
  765. try {
  766. const res: any = await getSecondLevelList({ parentDictId });
  767. if (res && (res.code === 200 || res.code === "200") && res.data) {
  768. secondLevelList.value = res.data;
  769. }
  770. } catch (error) {
  771. console.error("获取二级分类失败:", error);
  772. ElMessage.error("获取经营种类失败");
  773. }
  774. };
  775. // 二级分类变化时,加载三级分类
  776. const changeBusinessSecondLevel = async (dictId: string | number | boolean | undefined) => {
  777. const dictIdStr = String(dictId || "");
  778. if (!dictIdStr) {
  779. thirdLevelList.value = [];
  780. step2Form.businessTypes = "";
  781. step2Form.businessTypesList = [];
  782. return;
  783. }
  784. // 清空三级分类(但不清空 businessTypes,因为这是用户刚选择的值)
  785. thirdLevelList.value = [];
  786. step2Form.businessTypesList = [];
  787. // 加载三级分类
  788. try {
  789. const res: any = await getThirdLevelList(dictIdStr);
  790. if (res && (res.code === 200 || res.code === "200") && res.data && Array.isArray(res.data) && res.data.length > 0) {
  791. thirdLevelList.value = res.data;
  792. } else {
  793. // 如果没有三级分类数据,确保清空
  794. thirdLevelList.value = [];
  795. }
  796. } catch (error) {
  797. console.error("获取三级分类失败:", error);
  798. // 如果没有三级分类,不显示错误,因为可能该二级分类下没有三级分类
  799. // 确保清空三级分类列表
  800. thirdLevelList.value = [];
  801. }
  802. };
  803. // 经纬度查询
  804. const getLonAndLat = async (keyword: string) => {
  805. if (keyword) {
  806. let param = {
  807. addressName: keyword
  808. };
  809. let res: any = await getInputPrompt(param as any);
  810. if (res.code == "200") {
  811. addressList.value = res?.data?.tips || [];
  812. } else {
  813. ElMessage.error("查询失败!");
  814. }
  815. } else {
  816. addressList.value = [];
  817. }
  818. };
  819. const selectAddress = async (param: any) => {
  820. if (!step2Form.address || typeof step2Form.address !== "string") {
  821. ElMessage.warning("地址格式不正确,请重新选择");
  822. return;
  823. }
  824. if (!step2Form.address.includes(",")) {
  825. ElMessage.warning("地址格式不正确,缺少经纬度信息");
  826. return;
  827. }
  828. let locationList = step2Form.address.split(",");
  829. if (locationList.length < 2) {
  830. ElMessage.warning("地址格式不正确,无法获取经纬度");
  831. return;
  832. }
  833. addressList.value.forEach((item: any) => {
  834. if (item.location == step2Form.address) {
  835. queryAddress.value = item.name;
  836. }
  837. });
  838. step2Form.storePositionLongitude = locationList[0]?.trim() || "";
  839. step2Form.storePositionLatitude = locationList[1]?.trim() || "";
  840. if (!step2Form.storePositionLongitude || !step2Form.storePositionLatitude) {
  841. ElMessage.warning("无法获取有效的经纬度信息");
  842. return;
  843. }
  844. latShow.value = true;
  845. };
  846. //文件上传
  847. const handleHttpUpload = async (options: UploadRequestOptions) => {
  848. let formData = new FormData();
  849. formData.append("file", options.file);
  850. try {
  851. const res: any = await uploadImg(formData);
  852. const fileUrl = res?.data?.fileUrl || res?.data?.[0] || res?.fileUrl;
  853. if (fileUrl) {
  854. options.onSuccess({ fileUrl });
  855. } else {
  856. throw new Error("上传失败:未获取到文件URL");
  857. }
  858. } catch (error) {
  859. options.onError(error as any);
  860. ElMessage.error("文件上传失败,请重试");
  861. }
  862. };
  863. // 自动调用 OCR 识别
  864. const autoOcrRecognition = async (ocrType: string) => {
  865. // 如果正在识别中,不重复调用
  866. if (isOcrProcessing.value) {
  867. return;
  868. }
  869. let imageUrls = "";
  870. let fileList: UploadUserFile[] = [];
  871. // 根据不同的 ocrType 获取对应的图片 URL
  872. if (ocrType === "ID_CARD") {
  873. // 身份证:需要检查正反面是否都已上传完成
  874. if (idCardFrontList.value.length === 0 || idCardBackList.value.length === 0) {
  875. return;
  876. }
  877. const frontFile = idCardFrontList.value[0];
  878. const backFile = idCardBackList.value[0];
  879. // 验证上传的文件是否成功
  880. if (frontFile.status !== "success" || !frontFile.url || backFile.status !== "success" || !backFile.url) {
  881. return;
  882. }
  883. // 获取身份证正反面的 URL
  884. const frontUrl = getFileUrls(idCardFrontList.value)[0] || "";
  885. const backUrl = getFileUrls(idCardBackList.value)[0] || "";
  886. if (!frontUrl || !backUrl) {
  887. return;
  888. }
  889. // 将正反面 URL 用逗号分隔
  890. imageUrls = `${frontUrl},${backUrl}`;
  891. } else if (ocrType === "BUSINESS_LICENSE") {
  892. // 营业执照或娱乐经营许可证:检查是否已上传
  893. // 优先检查营业执照,如果没有再检查娱乐经营许可证
  894. let fileList: UploadUserFile[] = [];
  895. if (step2Form.businessLicenseAddress.length > 0) {
  896. fileList = step2Form.businessLicenseAddress;
  897. } else if (step2Form.disportLicenceImgList.length > 0) {
  898. fileList = step2Form.disportLicenceImgList;
  899. } else {
  900. return;
  901. }
  902. const file = fileList[0];
  903. if (file.status !== "success" || !file.url) {
  904. return;
  905. }
  906. const fileUrl = getFileUrls(fileList)[0] || "";
  907. if (!fileUrl) {
  908. return;
  909. }
  910. imageUrls = fileUrl;
  911. } else if (ocrType === "FOOD_MANAGE_LICENSE") {
  912. // 食品经营许可证:检查是否已上传
  913. if (step2Form.foodLicenceImgList.length === 0) {
  914. return;
  915. }
  916. const file = step2Form.foodLicenceImgList[0];
  917. if (file.status !== "success" || !file.url) {
  918. return;
  919. }
  920. const fileUrl = getFileUrls(step2Form.foodLicenceImgList)[0] || "";
  921. if (!fileUrl) {
  922. return;
  923. }
  924. imageUrls = fileUrl;
  925. } else {
  926. // 其他类型不进行 OCR
  927. return;
  928. }
  929. let params = {
  930. imageUrls: imageUrls,
  931. ocrType: ocrType,
  932. storeId: userInfo.storeId,
  933. storeUserId: userInfo.id
  934. };
  935. try {
  936. isOcrProcessing.value = true;
  937. const res: any = await ocrRequestUrl(params);
  938. if (res && (res.code === 200 || res.code === "200")) {
  939. // 只有身份证类型才需要保存识别结果到 ocrResult
  940. if (ocrType === "ID_CARD" && res.data && Array.isArray(res.data) && res.data.length > 0) {
  941. // 从正面(第一个元素)获取姓名
  942. const frontData = res.data[0]?.face?.data;
  943. // 从反面(第二个元素)获取身份证号,如果没有第二个元素则从正面获取
  944. const backData = res.data[1]?.face?.data || frontData;
  945. // 提取姓名
  946. const name = frontData?.name || "";
  947. // 提取身份证号,优先从反面获取,如果没有则从正面获取
  948. let idCard = backData?.idNumber || frontData?.idNumber || "";
  949. // 如果从 data 中获取不到,尝试从 prism_keyValueInfo 中查找
  950. if (!idCard && res.data[1]?.face?.prism_keyValueInfo) {
  951. const idNumberInfo = res.data[1].face.prism_keyValueInfo.find((item: any) => item.key === "idNumber" && item.value);
  952. if (idNumberInfo) {
  953. idCard = idNumberInfo.value;
  954. }
  955. }
  956. // 如果反面没有,尝试从正面查找
  957. if (!idCard && res.data[0]?.face?.prism_keyValueInfo) {
  958. const idNumberInfo = res.data[0].face.prism_keyValueInfo.find((item: any) => item.key === "idNumber" && item.value);
  959. if (idNumberInfo) {
  960. idCard = idNumberInfo.value;
  961. }
  962. }
  963. ocrResult.value = {
  964. name: name,
  965. idCard: idCard
  966. };
  967. // 更新本地存储中的用户信息
  968. const geekerUser = localGet("geeker-user");
  969. if (geekerUser && geekerUser.userInfo) {
  970. if (ocrResult.value.name) {
  971. geekerUser.userInfo.name = ocrResult.value.name;
  972. }
  973. if (ocrResult.value.idCard) {
  974. geekerUser.userInfo.idCard = ocrResult.value.idCard;
  975. }
  976. localSet("geeker-user", geekerUser);
  977. }
  978. ElMessage.success("身份证识别成功");
  979. } else if (ocrType === "BUSINESS_LICENSE") {
  980. // 判断是营业执照还是娱乐经营许可证
  981. const isBusinessLicense = step2Form.businessLicenseAddress.length > 0;
  982. // 提取 validToDate 字段(娱乐经营许可证)
  983. if (!isBusinessLicense && res.data && Array.isArray(res.data) && res.data.length > 0) {
  984. const validToDate = res.data[0]?.validToDate || "";
  985. if (validToDate) {
  986. entertainmentLicenceExpirationTime.value = formatDate(validToDate);
  987. console.log(entertainmentLicenceExpirationTime.value);
  988. }
  989. }
  990. if (isBusinessLicense) {
  991. ElMessage.success("营业执照识别成功");
  992. } else {
  993. ElMessage.success("娱乐经营许可证识别成功");
  994. }
  995. } else if (ocrType === "FOOD_MANAGE_LICENSE") {
  996. // 提取食品经营许可证的 validToDate 字段
  997. if (res.data && Array.isArray(res.data) && res.data.length > 0) {
  998. const validToDate = res.data[0]?.validToDate || "";
  999. if (validToDate) {
  1000. console.log(formatDate(validToDate));
  1001. foodLicenceExpirationTime.value = formatDate(validToDate);
  1002. console.log(foodLicenceExpirationTime.value);
  1003. }
  1004. }
  1005. ElMessage.success("食品经营许可证识别成功");
  1006. }
  1007. } else {
  1008. console.warn("OCR 识别失败:", res?.msg);
  1009. ElMessage.error(res?.msg || "识别失败,请重试");
  1010. }
  1011. } catch (error) {
  1012. console.error("OCR 识别失败:", error);
  1013. ElMessage.error("识别失败,请重试");
  1014. } finally {
  1015. isOcrProcessing.value = false;
  1016. }
  1017. };
  1018. // 文件上传成功回调
  1019. const handleUploadSuccess = (response: any, uploadFile: UploadUserFile, ocrType: string) => {
  1020. if (response?.fileUrl) {
  1021. uploadFile.url = response.fileUrl;
  1022. }
  1023. // 只有指定的类型才进行 OCR 识别
  1024. if (ocrType && (ocrType === "ID_CARD" || ocrType === "BUSINESS_LICENSE" || ocrType === "FOOD_MANAGE_LICENSE")) {
  1025. // 延迟一下,确保文件状态已更新,然后检查是否需要自动 OCR
  1026. setTimeout(() => {
  1027. autoOcrRecognition(ocrType);
  1028. }, 100);
  1029. }
  1030. };
  1031. // 图片预览处理函数
  1032. const handlePictureCardPreview = (file: UploadUserFile) => {
  1033. if (file.status === "uploading" && file.url) {
  1034. imageViewerUrlList.value = [file.url];
  1035. imageViewerInitialIndex.value = 0;
  1036. imageViewerVisible.value = true;
  1037. return;
  1038. }
  1039. let urlList: string[] = [];
  1040. let currentFileList: UploadUserFile[] = [];
  1041. // 判断是哪个上传组件的文件
  1042. if (idCardFrontList.value.some((f: UploadUserFile) => f.uid === file.uid)) {
  1043. currentFileList = idCardFrontList.value;
  1044. } else if (idCardBackList.value.some((f: UploadUserFile) => f.uid === file.uid)) {
  1045. currentFileList = idCardBackList.value;
  1046. } else if (step2Form.businessLicenseAddress.some((f: UploadUserFile) => f.uid === file.uid)) {
  1047. currentFileList = step2Form.businessLicenseAddress;
  1048. } else if (step2Form.contractImageList.some((f: UploadUserFile) => f.uid === file.uid)) {
  1049. currentFileList = step2Form.contractImageList;
  1050. } else if (step2Form.foodLicenceImgList.some((f: UploadUserFile) => f.uid === file.uid)) {
  1051. currentFileList = step2Form.foodLicenceImgList;
  1052. } else if (step2Form.disportLicenceImgList.some((f: UploadUserFile) => f.uid === file.uid)) {
  1053. currentFileList = step2Form.disportLicenceImgList;
  1054. }
  1055. urlList = currentFileList
  1056. .filter((item: UploadUserFile) => item.status === "success" && (item.url || (item.response as any)?.fileUrl))
  1057. .map((item: UploadUserFile) => item.url || (item.response as any)?.fileUrl);
  1058. const currentUrl = file.url || (file.response as any)?.fileUrl;
  1059. const currentIndex = urlList.findIndex((url: string) => url === currentUrl);
  1060. if (currentIndex < 0) {
  1061. ElMessage.warning("图片尚未上传完成,无法预览");
  1062. return;
  1063. }
  1064. imageViewerUrlList.value = urlList;
  1065. imageViewerInitialIndex.value = currentIndex;
  1066. imageViewerVisible.value = true;
  1067. };
  1068. // 文件移除处理
  1069. const handleRemove = (file: UploadUserFile) => {
  1070. // 文件移除时,清空 OCR 识别结果
  1071. ocrResult.value = {};
  1072. isOcrProcessing.value = false;
  1073. };
  1074. // 提取文件列表中的URL
  1075. const getFileUrls = (fileList: UploadUserFile[]): string[] => {
  1076. return fileList
  1077. .map((file: UploadUserFile) => {
  1078. const response = file.response as any;
  1079. return file.url || response?.fileUrl || "";
  1080. })
  1081. .filter((url: string) => url);
  1082. };
  1083. // 根据adcode获取地区详细信息
  1084. const getDistrictInfo = async (adcode: string) => {
  1085. try {
  1086. const response: any = await getDistrict({ adCode: adcode } as any);
  1087. const district = response?.data?.districts?.[0];
  1088. if (district) {
  1089. return {
  1090. citycode: district.citycode ? [district.citycode] : [],
  1091. adcode: district.adcode,
  1092. level: district.level,
  1093. center: district.center,
  1094. name: district.name,
  1095. districts: []
  1096. };
  1097. }
  1098. } catch (error) {
  1099. console.error("获取地区信息失败:", error);
  1100. }
  1101. return null;
  1102. };
  1103. // 构建whereAddress数组
  1104. const buildWhereAddress = async (regionCodes: string[]) => {
  1105. const whereAddress: any[] = [];
  1106. if (regionCodes && regionCodes.length > 0) {
  1107. for (const code of regionCodes) {
  1108. const districtInfo = await getDistrictInfo(code);
  1109. if (districtInfo) {
  1110. whereAddress.push(districtInfo);
  1111. }
  1112. }
  1113. }
  1114. return whereAddress;
  1115. };
  1116. // 提交
  1117. const handleSubmit = async () => {
  1118. if (!step2FormRef.value) return;
  1119. await step2FormRef.value.validate(async valid => {
  1120. if (valid) {
  1121. const businessLicenseUrls = getFileUrls(step2Form.businessLicenseAddress);
  1122. const contractImageUrls = getFileUrls(step2Form.contractImageList);
  1123. const foodLicenceUrls = getFileUrls(step2Form.foodLicenceImgList);
  1124. const disportLicenceUrls = getFileUrls(step2Form.disportLicenceImgList);
  1125. const whereAddress = await buildWhereAddress(step2Form.region);
  1126. let storeStatus = 1;
  1127. if (step2Form.businessType === "正常营业") {
  1128. storeStatus = 1;
  1129. } else if (step2Form.businessType === "暂停营业") {
  1130. storeStatus = 0;
  1131. } else if (step2Form.businessType === "筹建中") {
  1132. storeStatus = 2;
  1133. }
  1134. const storeAreaNum = typeof step2Form.storeArea === "string" ? parseInt(step2Form.storeArea) : step2Form.storeArea;
  1135. const addressObj = {
  1136. address: queryAddress.value || "",
  1137. longitude: parseFloat(step2Form.storePositionLongitude) || 0,
  1138. latitude: parseFloat(step2Form.storePositionLatitude) || 0
  1139. };
  1140. const storePosition =
  1141. step2Form.storePositionLongitude && step2Form.storePositionLatitude
  1142. ? `${step2Form.storePositionLongitude},${step2Form.storePositionLatitude}`
  1143. : "";
  1144. let fullStoreAddress = "";
  1145. if (whereAddress.length > 0) {
  1146. const provinceName = whereAddress[0]?.name || "";
  1147. const cityName = whereAddress[1]?.name || "";
  1148. const districtName = whereAddress[2]?.name || "";
  1149. fullStoreAddress = `${provinceName}${cityName}${districtName}`;
  1150. }
  1151. // 获取身份证正反面URL
  1152. const idCardFrontUrl = getFileUrls(idCardFrontList.value)[0] || "";
  1153. const idCardBackUrl = getFileUrls(idCardBackList.value)[0] || "";
  1154. // 处理经营种类和三级分类
  1155. // 根据用户需求:如果有三级分类,传经营板块、经营种类(二级分类)、三级分类
  1156. // 如果没有三级分类,传经营板块、经营种类(二级分类)
  1157. let finalBusinessTypes: string[] = [];
  1158. let businessClassifyList: string[] = [];
  1159. if (thirdLevelList.value.length > 0) {
  1160. // 有三级分类
  1161. // businessTypes 存储三级分类的 dictId(字符串)
  1162. if (step2Form.businessTypes) {
  1163. finalBusinessTypes = [step2Form.businessTypes];
  1164. businessClassifyList = [step2Form.businessTypes];
  1165. }
  1166. // 如果有三级分类,还需要传递二级分类(经营种类)
  1167. if (Array.isArray(step2Form.businessSecondLevel) && step2Form.businessSecondLevel.length > 0) {
  1168. // 如果 finalBusinessTypes 为空,使用二级分类
  1169. if (finalBusinessTypes.length === 0) {
  1170. finalBusinessTypes = step2Form.businessSecondLevel;
  1171. }
  1172. }
  1173. } else {
  1174. // 没有三级分类,使用二级分类(经营种类)
  1175. if (Array.isArray(step2Form.businessSecondLevel) && step2Form.businessSecondLevel.length > 0) {
  1176. finalBusinessTypes = step2Form.businessSecondLevel;
  1177. } else if (step2Form.businessTypes) {
  1178. // 如果没有选择二级分类,使用 businessTypes(可能是二级分类的 dictId)
  1179. finalBusinessTypes = [step2Form.businessTypes];
  1180. } else if (step2Form.businessTypesList.length > 0) {
  1181. // 使用旧的逻辑
  1182. finalBusinessTypes = step2Form.businessTypesList;
  1183. }
  1184. // 没有三级分类时,businessClassifyList 保持为空数组
  1185. }
  1186. const params = {
  1187. foodLicenceExpirationTime: foodLicenceExpirationTime.value, //食品经营许可证到期时间
  1188. entertainmentLicenceExpirationTime: entertainmentLicenceExpirationTime.value, //娱乐经营许可证到期时间
  1189. businessClassifyList: step2Form.businessSecondLevel, //三级分类
  1190. mealProvided: step2Form.businessSecondMeal, //是否提供餐食
  1191. entertainmentLicenseAddress: disportLicenceUrls, //娱乐经营许可证
  1192. storeTel: userInfo.phone,
  1193. storeName: step2Form.storeName,
  1194. storeCapacity: step2Form.storeCapacity,
  1195. storeArea: storeAreaNum,
  1196. isChain: step2Form.isChain,
  1197. storeDetailAddress: step2Form.storeDetailAddress,
  1198. storeBlurb: step2Form.storeBlurb,
  1199. businessSection: step2Form.businessSection,
  1200. businessTypesList: finalBusinessTypes,
  1201. storeStatus: storeStatus,
  1202. businessStatus: step2Form.businessStatus,
  1203. address: addressObj,
  1204. businessLicenseAddress: businessLicenseUrls,
  1205. contractImageList: contractImageUrls,
  1206. foodLicenceImgList: foodLicenceUrls,
  1207. disportLicenceUrls: disportLicenceUrls,
  1208. storeAddress: fullStoreAddress,
  1209. whereAddress: whereAddress,
  1210. updatedTime: null,
  1211. queryAddress: queryAddress.value,
  1212. storePosition: storePosition,
  1213. storePositionLatitude: parseFloat(step2Form.storePositionLatitude) || 0,
  1214. storePositionLongitude: parseFloat(step2Form.storePositionLongitude) || 0,
  1215. businessSectionName: step2Form.businessSectionName,
  1216. businessTypes: finalBusinessTypes,
  1217. foodLicenceUrl: foodLicenceUrls.length > 0 ? foodLicenceUrls[0] : "",
  1218. userAccount: userInfo.id,
  1219. administrativeRegionProvinceAdcode: step2Form.administrativeRegionProvinceAdcode,
  1220. administrativeRegionCityAdcode: step2Form.administrativeRegionCityAdcode,
  1221. administrativeRegionDistrictAdcode: step2Form.administrativeRegionDistrictAdcode,
  1222. idCardFrontUrl: idCardFrontUrl,
  1223. idCardBackUrl: idCardBackUrl
  1224. };
  1225. ElMessageBox.confirm("确认提交入驻申请吗?", "提示", {
  1226. confirmButtonText: "确定",
  1227. cancelButtonText: "取消",
  1228. type: "warning"
  1229. })
  1230. .then(async () => {
  1231. try {
  1232. const res: any = await applyStore(params);
  1233. if (res && res.code == 200) {
  1234. storeApplicationStatus.value = 0;
  1235. ElMessage.success(res.msg);
  1236. callGetUserInfo();
  1237. setStep(0);
  1238. } else {
  1239. ElMessage.error(res.msg || "提交失败");
  1240. }
  1241. } catch (error) {
  1242. ElMessage.error("提交失败,请重试");
  1243. }
  1244. })
  1245. .catch(() => {
  1246. // 取消提交
  1247. });
  1248. } else {
  1249. ElMessage.error("请完善表单信息");
  1250. }
  1251. });
  1252. };
  1253. // 文件上传超出限制
  1254. const handleExceed = () => {
  1255. ElMessage.warning("文件数量超出限制");
  1256. };
  1257. </script>
  1258. <style scoped lang="scss">
  1259. // 表单页面样式
  1260. .form-container {
  1261. min-height: calc(100vh - 100px);
  1262. padding: 30px;
  1263. background: #ffffff;
  1264. border-radius: 8px;
  1265. .back-btn {
  1266. margin-bottom: 30px;
  1267. color: #606266;
  1268. border-color: #dcdfe6;
  1269. }
  1270. .progress-container {
  1271. margin-bottom: 40px;
  1272. :deep(.el-step__head.is-process .el-step__icon) {
  1273. color: #909399;
  1274. border-color: #909399 !important;
  1275. }
  1276. :deep(.el-steps) {
  1277. .is-finish {
  1278. .el-step__icon {
  1279. color: #ffffff;
  1280. background-color: #6c8ff8 !important;
  1281. border-color: #6c8ff8 !important;
  1282. }
  1283. }
  1284. .el-step__head {
  1285. .el-step__icon {
  1286. width: 30px;
  1287. height: 30px;
  1288. font-size: 16px;
  1289. font-weight: 600;
  1290. }
  1291. }
  1292. .el-step__title {
  1293. .step-title-wrapper {
  1294. display: flex;
  1295. flex-direction: column;
  1296. gap: 8px;
  1297. align-items: center;
  1298. .step-title {
  1299. font-size: 16px;
  1300. font-weight: 600;
  1301. color: #6c8ff8;
  1302. }
  1303. }
  1304. }
  1305. }
  1306. }
  1307. // 第一步内容样式
  1308. .step1-content {
  1309. .form-content {
  1310. max-width: 800px;
  1311. margin: 0 auto 40px;
  1312. .section-title {
  1313. margin-bottom: 30px;
  1314. font-size: 18px;
  1315. font-weight: 600;
  1316. color: #303133;
  1317. text-align: center;
  1318. }
  1319. .id-card-upload-container {
  1320. display: flex;
  1321. gap: 40px;
  1322. align-items: flex-start;
  1323. justify-content: center;
  1324. :deep(.el-upload-list--picture-card) {
  1325. width: 100%;
  1326. }
  1327. .upload-item {
  1328. flex: 1;
  1329. max-width: 300px;
  1330. .upload-label {
  1331. margin-bottom: 12px;
  1332. font-size: 14px;
  1333. color: #606266;
  1334. text-align: center;
  1335. }
  1336. .id-card-upload {
  1337. width: 100%;
  1338. :deep(.el-upload) {
  1339. position: relative;
  1340. display: flex;
  1341. align-items: center;
  1342. justify-content: center;
  1343. width: 100%;
  1344. height: 200px;
  1345. cursor: pointer;
  1346. background-color: #f5f7fa;
  1347. border: 1px solid #dcdfe6;
  1348. border-radius: 4px;
  1349. transition: all 0.3s;
  1350. &:hover {
  1351. border-color: #6c8ff8;
  1352. }
  1353. }
  1354. // 当上传完成后隐藏上传按钮
  1355. &.upload-complete {
  1356. :deep(.el-upload) {
  1357. display: none !important;
  1358. }
  1359. }
  1360. :deep(.el-upload-list) {
  1361. .el-upload-list__item {
  1362. width: 100%;
  1363. height: 200px;
  1364. margin: 0;
  1365. }
  1366. }
  1367. .upload-placeholder {
  1368. display: flex;
  1369. align-items: center;
  1370. justify-content: center;
  1371. width: 100%;
  1372. height: 100%;
  1373. .placeholder-text {
  1374. font-size: 14px;
  1375. color: #909399;
  1376. }
  1377. }
  1378. }
  1379. }
  1380. }
  1381. // OCR 识别结果展示样式
  1382. .ocr-result-container {
  1383. width: 670px;
  1384. padding: 20px;
  1385. margin: 60px auto;
  1386. .ocr-result-item {
  1387. display: flex;
  1388. align-items: center;
  1389. margin-bottom: 16px;
  1390. font-size: 16px;
  1391. line-height: 1.5;
  1392. &:last-child {
  1393. margin-bottom: 0;
  1394. }
  1395. .label {
  1396. min-width: 100px;
  1397. font-weight: 600;
  1398. color: #606266;
  1399. }
  1400. .value {
  1401. flex: 1;
  1402. color: #303133;
  1403. word-break: break-all;
  1404. }
  1405. }
  1406. .ocr-result-tip {
  1407. padding: 10px 0;
  1408. font-size: 14px;
  1409. color: #909399;
  1410. text-align: center;
  1411. }
  1412. }
  1413. }
  1414. }
  1415. .form-content {
  1416. max-width: 800px;
  1417. margin: 0 auto;
  1418. &.step2-form {
  1419. max-width: 100%;
  1420. .form-row {
  1421. display: flex;
  1422. gap: 40px;
  1423. .form-col {
  1424. flex: 1;
  1425. }
  1426. }
  1427. }
  1428. }
  1429. .form-actions {
  1430. display: flex;
  1431. gap: 20px;
  1432. justify-content: center;
  1433. padding-top: 30px;
  1434. margin-top: 40px;
  1435. border-top: 1px solid #e4e7ed;
  1436. .el-button {
  1437. width: 200px;
  1438. height: 44px;
  1439. font-size: 16px;
  1440. font-weight: 500;
  1441. color: #ffffff;
  1442. background: #6c8ff8;
  1443. border: none;
  1444. border-radius: 4px;
  1445. outline: none;
  1446. }
  1447. }
  1448. }
  1449. </style>