approve.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 || '../../static/img/sfz.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 { upload } from '@/api/order.js';
  18. export default {
  19. data() {
  20. return {
  21. loding: false, //判断是否在点击中
  22. form: {
  23. name: '',
  24. card: '',
  25. img: ''
  26. }
  27. };
  28. },
  29. onLoad(option) {},
  30. methods: {
  31. upImg(e) {
  32. console.log('上传图片');
  33. const that = this;
  34. uni.showLoading({
  35. title: '上传中',
  36. mask: true
  37. });
  38. upload({
  39. filename: ''
  40. }).then(data => {
  41. uni.hideLoading()
  42. this.form.img = data[0].url;
  43. }).catch(()=>{
  44. uni.hideLoading()
  45. });
  46. },
  47. ToIndex() {
  48. let obj = this;
  49. let ur = uni.getStorageSync('present') || '/pages/index/index';
  50. // 用于处理缓存bug
  51. if (ur == 'pages/product/product') {
  52. ur = '/pages/index/index';
  53. }
  54. uni.switchTab({
  55. url: ur,
  56. fail(e) {
  57. uni.navigateTo({
  58. url: ur,
  59. fail(e) {
  60. uni.navigateTo({
  61. url: '/pages/index/index'
  62. });
  63. }
  64. });
  65. }
  66. });
  67. },
  68. pushData() {
  69. const da = this.form;
  70. if (this.loding) {
  71. return;
  72. }
  73. if (!da.name) {
  74. uni.showModal({
  75. title: '提示',
  76. content: '请填写真实姓名',
  77. showCancel: false
  78. });
  79. return;
  80. }
  81. if (!da.card) {
  82. uni.showModal({
  83. title: '提示',
  84. content: '请填写身份证',
  85. showCancel: false
  86. });
  87. return;
  88. }
  89. if (!da.img) {
  90. uni.showModal({
  91. title: '提示',
  92. content: '请选择图片',
  93. showCancel: false
  94. });
  95. return;
  96. }
  97. const data = {
  98. cidimg: da.img,
  99. rname: da.name,
  100. cid: da.card
  101. };
  102. uni.showLoading({
  103. title: '审核中',
  104. mask: true
  105. });
  106. this.loding = true;
  107. // 上传
  108. realName(data)
  109. .then(e => {
  110. uni.showModal({
  111. title: '提示',
  112. content: '实名提交成功',
  113. showCancel: false,
  114. success: res => {
  115. uni.switchTab({
  116. url: '/pages/index/index'
  117. });
  118. }
  119. });
  120. uni.hideLoading();
  121. this.loding = false;
  122. console.log(e);
  123. })
  124. .catch(e => {
  125. this.loding = false;
  126. console.log(e);
  127. uni.hideLoading();
  128. });
  129. }
  130. }
  131. };
  132. </script>
  133. <style lang="scss" scoped>
  134. .content {
  135. height: 100%;
  136. padding: 0 $page-row-spacing;
  137. }
  138. .add-btn {
  139. display: flex;
  140. align-items: center;
  141. justify-content: center;
  142. width: 690rpx;
  143. height: 80rpx;
  144. margin: 60rpx auto;
  145. font-size: $font-lg;
  146. color: #fff;
  147. background: #ff0000;
  148. border-radius: 10rpx;
  149. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  150. }
  151. .bgimg {
  152. text-align: center;
  153. width: 1200rpx;
  154. margin-left: -260rpx;
  155. height: 400rpx;
  156. background: #ff0000;
  157. border-bottom-right-radius: 999999rpx;
  158. border-bottom-left-radius: 999999rpx;
  159. .img {
  160. width: 400rpx;
  161. margin-top: 50rpx;
  162. }
  163. }
  164. .user {
  165. margin-top: -100rpx !important;
  166. border-radius: 10rpx !important;
  167. padding: 0 30rpx;
  168. }
  169. .userBox,
  170. .user {
  171. box-shadow: 0px 2px 16px 1px rgba(89, 89, 89, 0.24) !important;
  172. background-color: white !important;
  173. }
  174. .userBox {
  175. margin-top: 20rpx;
  176. padding: 30rpx;
  177. .imgUp {
  178. min-height: 100rpx;
  179. text-align: center;
  180. margin-top: 30rpx;
  181. .img {
  182. width: 300rpx;
  183. height: 400rpx;
  184. }
  185. }
  186. }
  187. .imglist /deep/ * {
  188. margin-left: auto !important;
  189. margin-right: auto !important;
  190. }
  191. </style>