index.vue 8.7 KB

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