Index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <app-view class="g-form account-certification">
  3. <template #header>
  4. <app-navbar title="实名认证" />
  5. </template>
  6. <Form ref="formRef" class="g-form__container" @submit="onCheckCardNum" :loading="loading">
  7. <CellGroup inset>
  8. <Field v-model="formData.username" name="username" label="姓名" placeholder="请输入用户姓名"
  9. :rules="formRules.username" :readonly="isReadonly" />
  10. <Field v-model="formData.mobile" name="mobile" readonly label="手机号码" />
  11. <Field name="idCardType" label="证件类型" :rules="formRules.cardtype" is-link>
  12. <template #input>
  13. <app-select v-model="formData.cardtype" placeholder="请选择证件类型" :options="getCerTypePersonList()"
  14. :readonly="isReadonly" />
  15. </template>
  16. </Field>
  17. <Field v-model="formData.cardnum" name="cardnum" label="证件号码" placeholder="请输入证件号码"
  18. :rules="formRules.cardnum" :readonly="isReadonly" />
  19. <Field name="cardfrontphotourl" label="证件正面照片" :rules="formRules.cardfrontphotourl">
  20. <template #input>
  21. <Image fit="contain" :src="getFileUrl(formData.cardfrontphotourl)" width="100" height="100"
  22. v-if="isReadonly" />
  23. <app-uploader @success="f_afterRead" v-else />
  24. </template>
  25. </Field>
  26. <Field name="cardbackphotourl" v-if="showCardBackPhoto === '1'" label="证件反面照片" :rules="formRules.cardbackphotourl">
  27. <template #input>
  28. <Image fit="contain" :src="getFileUrl(formData.cardbackphotourl)" width="100" height="100"
  29. v-if="isReadonly" />
  30. <app-uploader @success="b_afterRead" v-else />
  31. </template>
  32. </Field>
  33. <Field name="halfbodyphotourl" v-if="showHalfBodyPhoto === '1'" :label="halfBodyPhotoTitle" :rules="formRules.halfbodyphotourl">
  34. <template #input>
  35. <Image fit="contain" :src="getFileUrl(formData.halfbodyphotourl)" width="100" height="100"
  36. v-if="isReadonly" />
  37. <app-uploader @success="h_afterRead" v-else />
  38. </template>
  39. </Field>
  40. </CellGroup>
  41. </Form>
  42. <img src="../../../assets/images/certification.png" />
  43. <template #footer>
  44. <div class="g-form__footer inset">
  45. <Button type="danger" :loading="buttonLoading" @click="formRef?.submit" round block>提交实名认证</Button>
  46. </div>
  47. </template>
  48. </app-view>
  49. </template>
  50. <script lang="ts" setup>
  51. import { shallowRef, onMounted } from 'vue'
  52. import { CellGroup, Button, Field, Form, FormInstance, showFailToast, FieldRule, Image } from 'vant'
  53. import { fullloading, dialog } from '@/utils/vant';
  54. import { getFileUrl, getIdCardAge } from '@/filters';
  55. import { getCerTypePersonList } from "@/constants/account"
  56. import { useRequest } from '@/hooks/request'
  57. import { queryTencentUsereSignRecords, requestCheckCardNum } from '@/services/api/account';
  58. import { addAuthReq } from '@/business/user/account';
  59. import { validateRules } from '@/constants/regex';
  60. import { useUserStore } from '@/stores'
  61. import { useNavigation } from '@mobile/router/navigation'
  62. import { getWskhOpenAccountConfigs } from '@/services/api/account'
  63. import { getUserId, getMemberUserId } from '@/services/methods/user'
  64. import AppSelect from '@mobile/components/base/select/index.vue'
  65. import AppUploader from '@mobile/components/base/uploader/index.vue'
  66. const { router } = useNavigation()
  67. const userStore = useUserStore()
  68. const formRef = shallowRef<FormInstance>()
  69. const { formData, formSubmit, loading } = addAuthReq()
  70. const showHalfBodyPhoto = shallowRef('0')
  71. const showCardBackPhoto = shallowRef('0')
  72. const halfBodyPhotoTitle = shallowRef('手持证件照')
  73. // 获取网上开户配置
  74. useRequest(getWskhOpenAccountConfigs, {
  75. params: {
  76. configs: '53,54,78'
  77. },
  78. onSuccess: (res) => {
  79. /// 是否显示半身照和 证件背面照
  80. showCardBackPhoto.value = res.data.filter(e => e.configid === 53)[0].configvalue ?? '0'
  81. showHalfBodyPhoto.value = res.data.filter(e => e.configid === 54)[0].configvalue ?? '0'
  82. halfBodyPhotoTitle.value = res.data.filter(e => e.configid === 78)[0].configvalue ?? '手持证件照'
  83. }
  84. })
  85. const isReadonly = false//computed(() => userESignRecords.value.some((e) => e.recordstatus === 3))
  86. /// 查询记录
  87. const { loading: buttonLoading } = useRequest(queryTencentUsereSignRecords, {
  88. params: {
  89. userId: getUserId(),
  90. memberUserId: getMemberUserId()
  91. },
  92. onError: (err) => {
  93. showFailToast(err)
  94. }
  95. })
  96. const b_afterRead = (filePath: string) => {
  97. formData.cardbackphotourl = filePath
  98. }
  99. const f_afterRead = (filePath: string) => {
  100. formData.cardfrontphotourl = filePath
  101. }
  102. const h_afterRead = (filePath: string) => {
  103. formData.halfbodyphotourl = filePath
  104. }
  105. // 表单验证规则
  106. const formRules: { [key in keyof Model.AddAuthReq]?: FieldRule[] } = {
  107. username: [{
  108. required: true,
  109. message: '请输入用户姓名',
  110. }],
  111. mobile: [{
  112. required: true,
  113. message: '请输入手机号码',
  114. validator: (val) => {
  115. if (validateRules.phone.validate(val)) {
  116. return true
  117. }
  118. return validateRules.phone.message
  119. }
  120. }],
  121. cardnum: [{
  122. required: true,
  123. message: '请输入证件号码',
  124. validator: (val) => {
  125. if (formData.cardtype != 0) {
  126. return true
  127. } else {
  128. if (validateRules.cardno.validate(val)) {
  129. if (getIdCardAge(val)) {
  130. return '开户失败,您的年龄不符合开户要求'
  131. }
  132. return true
  133. }
  134. return validateRules.cardno.message
  135. }
  136. }
  137. }],
  138. cardbackphotourl: [{
  139. required: true,
  140. message: '请上传证件反面照片',
  141. }],
  142. cardfrontphotourl: [{
  143. required: true,
  144. message: '请上传证件正面照片',
  145. }],
  146. halfbodyphotourl: [{
  147. required: true,
  148. message: '请上传'+halfBodyPhotoTitle.value,
  149. }],
  150. }
  151. const onCheckCardNum = () => {
  152. fullloading((hideLoading) => {
  153. requestCheckCardNum({
  154. data: {
  155. cardnum: formData.cardnum
  156. }
  157. }).then(() => {
  158. formSubmit().then((res) => {
  159. if (res.code.toString() !== '0') {
  160. showFailToast(res.message)
  161. } else {
  162. hideLoading()
  163. dialog('提交请求成功,请耐心等待审核!').then(() => {
  164. router.back()
  165. })
  166. }
  167. }).catch((err) => {
  168. formData.cardnum = ''
  169. hideLoading(err, 'fail')
  170. })
  171. }).catch((err) => {
  172. hideLoading(err, 'fail')
  173. })
  174. })
  175. }
  176. onMounted(() => {
  177. formData.mobile = userStore.userInfo?.mobile2 ?? ''
  178. })
  179. </script>