auth-identity.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="auth-identity">
  3. <custom-nav noback="noback" transparent="transparent" ref="ltm" title=" " />
  4. <view class="content">
  5. <view class="app-item item">
  6. <text>分享人</text>
  7. <text>{{ userinfo.recom_nickname }}</text>
  8. </view>
  9. <view class="app-item item">
  10. <text>联系方式</text>
  11. <text>{{ userinfo.recom_mobile }}</text>
  12. </view>
  13. <view class="app-item item item-space">
  14. <text>手机区号</text>
  15. <input v-model="area_name" disabled />
  16. </view>
  17. <view class="app-item item ">
  18. <text>联系方式</text>
  19. <input v-model="userinfo.mobile" disabled />
  20. </view>
  21. <view class="app-item item">
  22. <text>微信昵称</text>
  23. <input v-model="wx_nickname" placeholder="请填写微信昵称" />
  24. </view>
  25. <view class="app-item item">
  26. <text>真实姓名</text>
  27. <input v-model="real_name" maxlength="32" placeholder="请填写真实姓名" />
  28. </view>
  29. <view class="app-item item">
  30. <text>身份证号</text>
  31. <input @input="inputChange" v-model="id_card_num" maxlength="18" placeholder="请填写身份证号" />
  32. </view>
  33. <view class="btn_box">
  34. <button class="big-btn bg" @tap="submit">提交</button>
  35. <button class="big-btn bg" @click="toback">退出</button>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. _API_Logout
  43. } from '@/apis/verify.js'
  44. import {
  45. _API_SubAuthInfo
  46. } from '@/apis/user.js'
  47. export default {
  48. data() {
  49. return {
  50. title: '身份认证',
  51. wx_nickname: '',
  52. real_name: '',
  53. id_card_num: '',
  54. isMatch: '', //身份验证
  55. area_name: '',
  56. code: '' //手机区号
  57. }
  58. },
  59. computed: {
  60. userinfo() {
  61. return this.$store.state.userinfo
  62. }
  63. },
  64. onLoad() {
  65. this.getCode()
  66. },
  67. methods: {
  68. inputChange() {
  69. this.id_card_num = this.id_card_num.trim()
  70. },
  71. toback() {
  72. uni.showLoading({
  73. mask: true
  74. })
  75. _API_Logout().then(() => {
  76. this.$store.commit('app/LOGOUT')
  77. uni.navigateBack()
  78. window.history.replaceState({}, '', '/api/gzh')
  79. location.reload()
  80. })
  81. },
  82. getCodeInfo(code) {
  83. let areaInfo = {
  84. isMatch: '',
  85. area_name: ''
  86. }
  87. if (code === 86) {
  88. areaInfo.isMatch =
  89. /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
  90. areaInfo.area_name = `中国大陆(+86)`
  91. } else if (code === 853) { //澳门
  92. areaInfo.isMatch = /^[1|5|7][0-9]{6}[0-9A-Z]$/
  93. areaInfo.area_name = `澳门(+853)`
  94. } else if (code === 886) { //台湾
  95. areaInfo.isMatch = /^[a-zA-Z][0-9]{9}$/
  96. areaInfo.area_name = `台湾(+866)`
  97. } else if (code === 852) { //香港
  98. areaInfo.isMatch = /^[A-Z]{1,2}[0-9]{6,10}[0-9A-Z]$/
  99. areaInfo.area_name = `香港(+852)`
  100. }
  101. return areaInfo
  102. },
  103. getCode() {
  104. var code = this.userinfo.area_code
  105. if (code) {
  106. let index = code.indexOf('+')
  107. code = code.substring(index + 1)
  108. this.isMatch = this.getCodeInfo(Number(code)).isMatch
  109. this.area_name = this.getCodeInfo(Number(code)).area_name
  110. }
  111. },
  112. submit() { // 点击提交
  113. if (!this.wx_nickname.length) {
  114. uni.toast('微信昵称不能为空')
  115. return
  116. }
  117. if (!this.real_name.match(/^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/)) {
  118. uni.toast('真实姓名不符合要求')
  119. return
  120. }
  121. if (this.isMatch && !this.id_card_num.match(this.isMatch)) {
  122. uni.toast('身份号码不合法')
  123. return
  124. }
  125. uni.showLoading({
  126. mask: true
  127. }) // 显示 loading
  128. _API_SubAuthInfo({ // 提交信息
  129. wechatname: this.wx_nickname,
  130. realname: this.real_name,
  131. cre_num: this.id_card_num
  132. }).then(res => {
  133. if (res.code === 200) { // 提交成功
  134. this.$store.commit('userinfo/UPDATA_USERINFO', {
  135. cert_status: 1
  136. })
  137. uni.redirectTo({
  138. url: '../auth-progress/auth-progress'
  139. }) // redirect 到 审核进度页面
  140. } else if (res.code === 300) {
  141. uni.showToast({
  142. duration: 3333,
  143. title: res.message
  144. })
  145. }
  146. })
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss">
  152. .auth-identity {
  153. @include page();
  154. .content {}
  155. }
  156. .btn_box {
  157. display: flex;
  158. justify-content: space-between;
  159. align-items: center;
  160. .big-btn {
  161. width: 40%;
  162. &:nth-last-of-type(1) {
  163. background-color: #007AFF;
  164. border-color: #007AFF;
  165. }
  166. }
  167. }
  168. </style>