approve.vue 4.6 KB

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