ソースを参照

完成页面跳转

yuanmingze 3 ヶ月 前
コミット
8527e25560
1 ファイル変更54 行追加29 行削除
  1. 54 29
      src/views/invoice-information/index.vue

+ 54 - 29
src/views/invoice-information/index.vue

@@ -120,20 +120,20 @@
     </div>
 
     <!-- 通用弹窗 -->
-    <ModernDialog
+    <!-- <ModernDialog
       v-model:show="showDialog"
       title="申请成功"
       message="您的开票信息已提交至税务部门审核,审核通过后通知您缴纳税款,请关注缴税信息。"
       confirmText="我知道了"
       @confirm="onConfirm"
-    />
+    /> -->
   </div>
 </template>
 
 <script setup lang="ts">
 import { useRouter } from 'vue-router'
 import { useDebounceFn } from '@/utils/util'
-import ModernDialog from '@/components/ModernDialog.vue'
+// import ModernDialog from '@/components/ModernDialog.vue'
 import {
   getConfirmInvoiceInfoApi,
   getStatusApi,
@@ -142,7 +142,7 @@ import {
 import type { PushRecordIdRequest } from '@/services/modules/invoiceInformation/type.d.ts'
 import { reactive, onMounted, ref } from 'vue'
 import StepProgress from '@/components/StepProgress.vue'
-import { showToast } from 'vant'
+import { showToast, showSuccessToast } from 'vant'
 import { useUserStore } from '@/stores/modules/user'
 
 const userStore = useUserStore()
@@ -155,7 +155,7 @@ const params = reactive<PushRecordIdRequest>({
   pushRecordId: userStore.pushRecordId,
 })
 
-const btnDisabled = ref(false)
+const btnDisabled = ref<boolean>(false)
 const getConfirmInvoiceInfo = async () => {
   try {
     loading.value = true
@@ -168,54 +168,78 @@ const getConfirmInvoiceInfo = async () => {
     // 如果存在错误码,则显示错误信息,且按钮禁用点击
     if (code === 1 && message) {
       showToast(message)
-      // btnDisabled.value = true
+      btnDisabled.value = true
     }
   } finally {
     loading.value = false
   }
 }
 
-const handleNext = useDebounceFn(async () => {
+interface ToStatus {
+  /**
+   * 待处理事件
+   */
+  eventStatus?: string
+  /**
+   * 开票状态
+   */
+  invoiceStatus?: string
+  /**
+   * 是否上传身份证图片
+   */
+  isIdImgReady?: boolean
+  [property: string]: any
+}
+
+const statusMap = ref<ToStatus>({})
+// 已经提交状态
+const isSubmitStausMap = ['PENDING', 'FINISHED']
+const getStatus = async () => {
   const res = await getStatusApi(params)
   if (res.code === 0) {
-    //  res.data.eventStatus === 'PROCESSED' 去人脸识别页面
-    if (res.data.eventStatus === 'PROCESSED') {
-      return router.push({
-        path: '/face-recognition',
-      })
+    statusMap.value = res.data as ToStatus
+    const invoiceStatus = res.data.invoiceStatus
+    if (invoiceStatus && isSubmitStausMap.includes(invoiceStatus)) {
+      btnDisabled.value = true
     }
-    return submitInvoiceApply()
-    // 当前账户没有身份照片,跳转上传证件页面
-    // if (!res.data.isIdImgReady) {
-    //   router.push({
-    //     path: '/identity-upload',
-    //   })
-    // }
   }
+}
+
+const handleNext = useDebounceFn(async () => {
+  // 当eventStatus === PROCESSED 需要人脸认证
+  if (statusMap.value.eventStatus === 'PROCESSED') {
+    return router.push({
+      path: '/face-recognition',
+    })
+  }
+  return submitInvoiceApply()
+  // 当前账户没有身份照片,跳转上传证件页面
+  // if (!res.data.isIdImgReady) {
+  //   router.push({
+  //     path: '/identity-upload',
+  //   })
+  // }
 }, 1000)
 
-const showDialog = ref(false)
 const submitInvoiceApply = async () => {
   try {
     const res = await submitInvoiceApplyApi(params)
     if (res.code === 0 && res.data) {
-      showDialog.value = true
+      showSuccessToast('提交成功')
+      setTimeout(() => {
+        userStore.LogOut()
+        router.replace({
+          path: '/success',
+        })
+      }, 800)
     }
   } catch (err) {
     console.log('err', err)
-
     showToast('提交失败,请稍后重试')
   }
 }
 
 const activeStep = ref(1)
-const onConfirm = () => {
-  showDialog.value = false
-  userStore.LogOut()
-  router.replace({
-    path: '/login',
-  })
-}
 
 const toDetail = () => {
   router.push({
@@ -223,6 +247,7 @@ const toDetail = () => {
   })
 }
 onMounted(() => {
+  getStatus()
   getConfirmInvoiceInfo()
   const authFlag = sessionStorage.getItem('FACE_AUTH_DONE')
   if (authFlag === '1') {