index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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="tips" v-else>
  8. <text class="icon">&#xe634;</text>
  9. <text>为保障资金安全,用户需进行实名认证,请务必认真填写</text>
  10. </view>
  11. <view class="main">
  12. <view v-if="step === 1">
  13. <u-divider text="本人二代身份证"></u-divider>
  14. <view class="r">
  15. <view class="r50">
  16. <card v-model="item.p1" text="点击拍摄/上传人像面" icon="&#xe690;" :read="item.isAuthentication === 1" side="face" @success="success"></card>
  17. </view>
  18. <view class="r50">
  19. <card v-model="item.p2" text="点击拍摄/上传国徽面" icon="&#xe61f;" :read="item.isAuthentication === 1" side="back" @success="success"></card>
  20. </view>
  21. </view>
  22. </view>
  23. <view v-else>
  24. <view class="form">
  25. <view class="form_group">
  26. <view class="lable re">姓名</view>
  27. <input type="text" placeholder="请输入姓名" v-model="item.name" :disabled="item.isAuthentication === 1" />
  28. </view>
  29. <view class="form_group">
  30. <view class="lable re">身份证</view>
  31. <input type="text" placeholder="请输入身份证" v-model="item.idCard" :disabled="item.isAuthentication === 1" />
  32. </view>
  33. </view>
  34. <view class="form" style="margin-top: 15px">
  35. <view class="form_group">
  36. <view class="lable re">手机号</view>
  37. <input type="text" placeholder="请输入手机号" v-model="item.phone" :disabled="item.isAuthentication === 1" />
  38. </view>
  39. <view class="form_group">
  40. <view class="lable re">支付宝账号</view>
  41. <input type="text" placeholder="请输入支付宝账号" v-model="item.alipay" :disabled="item.isAuthentication === 1" />
  42. </view>
  43. </view>
  44. </view>
  45. <button class="btn" @click="next()" v-if="step === 1">下一步</button>
  46. <button class="btn" @click="save()" v-if="step === 2 && item.isAuthentication != 1">确定</button>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. data() {
  53. return {
  54. step: 1,
  55. item: {}
  56. };
  57. },
  58. onLoad() {
  59. this.getData();
  60. },
  61. methods: {
  62. getData() {
  63. this.http.request({
  64. url: '/app/user/info',
  65. data: this.item,
  66. success: (res) => {
  67. this.item = res.data.data;
  68. }
  69. });
  70. },
  71. success(res) {
  72. if (res.side == 'face') {
  73. this.item.name = res.data.name;
  74. this.item.idCard = res.data.num;
  75. this.item.sex = res.data.sex;
  76. this.item.address = res.data.address;
  77. this.item.nationality = res.data.nationality;
  78. this.item.birth = res.data.birth;
  79. } else {
  80. this.item.endDate = res.data.end_date;
  81. }
  82. },
  83. next() {
  84. if (!this.item.p1 && !this.item.p2) {
  85. uni.showModal({ content: '请先上传证件照', showCancel: false });
  86. return;
  87. }
  88. this.step = 2;
  89. },
  90. save() {
  91. let rule = [
  92. { name: 'name', checkType: 'notnull', errorMsg: '请输入姓名' },
  93. { name: 'idCard', checkType: 'notnull', errorMsg: '请输入身份证' },
  94. { name: 'p1', checkType: 'notnull', errorMsg: '请上传身份证人面像' },
  95. { name: 'p2', checkType: 'notnull', errorMsg: '请上传身份证人徽面' },
  96. { name: 'phone', checkType: 'phone', errorMsg: '请请输入手机号' },
  97. { name: 'alipay', checkType: 'notnull', errorMsg: '请输入支付宝账号' }
  98. ];
  99. if (!this.verify.check(this.item, rule)) {
  100. uni.showModal({ content: this.verify.error, showCancel: false });
  101. return false;
  102. }
  103. this.http.request({
  104. url: '/app/user/auth',
  105. data: this.item,
  106. method: 'POST',
  107. success: (res) => {
  108. uni.showModal({
  109. title: '提示',
  110. content: '实名认证成功。',
  111. showCancel: false,
  112. success: (res) => {
  113. uni.navigateBack();
  114. }
  115. });
  116. }
  117. });
  118. }
  119. }
  120. };
  121. </script>
  122. <style lang="scss">
  123. .btn {
  124. margin-top: 30px;
  125. }
  126. </style>