stepOne.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div class="f-main">
  3. <div class="content-top">
  4. <p>实名认证{{valid.realName}}</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="page-part">
  22. <div>
  23. <!--<checkbox v-model="checked"></checkbox>-->
  24. <span class="agree">我已阅读并同意 <a href="/common/agreement">《优软云服务条款》</a></span>
  25. </div>
  26. </div>
  27. <div class="page-part">
  28. <mt-button size="large" type="primary" @click="sureAccount('await')">提 交</mt-button>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. name: 'step-one',
  36. data () {
  37. return {
  38. state: {
  39. realName: 'error',
  40. idCard: 'error'
  41. },
  42. valid: {
  43. realName: '',
  44. idCard: ''
  45. }
  46. }
  47. },
  48. methods: {
  49. // 弹窗处理
  50. downToast (type) {
  51. this.$toast({
  52. message: type,
  53. iconClass: 'el-icon-warning'
  54. })
  55. },
  56. // 验证姓名
  57. validateRealName () {
  58. if (!this.valid.realName) {
  59. this.downToast('请先填写您的姓名')
  60. this.state.realName = 'error'
  61. } else {
  62. if (this.valid.realName.length > 20) {
  63. this.downToast('输入长度过长,限定20个字符以内')
  64. this.state.realName = 'warning'
  65. } else {
  66. this.state.realName = 'success'
  67. }
  68. }
  69. },
  70. // 验证身份证
  71. validateIdCard () {
  72. let reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
  73. if (!this.valid.idCard) {
  74. this.downToast('请填写您的身份证号')
  75. this.state.idCard = 'error'
  76. } else {
  77. if (!reg.test(this.valid.idCard)) {
  78. this.downToast('您的身份证有误,请检查')
  79. this.state.idCard = 'warning'
  80. } else {
  81. this.$http.get(`/api/user/idCard/valid`, {params: {idCard: this.valid.idCard}})
  82. .then(response => {
  83. if (!response.data.content.isValid) {
  84. this.state.idCard = 'success'
  85. } else {
  86. this.state.idCard = 'warning'
  87. this.downToast('身份已被认证,请确认。')
  88. }
  89. }).catch((err) => {
  90. this.$indicator.close()
  91. this.downToast(err.errMsg)
  92. })
  93. }
  94. }
  95. },
  96. sureAccount (type) {
  97. if (this.state.realName !== 'success' ||
  98. this.state.idCard !== 'success') {
  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(() => {
  117. this.$indicator.close()
  118. this.downToast('请检查网络是否正常或联系服务商')
  119. })
  120. }
  121. }
  122. }
  123. }
  124. </script>