stepOne.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div class="f-main">
  3. <div class="content-top">
  4. <p>实名认证</p>
  5. </div>
  6. <div class="f-form">
  7. <div class="page-part">
  8. <mt-field placeholder="真实姓名"
  9. v-model="valid.realName"
  10. :state="state.realName"
  11. @blur.native.capture="validateRealName"
  12. ></mt-field>
  13. </div>
  14. <div class="page-part">
  15. <mt-field placeholder="身份证号"
  16. v-model="valid.idCard"
  17. :state="state.idCard"
  18. @blur.native.capture="validateIdCard"
  19. ></mt-field>
  20. </div>
  21. <div class="form-btn">
  22. <div class="page-part">
  23. <el-checkbox v-model="checked">我已阅读并同意 <a href="/common/agreement" class="rgba">《优软云服务条款》</a></el-checkbox>
  24. </div>
  25. <mt-button size="large" type="primary" @click="sureAccount('await')">提 交</mt-button>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. export default {
  32. name: 'step-one',
  33. data () {
  34. return {
  35. state: {
  36. realName: 'error',
  37. idCard: 'error'
  38. },
  39. valid: {
  40. realName: '',
  41. idCard: ''
  42. },
  43. checked: true
  44. }
  45. },
  46. methods: {
  47. // 弹窗处理
  48. downToast (type) {
  49. this.$toast({
  50. message: type,
  51. iconClass: 'el-icon-warning'
  52. })
  53. },
  54. // 验证姓名
  55. validateRealName () {
  56. if (!this.valid.realName) {
  57. this.downToast('请先填写您的姓名')
  58. this.state.realName = 'error'
  59. } else {
  60. if (this.valid.realName.length > 20) {
  61. this.downToast('输入长度过长,限定20个字符以内')
  62. this.state.realName = 'warning'
  63. } else {
  64. this.state.realName = 'success'
  65. }
  66. }
  67. },
  68. // 验证身份证
  69. validateIdCard () {
  70. let reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
  71. if (!this.valid.idCard) {
  72. this.downToast('请填写您的身份证号')
  73. this.state.idCard = 'error'
  74. } else {
  75. if (!reg.test(this.valid.idCard)) {
  76. this.downToast('您的身份证有误,请检查')
  77. this.state.idCard = 'warning'
  78. } else {
  79. this.$http.get(`/api/user/idCard/valid`, {params: {idCard: this.valid.idCard}})
  80. .then(response => {
  81. if (!response.data.content.isValid) {
  82. this.state.idCard = 'success'
  83. } else {
  84. this.state.idCard = 'warning'
  85. this.downToast('身份已被认证,请确认。')
  86. }
  87. }).catch((err) => {
  88. this.$indicator.close()
  89. this.downToast(err.errMsg)
  90. })
  91. }
  92. }
  93. },
  94. sureAccount (type) {
  95. if (this.state.realName !== 'success' ||
  96. this.state.idCard !== 'success') {
  97. this.downToast('请确认填写部分是否有误')
  98. } else if (!this.checked) {
  99. this.downToast('您对阅读条款未做勾选')
  100. } else {
  101. this.$indicator.open('验证过程中...')
  102. let param = new FormData()
  103. param.append('realName', this.valid.realName)
  104. param.append('idCard', this.valid.idCard)
  105. let config = {
  106. headers: {'Content-Type': 'multipart/form-data'}
  107. }
  108. this.$http.post('/valid/user/identity/submit', param, config)
  109. .then(response => {
  110. this.$indicator.close()
  111. if (response.data.success) {
  112. this.$emit('stepEvent', type)
  113. } else {
  114. this.downToast(response.data.errMsg)
  115. }
  116. }).catch((err) => {
  117. this.$indicator.close()
  118. this.downToast(err.errMsg)
  119. })
  120. }
  121. }
  122. }
  123. }
  124. </script>