index.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <div class="loading-page" role="status" aria-live="polite" aria-label="页面加载中">
  3. <!-- 顶部导航 -->
  4. <van-nav-bar title="加载中" fixed :border="false" safe-area-inset-top class="nav" />
  5. <!-- 中心区域(带淡淡的高光背景,不是卡片) -->
  6. <div class="loading-body">
  7. <div>
  8. <van-loading type="circular" vertical :size="loadingSize" :color="loadingColor">
  9. 加载中…
  10. </van-loading>
  11. </div>
  12. </div>
  13. </div>
  14. </template>
  15. <script setup lang="ts">
  16. import { getFaceAuthResultApi } from '@/services/modules/faceRecognition'
  17. import type { PushRecordIdRequest } from '@/services/modules/invoiceInformation/type.d.ts'
  18. import { reactive, onMounted } from 'vue'
  19. import { useUserStore } from '@/stores/modules/user'
  20. import { showToast } from 'vant'
  21. import { useInvoice } from '@/hooks/useInvoice'
  22. import { useRouter } from 'vue-router'
  23. const userStore = useUserStore()
  24. const router = useRouter()
  25. // --- 初始化 Hooks ---
  26. const { submitInvoiceApply } = useInvoice()
  27. const loadingSize = '10vw'
  28. const loadingColor = '#1677ff'
  29. const params = reactive<PushRecordIdRequest>({
  30. pushRecordId: userStore.pushRecordId,
  31. })
  32. // 获取认证结果
  33. const getFaceAuthResult = async () => {
  34. try {
  35. const res = await getFaceAuthResultApi(params)
  36. if (res.code === 0 && res.data?.success) {
  37. const rzzt = res.data.rzzt
  38. // 已认证或无需认证提交跳转
  39. if (rzzt === 'NO_REQUIRED_AUTHENTICATION') {
  40. submitInvoiceApply()
  41. } else {
  42. // 认证失败重定向到发票信息页面
  43. router.replace({
  44. path: '/invoice-information',
  45. })
  46. }
  47. } else {
  48. showToast('认证失败,请刷新页面后重试')
  49. }
  50. } catch (err) {
  51. console.error('获取认证结果失败', err)
  52. showToast('网络错误,请稍后重试')
  53. }
  54. }
  55. onMounted(() => {
  56. getFaceAuthResult()
  57. })
  58. </script>
  59. <style scoped>
  60. /* 基于 375 设计稿的 vw 适配 */
  61. html {
  62. font-size: calc(100vw / 3.75);
  63. }
  64. .loading-page {
  65. width: 100vw;
  66. height: 100vh;
  67. background: #f6f7fb; /* 整页浅灰底,非卡片 */
  68. display: flex;
  69. flex-direction: column;
  70. overflow: hidden;
  71. }
  72. /* 顶部导航固定 */
  73. .nav {
  74. position: fixed;
  75. top: 0;
  76. width: 100vw;
  77. }
  78. /* 居中容器 */
  79. .loading-body {
  80. flex: 1;
  81. display: flex;
  82. align-items: center;
  83. justify-content: center;
  84. padding-top: 14vw; /* 预留固定导航空间 */
  85. }
  86. </style>