identity_upload.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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(data) {
  94. if(data.identity_one){
  95. this.memberData.identity_one=data.identity_one
  96. }
  97. if(data.identity_one){
  98. this.memberData.identity_two=data.identity_two
  99. }
  100. },
  101. methods: {
  102. showUploadingImg(showImg, uploadingType) {
  103. if (showImg) {
  104. if(this.isUploading){
  105. return
  106. }
  107. this.isUploading=true
  108. this.uploadingType = uploadingType;
  109. this.$refs.popup.open("bottom");
  110. } else {
  111. this.$refs.popup.close();
  112. this.isUploading=false
  113. }
  114. },
  115. uploadingImg(sourceType) {
  116. console.log('sourceType:'+sourceType)
  117. uni.chooseMedia({
  118. mediaType: 'image',
  119. count: 1, //默认9
  120. sizeType: "compressed",
  121. sourceType: [sourceType === 1 ? 'camera' : 'album'],
  122. fail:(e)=>{
  123. console.log(e)
  124. },
  125. success: (res) => {
  126. if (res.tempFiles.length > 0) {
  127. res.tempFiles.forEach((tempFile) => {
  128. txUploadFile(tempFile.tempFilePath).then((data) => {
  129. if (!data) {
  130. tools.error('图片上传失败')
  131. tools.hideLoading()
  132. } else {
  133. if (this.uploadingType === 1) {
  134. tools.showLoading()
  135. //开启身份证照片识别
  136. getBaiDuImgRecognition({
  137. 'imgUrl': data.Location,
  138. 'imgType': '1'
  139. }).then((res) => {
  140. tools.hideLoading()
  141. if (res.code === 1) {
  142. this.memberData.identity_one = data.Location;
  143. this.memberData.name = res.data.name;
  144. this.memberData.id_number = res.data.id_number;
  145. this.memberData.sex = res.data.sex;
  146. this.memberData.birthday = res.data.birthday;
  147. } else {
  148. tools.error('身份证照片识别失败')
  149. }
  150. })
  151. } else {
  152. tools.showLoading()
  153. //开启身份证照片背面识别
  154. getBaiDuImgRecognition({
  155. 'imgUrl': data.Location,
  156. 'imgType': '4'
  157. }).then((res) => {
  158. tools.hideLoading()
  159. if (res.code === 1) {
  160. this.memberData.identity_two = data.Location;
  161. this.memberData.identity_validity = res.data.identity_validity;
  162. } else {
  163. tools.error('身份证照片识别失败')
  164. }
  165. })
  166. }
  167. }
  168. })
  169. })
  170. this.showUploadingImg(false, 0);
  171. } else {
  172. tools.error("请选择上传的图片")
  173. }
  174. },
  175. });
  176. },
  177. // 完成
  178. onSubmit() {
  179. if(this.memberData.name===''){
  180. tools.error('请上传人像面照片')
  181. return
  182. }
  183. if(this.memberData.identity_validity===''){
  184. tools.error('请上传国徽面照片')
  185. return
  186. }
  187. uni.$emit('discernMember',this.memberData)
  188. tools.success('认证成功')
  189. setTimeout(()=>{
  190. tools.leftClick()
  191. },100)
  192. }
  193. }
  194. }
  195. </script>
  196. <style lang="scss" scoped>
  197. @import "@/static/css/wh-common";
  198. .picture-box {
  199. position: relative;
  200. }
  201. .picture-item {
  202. width: 300rpx;
  203. height: 250rpx;
  204. image {
  205. width: 100%;
  206. height: 170rpx;
  207. }
  208. .picture-text {
  209. height: 80rpx;
  210. line-height: 80rpx;
  211. text-align: center;
  212. border-radius: 0 0 30rpx 30rpx;
  213. }
  214. }
  215. .picture-icon {
  216. position: absolute;
  217. bottom: -6rpx;
  218. left: 45rpx;
  219. z-index: 10;
  220. }
  221. .picture-hint {
  222. width: 120rpx;
  223. height: 80rpx;
  224. background: #F7F9FE;
  225. border-radius: 10rpx 10rpx 10rpx 10rpx;
  226. }
  227. </style>