|
|
@@ -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)
|