perfect.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="content">
  3. <view class="card">
  4. <view class="title">
  5. 上传身份证
  6. </view>
  7. <view class="top row">
  8. <view class="left" @click="chooseImg(1)">
  9. <image class="image-dom" :src="cardLeft" v-if="cardLeft !== ''"></image>
  10. </view>
  11. <view class="right" @click="chooseImg(2)">
  12. <image class="image-dom" :src="cardRight" v-if="cardRight !== ''"></image>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="card margin-top">
  17. <view class="title">
  18. 上传营业执照
  19. </view>
  20. <view class="bottom row">
  21. <view class="image" @click="chooseImg(3)">
  22. <image class="image-dom" :src="imgBottom" v-if="imgBottom !== ''"></image>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="bottom-btn">
  27. <view class="btn" @click="push">
  28. 完善
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. getToken
  36. } from "@/utils/auth.js";
  37. export default {
  38. data() {
  39. return {
  40. // 身份证正面
  41. cardLeft: "",
  42. // 身份证反面
  43. cardRight: "",
  44. // 营业执照
  45. imgBottom: ""
  46. }
  47. },
  48. methods: {
  49. // 点击确认
  50. push() {
  51. if (this.cardLeft === '') {
  52. this.$u.toast('请上传身份证正面')
  53. return false
  54. }
  55. if (this.cardRight === '') {
  56. this.$u.toast('请上传身份证正面')
  57. return false
  58. }
  59. if (this.imgBottom === '') {
  60. this.$u.toast('请上传身份证正面')
  61. return false
  62. }
  63. this.request('/sender/verification', {
  64. id_z: this.cardLeft,
  65. id_f: this.cardRight,
  66. license: this.imgBottom,
  67. }, "POST").then(res => {
  68. if (res.code === 1) {
  69. this.$u.toast('完善成功')
  70. setTimeout(()=>{
  71. uni.navigateBack({
  72. delta:1
  73. })
  74. },2000)
  75. }
  76. })
  77. },
  78. // 点击选择图片
  79. chooseImg(type) {
  80. let _this = this
  81. uni.chooseImage({
  82. success(e) {
  83. console.log(e)
  84. uni.uploadFile({
  85. url: 'http://pet.hdlkeji.com/api/common/upload', //仅为示例,非真实的接口地址
  86. filePath: e.tempFilePaths[0],
  87. header: {
  88. "token": getToken()
  89. },
  90. name: 'file',
  91. success: (res) => {
  92. console.log(res, 11111)
  93. if (type === 1) {
  94. _this.cardLeft = e.tempFilePaths[0]
  95. }
  96. if (type === 2) {
  97. _this.cardRight = e.tempFilePaths[0]
  98. }
  99. if (type === 3) {
  100. _this.imgBottom = e.tempFilePaths[0]
  101. }
  102. }
  103. })
  104. }
  105. })
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss">
  111. .content {
  112. padding-top: 30rpx;
  113. .title {
  114. font-size: 36rpx;
  115. }
  116. .margin-top {
  117. margin-top: 40rpx;
  118. }
  119. }
  120. .card {
  121. width: 93%;
  122. padding: 30rpx;
  123. margin: 0 auto;
  124. background-color: #FFFFFF;
  125. border-radius: 30rpx;
  126. .top {
  127. .left {
  128. width: 300rpx;
  129. height: 200rpx;
  130. background-image: url("http://pet.hdlkeji.com/assets/static/1/107.png");
  131. background-size: 100% 100%;
  132. background-repeat: no-repeat;
  133. }
  134. .right {
  135. width: 300rpx;
  136. height: 200rpx;
  137. background-image: url("http://pet.hdlkeji.com/assets/static/1/106.png");
  138. background-size: 100% 100%;
  139. background-repeat: no-repeat;
  140. }
  141. }
  142. .bottom {
  143. display: flex;
  144. flex-direction: row;
  145. align-items: center;
  146. justify-content: center;
  147. .image {
  148. height: 300rpx;
  149. width: 600rpx;
  150. background-image: url("http://pet.hdlkeji.com/assets/static/1/82.png");
  151. background-size: 100% 100%;
  152. background-repeat: no-repeat;
  153. }
  154. }
  155. }
  156. .image-dom {
  157. width: 100%;
  158. height: 100%;
  159. }
  160. // 完成按钮
  161. .bottom-btn {
  162. position: fixed;
  163. bottom: 0;
  164. width: 100%;
  165. height: 10vh;
  166. display: flex;
  167. flex-direction: column;
  168. align-items: center;
  169. justify-content: center;
  170. background-color: #FFFFFF;
  171. .btn {
  172. width: 100%;
  173. color: #E68500;
  174. background-color: #FFE3A0;
  175. height: 80rpx;
  176. border-radius: 50rpx;
  177. text-align: center;
  178. line-height: 80rpx;
  179. }
  180. }
  181. </style>