authentication.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div v-if="authentication" class="ml-3">
  3. <div class="topTip" v-if="info.status === '0'">审核中,请耐心等待</div>
  4. <div v-if="info.status === '1'">
  5. <v-icon color="primary">mdi-check-circle</v-icon>
  6. 已通过实名认证
  7. </div>
  8. <div class="topTip" v-if="info.status === '2'">
  9. 认证已被驳回,原因:{{ info.reason }}
  10. </div>
  11. <div class="box mt-5">
  12. <div>姓名:{{ info.name }}</div>
  13. <div class="my-5">身份证号:{{ maskNumber(info.identityNo) }}</div>
  14. <div class="d-flex" v-if="info.status !== '1'">
  15. <span>国徽照</span>
  16. <div class="ml-10" style="width: 120px; height: 120px;">
  17. <v-img :src="info.backUrl" width="120" height="120" rounded alt=""/>
  18. </div>
  19. </div>
  20. <div class="d-flex mt-5" v-if="info.status !== '1'">
  21. <span>人像照</span>
  22. <div class="ml-10" style="width: 120px; height: 120px;">
  23. <v-img :src="info.frontUrl" width="120" height="120" rounded alt=""/>
  24. </div>
  25. </div>
  26. </div>
  27. <v-btn v-if="info.status === '2'" class="buttons mt-5" color="primary" @click="handleAgain">重新认证</v-btn>
  28. </div>
  29. <div v-else>
  30. <div class="topTip" v-if="info.status !== '2'">为了您在平台有更好的操作体验,请进行实名认证</div>
  31. <div class="d-flex align-center justify-center flex-column mt-5">
  32. <CtForm ref="CtFormRef" :items="formItems" style="width: 300px;">
  33. <template #backUrl="{ item }">
  34. <div class="color-666 font-size-14 mr-5">{{ item.label }}</div>
  35. <Img :value="item.value" @success="val => item.value = val" @delete="item.value = ''"></Img>
  36. </template>
  37. <template #frontUrl="{ item }">
  38. <div class="mt-5 d-flex">
  39. <div class="color-666 font-size-14 mr-5">{{ item.label }}</div>
  40. <Img :value="item.value" @success="val => item.value = val" @delete="item.value = ''"></Img>
  41. </div>
  42. </template>
  43. </CtForm>
  44. <v-btn class="buttons mt-5" color="primary" @click="handleSave">{{ $t('common.submit') }}</v-btn>
  45. </div>
  46. </div>
  47. </template>
  48. <script setup>
  49. defineOptions({ name: 'authentication-page'})
  50. import { ref } from 'vue'
  51. import { isValidIdCard18, maskNumber } from '@/utils/validate'
  52. import { getEnterpriseAuth, saveEnterpriseAuth } from '@/api/recruit/enterprise/information'
  53. import Snackbar from '@/plugins/snackbar'
  54. // 是否已实名
  55. const info = ref({})
  56. const authentication = ref(false)
  57. const CtFormRef = ref()
  58. const query = ref({})
  59. const formItems = ref({
  60. options: [
  61. {
  62. type: 'text',
  63. key: 'name',
  64. value: '',
  65. label: '真实姓名 *',
  66. rules: [v => !!v || '请输入您的真实姓名']
  67. },
  68. {
  69. type: 'text',
  70. key: 'identityNo',
  71. value: '',
  72. label: '身份证号码 *',
  73. rules: [
  74. value => {
  75. if (!value) {
  76. return '请输入您的身份证号码'
  77. }
  78. return true
  79. },
  80. value => {
  81. if (!isValidIdCard18(value)) {
  82. return '请输入正确的身份证号码'
  83. }
  84. return true
  85. }
  86. ]
  87. },
  88. {
  89. slotName: 'backUrl',
  90. key: 'backUrl',
  91. value: '',
  92. label: '身份证-国徽照 *',
  93. rules: [v => !!v || '请上传']
  94. },
  95. {
  96. key: 'frontUrl',
  97. slotName: 'frontUrl',
  98. value: '',
  99. label: '身份证-人像照 *',
  100. rules: [v => !!v || '请上传']
  101. }
  102. ]
  103. })
  104. const getData = async () => {
  105. const data = await getEnterpriseAuth()
  106. if (!data) return authentication.value = false
  107. authentication.value = true
  108. info.value = data
  109. }
  110. getData()
  111. const handleAgain = () => {
  112. formItems.value.options.forEach(item => {
  113. item.value = info.value[item.key]
  114. })
  115. query.value.id = info.value.id
  116. authentication.value = false
  117. }
  118. // 提交实名认证
  119. const handleSave = async () => {
  120. const { valid } = await CtFormRef.value.formRef.validate()
  121. if (!valid) return
  122. formItems.value.options.forEach(item => {
  123. query.value[item.key] = item.value
  124. })
  125. if (!query.value.backUrl || !query.value.frontUrl) return Snackbar.warning('请上传您的身份证照片')
  126. await saveEnterpriseAuth(query.value)
  127. Snackbar.success('提交成功')
  128. query.value = {}
  129. getData()
  130. }
  131. </script>
  132. <style scoped lang="scss">
  133. .topTip {
  134. background-color: #fff6ec;
  135. color: var(--v-error-base);
  136. padding: 12px 20px;
  137. margin: 10px 0 40px;
  138. font-size: 14px;
  139. }
  140. .box {
  141. background-color: #f7f8fa;
  142. border-radius: 6px;
  143. color: var(--color-666);
  144. font-size: 14px;
  145. padding: 25px;
  146. }
  147. .upload {
  148. width: 120px;
  149. height: 120px;
  150. border: 1px solid #ccc;
  151. border-radius: 4px;
  152. cursor: pointer;
  153. }
  154. </style>