index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view class="prebox">
  3. <view class="rzbox">
  4. <view class="flex1">
  5. <view class="plr6">
  6. <view class="rztit">请上传身份证件照</view>
  7. <view class="flexcj mb10">
  8. <view class="carbox" @click="getaddImage('front')">
  9. <image :src="baseUrl+user.front" class="img" v-if="user.front"></image>
  10. <image :src="cardz" class="img" v-else></image>
  11. <view class="tit">拍摄人像面</view>
  12. <!-- <view class="tit">身份证正面</view> -->
  13. </view>
  14. <view class="carbox" @click="getaddImage('back')">
  15. <image :src="baseUrl+user.back" class="img" v-if="user.back"></image>
  16. <image :src="cardf" class="img" v-else></image>
  17. <view class="tit">拍摄国徽面</view>
  18. <!-- <view class="tit">身份证反面</view> -->
  19. </view>
  20. </view>
  21. <view class="mb4">
  22. <view class="cardtip">身份信息会根据上传的证件照片自动识别,支持手动输入。</view>
  23. <view class="cardtip">如果识别错误,可尝试再次拍照。</view>
  24. </view>
  25. </view>
  26. <!-- 身份信息 -->
  27. <uni-forms ref="form" :model="user">
  28. <uni-forms-item label="真实姓名" name="realName">
  29. <uni-easyinput v-model="user.realName" disabled :inputBorder='false' placeholder="自动识别" />
  30. </uni-forms-item>
  31. <uni-forms-item label="身份证号" name="idCard">
  32. <uni-easyinput v-model="user.idCard" disabled :inputBorder='false' placeholder="自动识别" />
  33. </uni-forms-item>
  34. <uni-forms-item label="证件有效期" name="expirationDate">
  35. <uni-easyinput v-model="user.expirationDate" disabled :inputBorder='false' placeholder="自动识别" />
  36. </uni-forms-item>
  37. <!-- <uni-forms-item label="居住地址" name="address">
  38. <uni-easyinput type="textarea" :autoHeight="true" disabled v-model="user.address" :inputBorder='false' placeholder="自动识别" />
  39. </uni-forms-item> -->
  40. <uni-forms-item label="手机号码" name="phonenumber">
  41. <uni-easyinput v-model="user.phonenumber" :inputBorder='false' placeholder="请输入手机号码,以便接收短信" />
  42. </uni-forms-item>
  43. </uni-forms>
  44. <view class="formtip">* 请确保填写的信息准确无误</view>
  45. </view>
  46. <view class="rzbtn" @click="getNext">确认</view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import config from '@/config'
  52. const baseUrl = config.baseUrl
  53. import {uploadIdentify} from '@/utils/common.js'
  54. import {getOcrIdCard,getOcrFn,getChangeFace,getIdCardAdd} from "@/api/mine/card.js"
  55. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  56. // #ifdef APP-PLUS
  57. const aliyunVerify = uni.requireNativePlugin('AP-FaceDetectModule');
  58. // #endif
  59. export default{
  60. components:{},
  61. data(){
  62. return{
  63. cardz:require('@/work/static/prove/cardz.png'),
  64. cardf:require('@/work/static/prove/cardf.png'),
  65. faceimg:require('@/work/static/prove/faceimg.png'),
  66. ftipa:require('@/work/static/prove/ftipa.png'),
  67. ftipb:require('@/work/static/prove/ftipb.png'),
  68. ftipc:require('@/work/static/prove/ftipc.png'),
  69. frontimg:'',
  70. backimg:'',
  71. count:1,
  72. file:[],
  73. baseUrl:config.baseUrl,
  74. user:{
  75. realName:'',
  76. idCard:'',
  77. address:'',
  78. expirationDate:'',
  79. phonenumber:this.$store.state.user.phonenumber,
  80. front:'',
  81. back:'',
  82. },
  83. metaInfo:{},
  84. userId:this.$store.state.user.userId,
  85. }
  86. },
  87. onLoad() {
  88. // #ifdef APP-PLUS
  89. var metaInfo = aliyunVerify.getMetaInfo();
  90. this.metaInfo=JSON.parse(JSON.stringify(metaInfo))
  91. // let p = uni.getSystemInfoSync().platform;
  92. // if (p === "ios") {
  93. // t = JSON.stringify(t);
  94. // }
  95. // #endif
  96. },
  97. methods:{
  98. checkPermi, checkRole,
  99. getNext(){
  100. // 判断信息是否完善
  101. if(!this.user.front){
  102. this.$toast("请上传身份证人像面")
  103. return
  104. }
  105. if(!this.user.back){
  106. this.$toast("请上传身份证国徽面")
  107. return
  108. }
  109. // #ifdef APP-PLUS
  110. this.getFace()
  111. // #endif
  112. // #ifndef APP-PLUS
  113. // this.$toast("请在app端进行认证")
  114. // 跳h5页面进行人脸认证
  115. var user=JSON.parse(JSON.stringify(this.user));
  116. user.userId=this.userId;
  117. user.returnUrl='https://rzdbh.qs163.cn/pages/success';
  118. // var data={
  119. // idCard:user.idCard,
  120. // realName:user.realName,
  121. // returnUrl:'http://192.168.101.147:9092/pages/success'
  122. // }
  123. this.$tab.navigateTo('/pages/common/webview/faceauth?data='+encodeURIComponent(JSON.stringify(user)))
  124. // #endif
  125. },
  126. getFace(){
  127. var that=this;
  128. // initFace Y不需要,N需要人脸认证
  129. var user=this.user;
  130. var params={
  131. idCard:user.idCard,
  132. realName:user.realName,
  133. metaInfo:this.metaInfo,
  134. }
  135. // #ifndef APP-PLUS
  136. params.returnUrl='https://rzdb.qs163.cn';
  137. // #endif
  138. getOcrFn(params).then(res=>{
  139. if(res.code==200){
  140. // #ifdef APP-PLUS
  141. var id=res.data.certifyId;
  142. aliyunVerify.verify({
  143. "certifyId":id, // 填写从服务端获取的certifyId
  144. },
  145. function(response){
  146. var face='Y'
  147. if(response.code==1000){
  148. var reparams=that.user;
  149. reparams.userId=that.userId;
  150. getIdCardAdd(reparams).then(resa=>{
  151. if(resa.code==200){
  152. that.$store.dispatch('checkInitFace', face).then(() => {
  153. that.$tab.redirectTo('/work/pages/prove/addqy?from=rz')
  154. })
  155. }
  156. })
  157. }
  158. }
  159. );
  160. // #endif
  161. // #ifndef APP-PLUS
  162. this.$toast("请在app端进行认证")
  163. // 跳h5页面进行人脸认证
  164. // console.log(MetaInfo)
  165. // var user=this.user;
  166. // var data={
  167. // url:res.data.certifyUrl,
  168. // realName:user.realName,
  169. // }
  170. // this.$tab.navigateTo('/pages/common/webview/faceauth?data='+encodeURIComponent(JSON.stringify(data)))
  171. // #endif
  172. }
  173. })
  174. },
  175. getaddImage(e){
  176. let that = this;
  177. // var rs=['D:\\idcard.png']
  178. // if(rs&&rs.length>0){
  179. // var obj={
  180. // type:e,
  181. // // url:baseUrl+rs.join(',')
  182. // url:rs.join(',')
  183. // }
  184. // that.getOcrIdCard(obj)
  185. // }
  186. // return
  187. let file =[],count=9
  188. uni.chooseImage({
  189. count: 1,
  190. success:function(res){
  191. let img= res.tempFilePaths;
  192. if(img.length + file.length > count){
  193. uni.showToast({
  194. title: '最多上传'+count+'张图片',
  195. icon: 'none',
  196. duration: 2000
  197. })
  198. }else{
  199. let imglen = res.tempFilePaths.length;
  200. var fuwufile = [];
  201. uploadIdentify('/common/upload',img,0,0,0,imglen,fuwufile,function(rs){
  202. var resurl=rs[0];
  203. if(e=='front'){
  204. that.user.front=resurl.fileName;
  205. }else{
  206. that.user.back=resurl.fileName;
  207. }
  208. if(rs&&rs.length>0){
  209. var obj={
  210. type:e,
  211. url:resurl.urlOnline
  212. }
  213. that.getOcrIdCard(obj)
  214. }
  215. })
  216. }
  217. }
  218. });
  219. },
  220. getOcrIdCard(obj){
  221. var params={
  222. image:obj.url,
  223. idCardSide:obj.type
  224. }
  225. getOcrIdCard(params).then(res=>{
  226. if(res.code==200){
  227. var user=res.data;
  228. if(obj.type=='front'){
  229. this.user.realName=user.realName;
  230. this.user.idCard=user.idCard;
  231. this.user.address=user.address;
  232. }else{
  233. this.user.expirationDate=user.expirationDate
  234. }
  235. }
  236. })
  237. }
  238. }
  239. }
  240. </script>
  241. <style>
  242. page{background: #F3F3F0;}
  243. </style>
  244. <style lang="scss" scoped>
  245. .prebox{padding: 20rpx 18rpx;}
  246. .rzbox /deep/ .uni-forms-item{min-height: 116rpx;box-sizing: border-box;display: flex;align-items: center;margin-bottom: 0;border-bottom: 2rpx solid #E6E6E6;padding:22rpx 0;}
  247. .rzbox /deep/ .uni-forms-item__label{font-weight: bold;font-size: 30rpx;color: #222327;flex: 0 0 auto;width: auto !important;}
  248. .rzbox /deep/ .uni-easyinput{flex: 1;text-align: right;font-size: 30rpx;color: #222327;}
  249. .rzbox /deep/ .uni-easyinput__content-textarea{min-height: 40rpx;font-size: 30rpx;}
  250. .rzbox /deep/ .uni-easyinput__placeholder-class{font-size: 30rpx;color: #AAAAAA;}
  251. .rzbox /deep/ .uni-input-input{font-size: 30rpx;}
  252. .rzbox /deep/ .uni-textarea-textarea{font-size: 30rpx;}
  253. .rzbox /deep/ .is-disabled{color: #222327;background-color: #ffffff !important;}
  254. .rzbox{padding: 36rpx 12rpx 60rpx;background: #ffffff;border-radius: 20rpx;min-height: calc(100vh - 40rpx);box-sizing: border-box;display: flex;flex-direction: column;
  255. .rztit{font-weight: 500;font-size: 30rpx;color: #222327;margin-bottom: 30rpx;}
  256. .carbox{width: 300rpx;border-radius: 14rpx;overflow: hidden;
  257. .img{width: 300rpx;height: 202rpx;}
  258. .tit{width: 100%;height: 60rpx;background: #A0C6D5;text-align: center;font-weight: 500;
  259. font-size: 26rpx;line-height: 60rpx;
  260. color: #FFFFFF;}
  261. }
  262. .cardtip{font-weight: 500;font-size: 24rpx;color: #999999;line-height: 40rpx;}
  263. .inttxet{font-weight: 500;font-size: 30rpx;flex: 1;text-align: right;color: #222327;}
  264. .formtip{font-weight: 500;font-size: 24rpx;color: #FF6969;margin-top: 40rpx;text-align: right;}
  265. .rzbtn{background: #0256FD;border-radius:10rpx;height: 88rpx;display: flex;align-items: center;justify-content: center;font-weight: bold;font-size: 26rpx;color: #FFFFFF;margin: 0 12rpx;flex: 0 0 auto;margin-top: 20rpx;}
  266. }
  267. .forbtn{}
  268. </style>