select-type.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <view>
  3. <headContent borderBottom>
  4. <template #left>
  5. <reverse-back />
  6. </template>
  7. </headContent>
  8. <view class="content">
  9. <text class="content-title">ID 验证</text>
  10. <text class="content-lable">检查签发国家</text>
  11. <view class="item-box">
  12. <view class="item">
  13. <text>中国</text>
  14. <text class="item-icon iconfont">&#xe8b5;</text>
  15. </view>
  16. </view>
  17. <text class="content-lable lable-type">选择ID类型</text>
  18. <view class="item-box">
  19. <view class="item">
  20. <text class="type-icon iconfont">&#xe619;</text>
  21. <text class="text-name">护照</text>
  22. <text class="item-icon iconfont">&#xe8b5;</text>
  23. </view>
  24. <view class="item">
  25. <text class="type-icon iconfont">&#xe626;</text>
  26. <text class="text-name">驾驶证</text>
  27. <text class="item-icon iconfont">&#xe8b5;</text>
  28. </view>
  29. <view class="item" @click.stop=" getIdentity">
  30. <text class="type-icon iconfont">&#xe616;</text>
  31. <text class="text-name">身份证</text>
  32. <text class="item-icon iconfont">&#xe8b5;</text>
  33. </view>
  34. <view class="item">
  35. <text class="type-icon iconfont">&#xe62a;</text>
  36. <text class="text-name">签证</text>
  37. <text class="item-icon iconfont">&#xe8b5;</text>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. Api_identityVerify
  46. } from "@/api/index.js"
  47. import {
  48. pathToBase64,
  49. base64ToPath
  50. } from 'image-tools'
  51. // const ocr = uni.requireNativePlugin('DC-WBOCRService');
  52. export default {
  53. data() {
  54. return {
  55. dataObj: {}
  56. };
  57. },
  58. mounted() {
  59. },
  60. methods: {
  61. setIdentityVerify(base64) {
  62. const userId = this.$getStorageSync('userInfo')?.id
  63. Api_identityVerify({
  64. name: userId,
  65. card_id: userId,
  66. front_pic: base64
  67. }).then(res => {
  68. console.log('res = ', res)
  69. setTimeout(() => {
  70. uni.showToast({
  71. title: res || '提交成功'
  72. })
  73. setTimeout(() => {
  74. uni.hideToast()
  75. uni.reLaunch({
  76. url: '/pages/content/mine'
  77. });
  78. }, 1500)
  79. }, 210)
  80. }).catch(err => {
  81. }).finally(() => {
  82. setTimeout(() => {
  83. }, 500)
  84. })
  85. },
  86. getIdentity(e) {
  87. // 点击拍照
  88. let _this = this
  89. let configure = "{'side':'face'}" //face正面、back反面
  90. uni.chooseImage({
  91. count: 1, // 默认9
  92. sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
  93. sourceType: ['album'], // 可以指定来源是相册还是相机,默认二者都有
  94. success: res => {
  95. let tempFilePaths = res.tempFilePaths[0];
  96. this.base64String(tempFilePaths)
  97. },
  98. complete: () => {
  99. uni.hideLoading()
  100. }
  101. })
  102. },
  103. base64String(path) {
  104. pathToBase64(path)
  105. .then(base64 => {
  106. this.setIdentityVerify(base64)
  107. console.log(base64)
  108. })
  109. .catch(error => {
  110. console.error(error)
  111. })
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .content {
  118. width: 100%;
  119. padding: 50rpx $pages-padding;
  120. display: flex;
  121. flex-direction: column;
  122. .content-title {
  123. font-size: 70rpx;
  124. }
  125. .content-lable {
  126. font-size: 50rpx;
  127. line-height: 2.2;
  128. }
  129. .lable-type {
  130. margin-top: 100rpx;
  131. }
  132. .item-box {
  133. width: 100%;
  134. .item {
  135. width: 100%;
  136. height: 120rpx;
  137. padding: 0 $pages-padding;
  138. background-color: #e3e3e3;
  139. display: flex;
  140. justify-content: space-between;
  141. align-items: center;
  142. text {
  143. flex-shrink: 0;
  144. }
  145. .type-icon {
  146. font-size: 50rpx;
  147. color: #000;
  148. margin-right: 50rpx;
  149. }
  150. .text-name {
  151. flex: 1;
  152. }
  153. .item-icon {
  154. transform: rotate(180deg);
  155. font-size: 50rpx;
  156. color: #000;
  157. }
  158. &:nth-child(n + 2) {
  159. margin-top: 2px;
  160. }
  161. &:first-child {
  162. border-radius: 10rpx 10rpx 0 0;
  163. }
  164. &:last-child {
  165. border-radius: 0 0 10rpx 10rpx;
  166. }
  167. }
  168. }
  169. }
  170. </style>