approve.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <view class="content">
  3. <view class="bgimg"><image class="img" src="../../static/img/bgRz.png" mode="widthFix"></image></view>
  4. <u-form class="user" :model="form" ref="uForm">
  5. <u-form-item label="姓名"><u-input v-model="form.name" placeholder="请输入真实姓名" /></u-form-item>
  6. <u-form-item label="身份证号" label-width="150"><u-input placeholder="请输入身份证号" v-model="form.card" /></u-form-item>
  7. </u-form>
  8. <view class="userBox">
  9. <view class="title">上传人脸正面照片</view>
  10. <view class="imgUp" @click.stop="upImg"><image class="img" :src="form.img || '../../static/img/upImgbg.png'" mode="scaleToFill"></image></view>
  11. </view>
  12. <button class="add-btn" @click="pushData('add')">提交</button>
  13. </view>
  14. </template>
  15. <script>
  16. import { realName } from '@/api/set.js';
  17. export default {
  18. data() {
  19. return {
  20. loding: false, //判断是否在点击中
  21. form: {
  22. name: '',
  23. card: '',
  24. img: ''
  25. }
  26. };
  27. },
  28. onLoad(option) {},
  29. methods: {
  30. upImg(e) {
  31. console.log('上传图片');
  32. const that = this;
  33. uni.navigateTo({
  34. url: '/pages/set/cropper',
  35. events: {
  36. imgCropped(event) {
  37. // 监听裁剪完成
  38. // 返回的 event 中包含了已经裁剪好图片的base64编码字符串
  39. // 你可以使用 <image :src="imgDataUrl" mode="aspectFit"></image> 组件来展示裁剪后的图片
  40. // 或者你可以将该字符串通过接口上传给服务器用来保存
  41. that.$nextTick(function() {
  42. that.form.img = event.data;
  43. console.log(that.form.img, '图片');
  44. });
  45. }
  46. },
  47. fail(e) {
  48. console.log(e, '错误');
  49. }
  50. });
  51. },
  52. ToIndex() {
  53. let obj = this;
  54. let ur = uni.getStorageSync('present') || '/pages/index/index';
  55. // 用于处理缓存bug
  56. if (ur == 'pages/product/product') {
  57. ur = '/pages/index/index';
  58. }
  59. uni.switchTab({
  60. url: ur,
  61. fail(e) {
  62. uni.navigateTo({
  63. url: ur,
  64. fail(e) {
  65. uni.navigateTo({
  66. url: '/pages/index/index'
  67. });
  68. }
  69. });
  70. }
  71. });
  72. },
  73. pushData() {
  74. const da = this.form;
  75. if (this.loding) {
  76. return;
  77. }
  78. if (!da.name) {
  79. uni.showModal({
  80. title: '提示',
  81. content: '请填写名称',
  82. showCancel: false
  83. });
  84. return;
  85. }
  86. if (!da.card) {
  87. uni.showModal({
  88. title: '提示',
  89. content: '请填写身份证',
  90. showCancel: false
  91. });
  92. return;
  93. }
  94. if (!da.img) {
  95. uni.showModal({
  96. title: '提示',
  97. content: '请选择图片',
  98. showCancel: false
  99. });
  100. return;
  101. }
  102. const data = {
  103. face_image: da.img.replace(/^data:image\/[a-z,A-Z]*;base64,/, ''),
  104. real_name: da.name,
  105. id_card: da.card
  106. };
  107. uni.showLoading({
  108. title: '审核中',
  109. mask: true
  110. });
  111. this.loding = true;
  112. // 上传
  113. realName(data)
  114. .then(e => {
  115. uni.showModal({
  116. title: '提示',
  117. content: '实名成功过',
  118. showCancel: false,
  119. success: res => {
  120. uni.switchTab({
  121. url: '/pages/index/index'
  122. });
  123. }
  124. });
  125. uni.hideLoading();
  126. this.loding = false;
  127. console.log(e);
  128. })
  129. .catch(e => {
  130. this.loding = false;
  131. console.log(e);
  132. });
  133. }
  134. }
  135. };
  136. </script>
  137. <style lang="scss">
  138. .content {
  139. height: 100%;
  140. padding: 0 $page-row-spacing;
  141. }
  142. .add-btn {
  143. display: flex;
  144. align-items: center;
  145. justify-content: center;
  146. width: 690rpx;
  147. height: 80rpx;
  148. margin: 60rpx auto;
  149. font-size: $font-lg;
  150. color: #fff;
  151. background: $bg-green-gradual;
  152. border-radius: 10rpx;
  153. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  154. }
  155. .bgimg {
  156. text-align: center;
  157. width: 1200rpx;
  158. margin-left: -260rpx;
  159. height: 400rpx;
  160. background: linear-gradient(#4cb1ff, #3081df);
  161. border-bottom-right-radius: 999999rpx;
  162. border-bottom-left-radius: 999999rpx;
  163. .img {
  164. width: 400rpx;
  165. margin-top: 50rpx;
  166. }
  167. }
  168. .user {
  169. margin-top: -50rpx;
  170. border-radius: 10rpx;
  171. }
  172. .userBox,
  173. .user {
  174. box-shadow: 0px 2px 16px 1px rgba(89, 89, 89, 0.24);
  175. padding: 0 $page-row-spacing;
  176. background-color: white;
  177. }
  178. .userBox {
  179. margin-top: 20rpx;
  180. padding: 30rpx;
  181. .imgUp {
  182. min-height: 100rpx;
  183. text-align: center;
  184. margin-top: 30rpx;
  185. .img {
  186. width: 300rpx;
  187. height: 400rpx;
  188. }
  189. }
  190. }
  191. .imglist /deep/ * {
  192. margin-left: auto !important;
  193. margin-right: auto !important;
  194. }
  195. </style>