approve.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view class="content">
  3. <view class="bgimg"><image class="img" src="https://zhibo.liuniu946.com/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 || 'https://zhibo.liuniu946.com/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. console.log(event,"123456")
  38. // 监听裁剪完成
  39. // 返回的 event 中包含了已经裁剪好图片的base64编码字符串
  40. // 你可以使用 <image :src="imgDataUrl" mode="aspectFit"></image> 组件来展示裁剪后的图片
  41. // 或者你可以将该字符串通过接口上传给服务器用来保存
  42. that.$nextTick(function() {
  43. that.form.img = event.data;
  44. console.log(that.form.img, '图片');
  45. });
  46. }
  47. },
  48. fail(e) {
  49. console.log(e, '错误');
  50. }
  51. });
  52. },
  53. ToIndex() {
  54. let obj = this;
  55. let ur = uni.getStorageSync('present') || '/pages/index/index';
  56. // 用于处理缓存bug
  57. if (ur == 'pages/product/product') {
  58. ur = '/pages/index/index';
  59. }
  60. uni.switchTab({
  61. url: ur,
  62. fail(e) {
  63. uni.navigateTo({
  64. url: ur,
  65. fail(e) {
  66. uni.navigateTo({
  67. url: '/pages/index/index'
  68. });
  69. }
  70. });
  71. }
  72. });
  73. },
  74. pushData() {
  75. const da = this.form;
  76. if (this.loding) {
  77. return;
  78. }
  79. if (!da.name) {
  80. uni.showModal({
  81. title: '提示',
  82. content: '请填写名称',
  83. showCancel: false
  84. });
  85. return;
  86. }
  87. if (!da.card) {
  88. uni.showModal({
  89. title: '提示',
  90. content: '请填写身份证',
  91. showCancel: false
  92. });
  93. return;
  94. }
  95. if (!da.img) {
  96. uni.showModal({
  97. title: '提示',
  98. content: '请选择图片',
  99. showCancel: false
  100. });
  101. return;
  102. }
  103. const data = {
  104. face_image: da.img.replace(/^data:image\/[a-z,A-Z]*;base64,/, ''),
  105. real_name: da.name,
  106. id_card: da.card
  107. };
  108. uni.showLoading({
  109. title: '审核中',
  110. mask: true
  111. });
  112. this.loding = true;
  113. // 上传
  114. realName(data)
  115. .then(e => {
  116. uni.showModal({
  117. title: '提示',
  118. content: '实名成功过',
  119. showCancel: false,
  120. success: res => {
  121. uni.switchTab({
  122. url: '/pages/index/index'
  123. });
  124. }
  125. });
  126. uni.hideLoading();
  127. this.loding = false;
  128. console.log(e);
  129. })
  130. .catch(e => {
  131. this.$api.msg("审核失败")
  132. this.loding = false;
  133. console.log(e);
  134. uni.hideLoading();
  135. });
  136. }
  137. }
  138. };
  139. </script>
  140. <style lang="scss" scoped>
  141. .content {
  142. height: 100%;
  143. padding: 0 $page-row-spacing;
  144. }
  145. .add-btn {
  146. display: flex;
  147. align-items: center;
  148. justify-content: center;
  149. width: 690rpx;
  150. height: 80rpx;
  151. margin: 60rpx auto;
  152. font-size: $font-lg;
  153. color: #fff;
  154. background: #ff0000;
  155. border-radius: 10rpx;
  156. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  157. }
  158. .bgimg {
  159. text-align: center;
  160. width: 1200rpx;
  161. margin-left: -260rpx;
  162. height: 400rpx;
  163. background: #ff0000;
  164. border-bottom-right-radius: 999999rpx;
  165. border-bottom-left-radius: 999999rpx;
  166. .img {
  167. width: 400rpx;
  168. margin-top: 50rpx;
  169. }
  170. }
  171. .user {
  172. margin-top: -100rpx !important;
  173. border-radius: 10rpx !important;
  174. padding: 0 30rpx;
  175. }
  176. .userBox,
  177. .user {
  178. box-shadow: 0px 2px 16px 1px rgba(89, 89, 89, 0.24) !important;
  179. background-color: white !important;
  180. }
  181. .userBox {
  182. margin-top: 20rpx;
  183. padding: 30rpx;
  184. .imgUp {
  185. min-height: 100rpx;
  186. text-align: center;
  187. margin-top: 30rpx;
  188. .img {
  189. width: 300rpx;
  190. height: 400rpx;
  191. }
  192. }
  193. }
  194. .imglist /deep/ * {
  195. margin-left: auto !important;
  196. margin-right: auto !important;
  197. }
  198. </style>