index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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=this.user;
  110. // var data={
  111. // idCard:user.idCard,
  112. // realName:user.realName,
  113. // returnUrl:'https://rzdb.qs163.cn'
  114. // }
  115. // this.$tab.navigateTo('/pages/common/webview/faceauth?data='+encodeURIComponent(JSON.stringify(data)))
  116. // #endif
  117. },
  118. getFace(){
  119. var that=this;
  120. // initFace Y不需要,N需要人脸认证
  121. var user=this.user;
  122. var params={
  123. idCard:user.idCard,
  124. realName:user.realName,
  125. metaInfo:this.metaInfo,
  126. }
  127. // #ifndef APP-PLUS
  128. params.returnUrl='https://rzdb.qs163.cn';
  129. // #endif
  130. getOcrFn(params).then(res=>{
  131. if(res.code==200){
  132. // #ifdef APP-PLUS
  133. var id=res.data.certifyId;
  134. aliyunVerify.verify({
  135. "certifyId":id, // 填写从服务端获取的certifyId
  136. },
  137. function(response){
  138. var face='Y'
  139. if(response.code==1000){
  140. var reparams=that.user;
  141. reparams.userId=that.userId;
  142. getIdCardAdd(reparams).then(resa=>{
  143. if(resa.code==200){
  144. that.$store.dispatch('checkInitFace', face).then(() => {
  145. that.$tab.redirectTo('/work/pages/prove/addqy?from=rz')
  146. })
  147. }
  148. })
  149. }
  150. }
  151. );
  152. // #endif
  153. // #ifndef APP-PLUS
  154. this.$toast("请在app端进行认证")
  155. // 跳h5页面进行人脸认证
  156. // console.log(MetaInfo)
  157. // var user=this.user;
  158. // var data={
  159. // url:res.data.certifyUrl,
  160. // realName:user.realName,
  161. // }
  162. // this.$tab.navigateTo('/pages/common/webview/faceauth?data='+encodeURIComponent(JSON.stringify(data)))
  163. // #endif
  164. }
  165. })
  166. },
  167. getaddImage(e){
  168. let that = this;
  169. // var rs=['D:\\idcard.png']
  170. // if(rs&&rs.length>0){
  171. // var obj={
  172. // type:e,
  173. // // url:baseUrl+rs.join(',')
  174. // url:rs.join(',')
  175. // }
  176. // that.getOcrIdCard(obj)
  177. // }
  178. // return
  179. let file =[],count=9
  180. uni.chooseImage({
  181. count: 1,
  182. success:function(res){
  183. let img= res.tempFilePaths;
  184. if(img.length + file.length > count){
  185. uni.showToast({
  186. title: '最多上传'+count+'张图片',
  187. icon: 'none',
  188. duration: 2000
  189. })
  190. }else{
  191. let imglen = res.tempFilePaths.length;
  192. var fuwufile = [];
  193. uploadIdentify('/common/upload',img,0,0,0,imglen,fuwufile,function(rs){
  194. var resurl=rs[0];
  195. if(e=='front'){
  196. that.user.front=resurl.fileName;
  197. }else{
  198. that.user.back=resurl.fileName;
  199. }
  200. if(rs&&rs.length>0){
  201. var obj={
  202. type:e,
  203. url:resurl.urlOnline
  204. }
  205. that.getOcrIdCard(obj)
  206. }
  207. })
  208. }
  209. }
  210. });
  211. },
  212. getOcrIdCard(obj){
  213. var params={
  214. image:obj.url,
  215. idCardSide:obj.type
  216. }
  217. getOcrIdCard(params).then(res=>{
  218. if(res.code==200){
  219. var user=res.data;
  220. if(obj.type=='front'){
  221. this.user.realName=user.realName;
  222. this.user.idCard=user.idCard;
  223. this.user.address=user.address;
  224. }else{
  225. this.user.expirationDate=user.expirationDate
  226. }
  227. }
  228. })
  229. }
  230. }
  231. }
  232. </script>
  233. <style>
  234. page{background:#ffffff;}
  235. </style>
  236. <style lang="scss" scoped>
  237. .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;}
  238. .rzbox /deep/ .uni-forms-item__label{font-weight: bold;font-size: 30rpx;color: #222327;flex: 0 0 auto;width: auto !important;}
  239. .rzbox /deep/ .uni-easyinput{flex: 1;text-align: right;font-size: 30rpx;color: #222327;}
  240. .rzbox /deep/ .uni-easyinput__content-textarea{min-height: 40rpx;font-size: 30rpx;}
  241. .rzbox /deep/ .uni-easyinput__placeholder-class{font-size: 30rpx;color: #AAAAAA;}
  242. .rzbox /deep/ .uni-input-input{font-size: 30rpx;}
  243. .rzbox /deep/ .uni-textarea-textarea{font-size: 30rpx;}
  244. .rzbox /deep/ .is-disabled{color: #222327;background-color: #ffffff !important;}
  245. .rzbox{padding: 44rpx 34rpx 76rpx;
  246. .carbox{width: 320rpx;border-radius: 14rpx;overflow: hidden;
  247. .img{width: 320rpx;height: 216rpx;}
  248. .tit{width: 100%;height: 60rpx;background: #A0C6D5;text-align: center;font-weight: 500;
  249. font-size: 26rpx;line-height: 60rpx;
  250. color: #FFFFFF;}
  251. }
  252. .cardtip{font-weight: 500;font-size: 24rpx;color: #999999;line-height: 40rpx;}
  253. .inttxet{font-weight: 500;font-size: 30rpx;flex: 1;text-align: right;color: #222327;}
  254. .formtip{font-weight: 500;font-size: 24rpx;color: #FF6969;margin-top: 40rpx;text-align: right;}
  255. .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;}
  256. }
  257. </style>