authentication.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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.frontUrl" 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.backUrl" 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. const emit = defineEmits(['complete'])
  55. // 是否已实名
  56. const info = ref({})
  57. const authentication = ref(false)
  58. const CtFormRef = ref()
  59. const query = ref({})
  60. const formItems = ref({
  61. options: [
  62. {
  63. type: 'text',
  64. key: 'name',
  65. value: '',
  66. label: '真实姓名 *',
  67. rules: [v => !!v || '请输入您的真实姓名']
  68. },
  69. {
  70. type: 'text',
  71. key: 'identityNo',
  72. value: '',
  73. label: '身份证号码 *',
  74. rules: [
  75. value => {
  76. if (!value) {
  77. return '请输入您的身份证号码'
  78. }
  79. return true
  80. },
  81. value => {
  82. if (!isValidIdCard18(value)) {
  83. return '请输入正确的身份证号码'
  84. }
  85. return true
  86. }
  87. ]
  88. },
  89. {
  90. key: 'frontUrl',
  91. slotName: 'frontUrl',
  92. value: '',
  93. label: '身份证-人像照 *',
  94. rules: [v => !!v || '请上传']
  95. },
  96. {
  97. slotName: 'backUrl',
  98. key: 'backUrl',
  99. value: '',
  100. label: '身份证-国徽照 *',
  101. rules: [v => !!v || '请上传']
  102. }
  103. ]
  104. })
  105. const getData = async () => {
  106. const data = await getEnterpriseAuth()
  107. emit('complete', { status: Boolean(data?.status === '1'), id: 'authentication' })
  108. if (!data) return authentication.value = false
  109. authentication.value = true
  110. info.value = data
  111. }
  112. getData()
  113. const handleAgain = () => {
  114. formItems.value.options.forEach(item => {
  115. item.value = info.value[item.key]
  116. })
  117. query.value.id = info.value.id
  118. authentication.value = false
  119. }
  120. // 提交实名认证
  121. const handleSave = async () => {
  122. const { valid } = await CtFormRef.value.formRef.validate()
  123. if (!valid) return
  124. formItems.value.options.forEach(item => {
  125. query.value[item.key] = item.value
  126. })
  127. if (!query.value.backUrl || !query.value.frontUrl) return Snackbar.warning('请上传您的身份证照片')
  128. await saveEnterpriseAuth(query.value)
  129. Snackbar.success('提交成功')
  130. query.value = {}
  131. getData()
  132. }
  133. defineExpose({
  134. getData: getData()
  135. })
  136. </script>
  137. <style scoped lang="scss">
  138. .topTip {
  139. background-color: #fff6ec;
  140. color: var(--v-error-base);
  141. padding: 12px 20px;
  142. margin: 10px 0 40px;
  143. font-size: 14px;
  144. }
  145. .box {
  146. background-color: #f7f8fa;
  147. border-radius: 6px;
  148. color: var(--color-666);
  149. font-size: 14px;
  150. padding: 25px;
  151. }
  152. .upload {
  153. width: 120px;
  154. height: 120px;
  155. border: 1px solid #ccc;
  156. border-radius: 4px;
  157. cursor: pointer;
  158. }
  159. </style>