auth.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. data: this.item,
  68. success: (res) => {
  69. this.item = res.data.data;
  70. if (this.item.isAuthentication === 1) {
  71. uni.setNavigationBarTitle({ title: '我的认证' });
  72. }
  73. }
  74. });
  75. },
  76. success(res) {
  77. if (res.side == 'face') {
  78. this.item.name = res.data.name;
  79. this.item.idCard = res.data.num;
  80. this.item.sex = res.data.sex;
  81. this.item.address = res.data.address;
  82. this.item.nationality = res.data.nationality;
  83. this.item.birth = res.data.birth;
  84. } else {
  85. this.item.endDate = res.data.end_date;
  86. }
  87. },
  88. next() {
  89. if (!this.item.name) {
  90. uni.showModal({ content: '请上传身份证人像面', showCancel: false });
  91. return;
  92. }
  93. if (!this.item.endDate) {
  94. uni.showModal({ content: '请上传身份证国徽面', showCancel: false });
  95. return;
  96. }
  97. this.step = 2;
  98. },
  99. save() {
  100. let rule = [
  101. { name: 'name', checkType: 'notnull', errorMsg: '请输入姓名' },
  102. { name: 'idCard', checkType: 'notnull', errorMsg: '请输入身份证' },
  103. { name: 'p1', checkType: 'notnull', errorMsg: '请上传身份证人面像' },
  104. { name: 'p2', checkType: 'notnull', errorMsg: '请上传身份证人徽面' },
  105. { name: 'phone', checkType: 'phone', errorMsg: '请请输入手机号' },
  106. { name: 'alipay', checkType: 'notnull', errorMsg: '请输入支付宝账号' }
  107. ];
  108. if (!this.verify.check(this.item, rule)) {
  109. uni.showModal({ content: this.verify.error, showCancel: false });
  110. return false;
  111. }
  112. this.http.request({
  113. url: '/app/user/auth',
  114. data: this.item,
  115. method: 'POST',
  116. success: (res) => {
  117. uni.showModal({
  118. title: '提示',
  119. content: '实名认证成功。',
  120. showCancel: false,
  121. success: (res) => {
  122. uni.navigateBack();
  123. }
  124. });
  125. }
  126. });
  127. }
  128. }
  129. };
  130. </script>
  131. <style lang="scss">
  132. .bos {
  133. background-color: white;
  134. padding: 20px;
  135. border-radius: 8px;
  136. .item {
  137. font-size: 14px;
  138. padding-top: 7px;
  139. }
  140. .b {
  141. font-weight: bold;
  142. }
  143. }
  144. </style>