Ver código fonte

新增h5更新

yuanmingze 3 meses atrás
pai
commit
817d0c080d

+ 8 - 1
src/services/modules/identityUpload/index.ts

@@ -1,6 +1,6 @@
 import http from '../../index'
 
-import type { OcrRequest } from './type.d'
+import type { OcrRequest, UpdateH5IdcardInfoRequest } from './type.d'
 export const ocrApi = (data: OcrRequest) => {
   const formData = new FormData()
   formData.append('file', data.file)
@@ -10,3 +10,10 @@ export const ocrApi = (data: OcrRequest) => {
     data: formData,
   })
 }
+
+export const updateH5IdcardInfo = (data: UpdateH5IdcardInfoRequest) => {
+  return http.post({
+    url: '/admin/invoice-order/update-h5-idcard-info',
+    data: data,
+  })
+}

+ 33 - 0
src/services/modules/identityUpload/type.d.ts

@@ -6,3 +6,36 @@ export interface OcrRequest {
   side: 'front' | 'back'
   [key: string]: any
 }
+
+/**
+ * 参数
+ *
+ * OnUpdateH5IdCardInfo
+ */
+export interface UpdateH5IdcardInfoRequest {
+  /**
+   * 身份证号
+   */
+  idCard: string
+  /**
+   * 身份证反面
+   */
+  idCardBackImg: string
+  /**
+   * 身份证正面
+   */
+  idCardFrontImg: string
+  /**
+   * 身份证有效期结束时间
+   */
+  idcardPeriodEnd: string
+  /**
+   * 身份证有效期开始时间
+   */
+  idcardPeriodStart: string
+  /**
+   * 推送记录id
+   */
+  pushRecordId: string
+  [property: string]: any
+}

+ 19 - 11
src/views/identity-upload/index.vue

@@ -62,17 +62,19 @@
 import { ref, computed, reactive, onMounted } from 'vue'
 import { showToast, showFailToast } from 'vant'
 import { sysFileUploadApi } from '@/services/modules/common'
-import { ocrApi } from '@/services/modules/identityUpload/index'
+import { ocrApi, updateH5IdcardInfo } from '@/services/modules/identityUpload/index'
 import { useDebounceFn } from '@/utils/util'
 import { useRouter } from 'vue-router'
 /** 背景图 */
 import frontBg from '@/assets/images/id-front-bg.png'
 import backBg from '@/assets/images/id-back-bg.png'
+import { useUserStore } from '@/stores/modules/user'
 // ✅ 使用封装好的 Hook
 import { useInvoice } from '@/hooks/useInvoice'
+import type { UpdateH5IdcardInfoRequest } from '@/services/modules/identityUpload/type.d'
 // --- 初始化 Hooks ---
 const { getStatus, submitInvoiceApply, statusMap } = useInvoice()
-
+const userStore = useUserStore()
 /** 上传项类型 */
 interface UploadFileItem {
   url?: string
@@ -149,7 +151,6 @@ const handleOcrCheck = async (side: 'front' | 'back', file: File) => {
         submitInfo.idcardPeriodEnd = res.data.end
         submitInfo.idCardBackImg = res.data.imgUrl
       }
-      console.log('submitInfo', submitInfo)
 
       return { success: true }
     }
@@ -159,8 +160,8 @@ const handleOcrCheck = async (side: 'front' | 'back', file: File) => {
     return { success: false }
   }
 }
-const submitInfo = reactive({
-  id: '',
+const submitInfo = reactive<UpdateH5IdcardInfoRequest>({
+  pushRecordId: userStore.pushRecordId,
   idCard: '',
   idcardPeriodStart: '',
   idcardPeriodEnd: '',
@@ -179,13 +180,20 @@ const isReady = computed(() => {
 const handleNext = async () => {
   if (!isReady.value) return showToast('请先上传身份证正反面')
 
-  // 需要人脸识别->跳转人脸识别
-  if (statusMap.value.eventStatus === 'PROCESSED') {
-    return router.push({ path: '/face-recognition' })
+  try {
+    const res = await updateH5IdcardInfo(submitInfo)
+    if (res.code === 0) {
+      // 需要人脸识别->跳转人脸识别
+      if (statusMap.value.eventStatus === 'PROCESSED') {
+        return router.push({ path: '/face-recognition' })
+      }
+      // 其他情况,直接提交
+      await submitInvoiceApply()
+    }
+  } catch (err: any) {
+    const { message } = err
+    showToast(message)
   }
-
-  // 其他情况,直接提交
-  await submitInvoiceApply()
 }
 /** 防抖包装 */
 const handleNextDebounced = useDebounceFn(handleNext, 1000)