auth.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view>
  3. <view class="tips" v-if="item.isAuthentication === 1">
  4. <text class="icon">&#xe600;</text>
  5. <text>实名认证成功</text>
  6. </view>
  7. <view class="main">
  8. <view v-if="step === 1">
  9. <u-divider text="本人二代身份证"></u-divider>
  10. <view class="r">
  11. <view class="r50">
  12. <ocr v-model="item.p1" text="点击上传人像面" icon="&#xe690;" :read="item.isAuthentication === 1" side="face" @success="success"></ocr>
  13. </view>
  14. <view class="r50">
  15. <ocr v-model="item.p2" text="点击上传国徽面" icon="&#xe61e;" :read="item.isAuthentication === 1" side="back" @success="success"></ocr>
  16. </view>
  17. </view>
  18. </view>
  19. <view v-else>
  20. <view class="form_group">
  21. <view class="lable re">姓名</view>
  22. <input type="text" v-model="item.name" :disabled="true" />
  23. </view>
  24. <view class="form_group">
  25. <view class="lable re">身份证</view>
  26. <input type="text" v-model="item.idCard" :disabled="true" />
  27. </view>
  28. </view>
  29. <view class="bos" v-if="item.isAuthentication === 1">
  30. <view class="item b">姓名:</view>
  31. <view class="item">{{ item.name }}</view>
  32. <view class="item b">身份证:</view>
  33. <view class="item">{{ item.idCard }}</view>
  34. <view class="item b">有效期:</view>
  35. <view class="item">{{ item.endDate }}</view>
  36. </view>
  37. <view v-if="item.isAuthentication === 0">
  38. <view class="bz">
  39. <text class="icon">&#xe634;</text>
  40. <text>为保证用户信息真实可靠,需要实名认证</text>
  41. </view>
  42. <view class="bz">
  43. <text class="icon">&#xe634;</text>
  44. <text>未经您允许不对外提供</text>
  45. </view>
  46. </view>
  47. <button class="btn" @click="next()" v-if="step === 1 && item.isAuthentication != 1">下一步</button>
  48. <button class="btn" @click="save()" v-if="step === 2 && item.isAuthentication != 1">确定</button>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. step: 1,
  57. item: {}
  58. };
  59. },
  60. onLoad() {
  61. this.getData();
  62. },
  63. methods: {
  64. getData() {
  65. this.http.request({
  66. url: '/app/user/info',
  67. success: (res) => {
  68. this.item = res.data.data;
  69. if (this.item.isAuthentication === 1) {
  70. uni.setNavigationBarTitle({ title: '我的认证' });
  71. }
  72. }
  73. });
  74. },
  75. success(res) {
  76. if (res.side == 'face') {
  77. this.item.name = res.data.name;
  78. this.item.idCard = res.data.num;
  79. this.item.sex = res.data.sex;
  80. this.item.address = res.data.address;
  81. this.item.nationality = res.data.nationality;
  82. this.item.birth = res.data.birth;
  83. } else {
  84. this.item.endDate = res.data.end_date;
  85. }
  86. },
  87. next() {
  88. if (!this.item.name) {
  89. uni.showModal({ content: '请上传身份证人像面', showCancel: false });
  90. return;
  91. }
  92. if (!this.item.endDate) {
  93. uni.showModal({ content: '请上传身份证国徽面', showCancel: false });
  94. return;
  95. }
  96. this.step = 2;
  97. },
  98. save() {
  99. let rule = [
  100. { name: 'name', checkType: 'notnull', errorMsg: '请输入姓名' },
  101. { name: 'idCard', checkType: 'notnull', errorMsg: '请输入身份证' },
  102. { name: 'p1', checkType: 'notnull', errorMsg: '请上传身份证人面像' },
  103. { name: 'p2', checkType: 'notnull', errorMsg: '请上传身份证人徽面' }
  104. ];
  105. if (!this.verify.check(this.item, rule)) {
  106. uni.showModal({ content: this.verify.error, showCancel: false });
  107. return false;
  108. }
  109. this.http.request({
  110. url: '/app/user/auth',
  111. data: this.item,
  112. method: 'POST',
  113. success: (res) => {
  114. uni.showModal({
  115. title: '提示',
  116. content: '实名认证成功。',
  117. showCancel: false,
  118. success: (res) => {
  119. uni.navigateBack();
  120. }
  121. });
  122. }
  123. });
  124. }
  125. }
  126. };
  127. </script>
  128. <style lang="scss">
  129. .bos {
  130. background-color: white;
  131. padding: 20px;
  132. border-radius: 8px;
  133. .item {
  134. font-size: 14px;
  135. padding-top: 7px;
  136. }
  137. .b {
  138. font-weight: bold;
  139. }
  140. }
  141. </style>