identity_upload.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <view class="total-page page-env-160 page-box task-bg">
  3. <Nav :title="'身份证上传'" :genre="2" is_fixed>
  4. <view>
  5. <view class="sys-background-fff p-30 m-30 r-30">
  6. <text class="size-30 sys-weight-600">身份证上传认证照片</text>
  7. <view class="size-26 m-t10 text-color-999">仅用于公安网核实身份</view>
  8. <view class="row-justify-sb center size-28 p-b10 m-t40">
  9. <view class="picture-item" @click="showUploadingImg(true,1)">
  10. <image :src="memberData.identity_one" v-if="memberData.identity_one" mode="aspectFill"></image>
  11. <image src="/static/img/information/identity-front.png" v-else mode="aspectFill"></image>
  12. <view class="picture-text button-background text-color-fff">
  13. 拍摄人像面
  14. </view>
  15. </view>
  16. <view class="picture-item" @click="showUploadingImg(true,2)">
  17. <image :src="memberData.identity_two" v-if="memberData.identity_two" mode="aspectFill"></image>
  18. <image src="/static/img/information/identity-verso.png" v-else mode="aspectFill"></image>
  19. <view class="picture-text button-background text-color-fff">
  20. 拍摄国徽面
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="sys-background-fff p-30 m-lr30 m-t20 r-30">
  26. <text class="size-30 sys-weight-600">身份证上传认证照片</text>
  27. <view class="size-26 m-t10 text-color-999">仅用于公安网核实身份</view>
  28. <view class="row-justify-sb center size-26 m-t40">
  29. <view class="column-c" v-for="(item,index) in hintList" :key="index">
  30. <view class="picture-box">
  31. <image class="picture-hint" :src="`/static/img/information/${item.image}.png`"
  32. mode="aspectFill"></image>
  33. <image class="wh-30 picture-icon"
  34. :src="item.is_correct?'/static/img/information/hint-vector.png':'/static/img/information/hint-subtract.png'"
  35. mode="aspectFill"></image>
  36. </view>
  37. <view class="picture-text size-24 text-color-999 m-t20">
  38. {{item.name}}
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <EnButton :text="'完成'" @onSubmit="onSubmit">
  44. </EnButton>
  45. </view>
  46. </Nav>
  47. <uni-popup ref="popup" :safeArea="false" type="bottom" >
  48. <view class="popup-block">
  49. <view class="popup-row" @click="uploadingImg(1)">拍照</view>
  50. <view class="popup-row" @click="uploadingImg(2)">从手机里面选择</view>
  51. <view class="popup-row" @click="showUploadingImg(false,0)">取消</view>
  52. </view>
  53. </uni-popup>
  54. </view>
  55. </template>
  56. <!-- correct -->
  57. <script>
  58. import tools from "@/service/tools";
  59. import {getBaiDuImgRecognition} from "@/api/common";
  60. import txUploadFile from "@/service/txOssSts";
  61. export default {
  62. components: {},
  63. data() {
  64. return {
  65. hintList: [{
  66. name: '标准照片',
  67. image: 'hint-one',
  68. is_correct: true
  69. }, {
  70. name: '边框缺失',
  71. image: 'hint-two',
  72. is_correct: false
  73. }, {
  74. name: '照片模糊',
  75. image: 'hint-three',
  76. is_correct: false
  77. }, {
  78. name: '闪光强烈',
  79. image: 'hint-four',
  80. is_correct: false
  81. }, ],
  82. memberData:{
  83. identity_one:'',
  84. identity_two:'',
  85. name:'',
  86. id_number:'',
  87. sex:'',
  88. identity_validity:'',
  89. },
  90. isUploading:false,
  91. }
  92. },
  93. onLoad() {},
  94. methods: {
  95. showUploadingImg(showImg, uploadingType) {
  96. if (showImg) {
  97. if(this.isUploading){
  98. return
  99. }
  100. this.isUploading=true
  101. this.uploadingType = uploadingType;
  102. this.$refs.popup.open("bottom");
  103. } else {
  104. this.$refs.popup.close();
  105. this.isUploading=false
  106. }
  107. },
  108. uploadingImg(sourceType) {
  109. console.log('sourceType:'+sourceType)
  110. uni.chooseMedia({
  111. mediaType: 'image',
  112. count: 1, //默认9
  113. sizeType: "compressed",
  114. sourceType: [sourceType === 1 ? 'camera' : 'album'],
  115. fail:(e)=>{
  116. console.log(e)
  117. },
  118. success: (res) => {
  119. if (res.tempFiles.length > 0) {
  120. res.tempFiles.forEach((tempFile) => {
  121. txUploadFile(tempFile.tempFilePath).then((data) => {
  122. if (!data) {
  123. tools.error('图片上传失败')
  124. tools.hideLoading()
  125. } else {
  126. if (this.uploadingType === 1) {
  127. tools.showLoading()
  128. //开启身份证照片识别
  129. getBaiDuImgRecognition({
  130. 'imgUrl': data.Location,
  131. 'imgType': '1'
  132. }).then((res) => {
  133. tools.hideLoading()
  134. if (res.code === 1) {
  135. this.memberData.identity_one = data.Location;
  136. this.memberData.name = res.data.name;
  137. this.memberData.id_number = res.data.id_number;
  138. this.memberData.sex = res.data.sex;
  139. this.memberData.birthday = res.data.birthday;
  140. } else {
  141. tools.error('身份证照片识别失败')
  142. }
  143. })
  144. } else {
  145. tools.showLoading()
  146. //开启身份证照片背面识别
  147. getBaiDuImgRecognition({
  148. 'imgUrl': data.Location,
  149. 'imgType': '4'
  150. }).then((res) => {
  151. tools.hideLoading()
  152. if (res.code === 1) {
  153. this.memberData.identity_two = data.Location;
  154. this.memberData.identity_validity = res.data.identity_validity;
  155. } else {
  156. tools.error('身份证照片识别失败')
  157. }
  158. })
  159. }
  160. }
  161. })
  162. })
  163. this.showUploadingImg(false, 0);
  164. } else {
  165. tools.error("请选择上传的图片")
  166. }
  167. },
  168. });
  169. },
  170. // 完成
  171. onSubmit() {
  172. if(this.memberData.name===''){
  173. tools.error('请上传人像面照片')
  174. return
  175. }
  176. if(this.memberData.identity_validity===''){
  177. tools.error('请上传国徽面照片')
  178. return
  179. }
  180. uni.$emit('discernMember',this.memberData)
  181. tools.success('认证成功')
  182. setTimeout(()=>{
  183. tools.leftClick()
  184. },100)
  185. }
  186. }
  187. }
  188. </script>
  189. <style lang="scss" scoped>
  190. @import "@/static/css/wh-common";
  191. .picture-box {
  192. position: relative;
  193. }
  194. .picture-item {
  195. width: 300rpx;
  196. height: 250rpx;
  197. image {
  198. width: 100%;
  199. height: 170rpx;
  200. }
  201. .picture-text {
  202. height: 80rpx;
  203. line-height: 80rpx;
  204. text-align: center;
  205. border-radius: 0 0 30rpx 30rpx;
  206. }
  207. }
  208. .picture-icon {
  209. position: absolute;
  210. bottom: -6rpx;
  211. left: 45rpx;
  212. z-index: 10;
  213. }
  214. .picture-hint {
  215. width: 120rpx;
  216. height: 80rpx;
  217. background: #F7F9FE;
  218. border-radius: 10rpx 10rpx 10rpx 10rpx;
  219. }
  220. </style>