index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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="&#xe61e;" :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="true" />
  28. </view>
  29. <view class="form_group">
  30. <view class="lable re">身份证</view>
  31. <input type="text" placeholder="请输入身份证" v-model="item.idCard" :disabled="true" />
  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" />
  38. </view>
  39. <view class="form_group">
  40. <view class="lable re">支付宝</view>
  41. <input type="text" placeholder="请输入支付宝账号" v-model="item.alipay" />
  42. </view>
  43. </view>
  44. </view>
  45. <view class="form" v-if="item.isAuthentication === 1" style="margin-top: 10px">
  46. <view class="form_group">
  47. <view class="lable">姓名</view>
  48. <input type="text" v-model="item.name" :disabled="true" />
  49. </view>
  50. <view class="form_group">
  51. <view class="lable">身份证</view>
  52. <input type="text" v-model="item.idCard" :disabled="true" />
  53. </view>
  54. <view class="form_group">
  55. <view class="lable">有效期</view>
  56. <input type="text" v-model="item.endDate" :disabled="true" />
  57. </view>
  58. </view>
  59. <button class="btn" @click="next()" v-if="step === 1 && item.isAuthentication != 1">下一步</button>
  60. <button class="btn" @click="save()" v-if="step === 2 && item.isAuthentication != 1">确定</button>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. export default {
  66. data() {
  67. return {
  68. step: 1,
  69. item: {}
  70. };
  71. },
  72. onLoad() {
  73. this.getData();
  74. },
  75. methods: {
  76. getData() {
  77. this.http.request({
  78. url: '/app/user/info',
  79. data: this.item,
  80. success: (res) => {
  81. this.item = res.data.data;
  82. if (this.item.isAuthentication === 1) {
  83. uni.setNavigationBarTitle({ title: '我的认证' });
  84. }
  85. }
  86. });
  87. },
  88. success(res) {
  89. if (res.side == 'face') {
  90. this.item.name = res.data.name;
  91. this.item.idCard = res.data.num;
  92. this.item.sex = res.data.sex;
  93. this.item.address = res.data.address;
  94. this.item.nationality = res.data.nationality;
  95. this.item.birth = res.data.birth;
  96. } else {
  97. this.item.endDate = res.data.end_date;
  98. }
  99. },
  100. next() {
  101. if (!this.item.name) {
  102. uni.showModal({ content: '请上传身份证人像面', showCancel: false });
  103. return;
  104. }
  105. if (!this.item.endDate) {
  106. uni.showModal({ content: '请上传身份证国徽面', showCancel: false });
  107. return;
  108. }
  109. this.step = 2;
  110. },
  111. save() {
  112. let rule = [
  113. { name: 'name', checkType: 'notnull', errorMsg: '请输入姓名' },
  114. { name: 'idCard', checkType: 'notnull', errorMsg: '请输入身份证' },
  115. { name: 'p1', checkType: 'notnull', errorMsg: '请上传身份证人面像' },
  116. { name: 'p2', checkType: 'notnull', errorMsg: '请上传身份证人徽面' },
  117. { name: 'phone', checkType: 'phone', errorMsg: '请请输入手机号' },
  118. { name: 'alipay', checkType: 'notnull', errorMsg: '请输入支付宝账号' }
  119. ];
  120. if (!this.verify.check(this.item, rule)) {
  121. uni.showModal({ content: this.verify.error, showCancel: false });
  122. return false;
  123. }
  124. this.http.request({
  125. url: '/app/user/auth',
  126. data: this.item,
  127. method: 'POST',
  128. success: (res) => {
  129. uni.showModal({
  130. title: '提示',
  131. content: '实名认证成功。',
  132. showCancel: false,
  133. success: (res) => {
  134. uni.navigateBack();
  135. }
  136. });
  137. }
  138. });
  139. }
  140. }
  141. };
  142. </script>
  143. <style lang="scss">
  144. .btn {
  145. margin-top: 30px;
  146. }
  147. </style>