Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

real-name-authentication.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. <template>
  2. <view class="content-wrap">
  3. <view class="t-card">
  4. <view class="content">
  5. <view class="t-con">
  6. <view class="item-tips">
  7. <view class="title"> 上传后请核对识别信息 </view>
  8. <view class="tip"> 如有错误请及时手动修改 </view>
  9. </view>
  10. <view class="picture-wrapper" @click="takePhotoMode(1)">
  11. <view class="bg">
  12. <view class="">
  13. <view class="name"> 人像面 </view>
  14. <view class="value"> 上传身份证的人像面 </view>
  15. <view class="tip">
  16. <view class="tip-value"> 拍摄规范 </view>
  17. </view>
  18. </view>
  19. <image v-if="!state.form.userIdImgUrl" class="icon" :src="`${$imgUrl}issuance/sfz.png`"
  20. :style="{'--bgimg':`url(${$imgUrl}issuance/bg-border.png)`}">
  21. </image>
  22. <image v-else class="icon" :src="strReplace(state.form.userIdImgUrl)"
  23. :style="{'--bgimg':`url(${$imgUrl}issuance/bg-border.png`}"></image>
  24. </view>
  25. </view>
  26. <view class="picture-wrapper" @click="takePhotoMode(2)">
  27. <view class="bg">
  28. <view class="">
  29. <view class="name"> 国徽面 </view>
  30. <view class="value"> 上传身份证的国徽面 </view>
  31. <view class="tip">
  32. <view class="tip-value"> 拍摄规范 </view>
  33. </view>
  34. </view>
  35. <image v-if="!state.form.userIdBackImgUrl" class="icon" :src="`${$imgUrl}issuance/sff.png`"
  36. :style="{'--bgimg':`url(${$imgUrl}issuance/bg-border.png`}">
  37. </image>
  38. <image v-else class="icon" :src="strReplace(state.form.userIdBackImgUrl)"
  39. :style="{'--bgimg':`url(${$imgUrl}issuance/bg-border.png`}"></image>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="shibie-wrapper">
  44. <view class="title"> 识别内容如下 </view>
  45. <u-form label-width="230" :model="state.form" ref="uForm" :label-style='labelStyle'>
  46. <u-form-item label="姓名" :left-icon='`${$imgUrl}issuance/point-form.png`'
  47. :left-icon-style='leftIcon'>
  48. <u-input v-model="state.form.userName" placeholder='请输入姓名' maxlength="20"
  49. @input="replaceInput" inputAlign="right" />
  50. </u-form-item>
  51. <u-form-item label="身份证号" :left-icon='`${$imgUrl}issuance/point-form.png`'
  52. :left-icon-style='leftIcon'>
  53. <u-input placeholder='请输入身份证' type="idcard" v-model="state.form.idNum" maxlength="18"
  54. inputAlign="right" />
  55. </u-form-item>
  56. <u-form-item label="地址" :left-icon='`${$imgUrl}issuance/point-form.png`'
  57. :left-icon-style='leftIcon'>
  58. <u-input placeholder='请输入地址' :autoHeight='true' v-model="state.form.address" maxlength="50"
  59. inputAlign="right" />
  60. </u-form-item>
  61. <u-form-item label="证件类型" :left-icon='`${$imgUrl}issuance/point-form.png`'
  62. :left-icon-style='leftIcon' borderBottom>
  63. <u-input v-model="state.form.idTypeStr" type="select" @click="show1 = true"
  64. input-align='right' />
  65. </u-form-item>
  66. </u-form>
  67. </view>
  68. <view class="action">
  69. <view class="btn-tip">
  70. 如识别信息有误,请手动修改,确认无误后,点击下一步!
  71. </view>
  72. <button type="default" class="ui-btn" @click="savaHandle()">
  73. 下一步
  74. </button>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <!-- 选择车牌颜色 -->
  80. <u-select v-model="show1" :list="credentialTypeSelect" @confirm="changeIdType"></u-select>
  81. <uploadImg :isTakePhotoModeShow="state.isTakePhotoModeShow" :phoneType="state.choiceIndex" @close="close"
  82. @ocrResult="ocrResult">
  83. </uploadImg>
  84. </template>
  85. <script setup lang="ts">
  86. import uploadImg from '@/components/uploadOcr';
  87. import {
  88. reactive,
  89. ref,
  90. } from "vue";
  91. import {
  92. msg,
  93. checkStr,
  94. strReplace,
  95. uploadFile,
  96. compressImage,
  97. chooseImageCompress,
  98. compareDates,
  99. getFileBase64
  100. } from "@/utils/utils";
  101. import {
  102. onLoad,
  103. onPageScroll,
  104. } from "@dcloudio/uni-app";
  105. import {
  106. getUserMsg,
  107. realNameAuthentication
  108. } from "@/utils/network/api.js";
  109. import { credentialTypeSelect } from "@/datas/credentialType.js";
  110. import { requestNew } from "@/utils/network/request.js";
  111. import {
  112. setItem,
  113. getItem,
  114. } from "@/utils/storage";
  115. import {
  116. getCodeName
  117. } from "@/datas/queryKey.js";
  118. import navBar from "@/components/nav-bar/nav-bar2.vue";
  119. const labelStyle = {
  120. color: "#004576",
  121. fontSize: "28rpx",
  122. }
  123. const leftIcon = {
  124. height: '100%',
  125. width: '8rpx',
  126. display: 'flex',
  127. 'align-items': 'center',
  128. 'margin-right': '4rpx',
  129. }
  130. const scrollTop = ref(0)
  131. const show1 = ref(false)
  132. const state = reactive({
  133. choiceIndex: 1, // 1 身份证正面 2 身份证反面 3行驶证正面 4行驶证反面
  134. isTakePhotoModeShow: false, //选择拍照方式是否出来
  135. form: {
  136. address: "",
  137. idNum: "",
  138. userName: "", //开户人姓名
  139. userIdImgUrl: "",
  140. userIdBackImgUrl: "",
  141. gender: "",
  142. idType: "", //用户证件类型 101//身份证
  143. idTypeStr: "",
  144. userIdBackImgBase64:"",
  145. userIdImgBase64:""
  146. },
  147. userIdImgBase64Old:"",
  148. userIdBackImgBase64Old:""
  149. });
  150. const close = (e) => {
  151. console.log("e", e)
  152. state.isTakePhotoModeShow = e
  153. }
  154. const changeIdType = (item) => {
  155. state.form.idType = item[0].value
  156. state.form.idTypeStr = item[0].label
  157. console.log(item)
  158. }
  159. async function savaHandle(){
  160. if (!state.form.userName) {
  161. msg('请输入姓名');
  162. return;
  163. }
  164. if (!state.form.userIdImgUrl) {
  165. msg('请上传身份证的人像面');
  166. return;
  167. }
  168. if (!state.form.userIdBackImgUrl) {
  169. msg('请上传身份证的国徽面');
  170. return;
  171. }
  172. if (!checkStr(state.form.idNum, 'card')) {
  173. msg('请输入正确身份证号');
  174. return;
  175. }
  176. if (!state.form.idType) {
  177. msg('请选择证件类型');
  178. return;
  179. }
  180. state.form.userIdImgBase64=await getFileBase64(state.userIdImgBase64Old)
  181. state.form.userIdBackImgBase64=await getFileBase64(state.userIdBackImgBase64Old)
  182. // getFileBase64(state.userIdImgBase64Old, (data) => {
  183. // console.log("getFileBase641", data)
  184. // state.form.userIdImgBase64=data
  185. // })
  186. // getFileBase64(state.userIdBackImgBase64Old, (data) => {
  187. // console.log("getFileBase642", data)
  188. // state.form.userIdBackImgBase64=data
  189. // })
  190. const options = {
  191. type: 2,
  192. data: {
  193. ...state.form
  194. },
  195. method: "POST",
  196. showLoading: true,
  197. };
  198. requestNew(realNameAuthentication, options).then((res) => {
  199. console.log("提交", res);
  200. });
  201. };
  202. onLoad((option : any) => {
  203. console.log("option", option)
  204. });
  205. //监听页面滚动
  206. onPageScroll((e) => {
  207. scrollTop.value = e.scrollTop;
  208. });
  209. const replaceInput = (event) => {
  210. console.log("event", event)
  211. const screeningStr = /[^\u4E00-\u9FA5]/g; //想禁止什么类型,在这里替换正则就可以了
  212. if (screeningStr.test(event)) {
  213. setTimeout(() => {
  214. state.form.userName = event.replace(screeningStr, '');
  215. }, 100)
  216. } else {
  217. setTimeout(() => {
  218. state.form.userName = event;
  219. }, 100)
  220. }
  221. console.log("event.replace(screeningStr, '')", event.replace(screeningStr, ''), event, state.form.userName)
  222. }
  223. const takePhotoMode = (index) => {
  224. console.log("index", index)
  225. state.isTakePhotoModeShow = true
  226. state.choiceIndex = index
  227. }
  228. const ocrResult =(data) => {
  229. console.log("图片地址val", data)
  230. if (state.choiceIndex == 1) {
  231. state.form.userName = data.name;
  232. if (data.gender == '男') {
  233. state.form.gender = 'MALE'
  234. } else if (data.gender == '女') {
  235. state.form.gender = 'FEMALE'
  236. } else {
  237. state.form.gender = 'UNKOWN'
  238. }
  239. state.form.idNum = data.idno;
  240. state.form.userIdImgUrl = data.imageUrl;
  241. state.form.address = data.address;
  242. state.userIdImgBase64Old=data.tempFilePath;
  243. } else {
  244. state.form.userIdBackImgUrl = data.imageUrl;
  245. state.userIdBackImgBase64Old=data.tempFilePath
  246. compareDates(data.enddate)
  247. }
  248. }
  249. </script>
  250. <style lang="scss" scoped>
  251. .title {
  252. font-size: 35rpx;
  253. font-family: Microsoft YaHei;
  254. font-weight: 400;
  255. color: #01243A;
  256. line-height: 35rpx;
  257. margin-bottom: 20rpx;
  258. }
  259. .content-wrap {
  260. position: absolute;
  261. top: 30rpx;
  262. width: 100%;
  263. box-sizing: border-box;
  264. padding: 0 30rpx 210rpx;
  265. .t-con {
  266. width: 100%;
  267. background-color: #fff;
  268. border-radius: 12rpx;
  269. padding: 40rpx 30rpx 30rpx;
  270. box-sizing: border-box;
  271. }
  272. .t-select {
  273. display: flex;
  274. padding-bottom: 30rpx;
  275. justify-content: center;
  276. align-items: center;
  277. .item-select {
  278. width: 200rpx;
  279. height: 68rpx;
  280. font-family: SourceHanSansSC, SourceHanSansSC;
  281. font-weight: 400;
  282. font-size: 28rpx;
  283. color: #CCB375;
  284. text-align: center;
  285. line-height: 68rpx;
  286. border: 1rpx solid #CCB375;
  287. &.l-item {
  288. border-radius: 34rpx 0 0 34rpx;
  289. }
  290. &.r-item {
  291. border-radius: 0 34rpx 34rpx 0;
  292. }
  293. &.active {
  294. color: #fff;
  295. background: #CCB375;
  296. }
  297. }
  298. }
  299. .big {
  300. font-size: 30rpx;
  301. font-family: Microsoft YaHei;
  302. font-weight: 400;
  303. color: #333333;
  304. line-height: 24rpx;
  305. }
  306. .nomal {
  307. font-size: 26rpx;
  308. font-family: Microsoft YaHei;
  309. font-weight: 400;
  310. color: #666666;
  311. line-height: 24rpx;
  312. }
  313. }
  314. .content {
  315. .action {
  316. position: absolute;
  317. bottom: 0rpx;
  318. left: 0;
  319. height: 188rpx;
  320. background-color: #fff;
  321. border-radius: 30rpx 30rpx 0 0;
  322. width: 100vw;
  323. display: flex;
  324. align-items: center;
  325. justify-content: center;
  326. flex-direction: column;
  327. .btn-tip {
  328. font-family: SourceHanSansSC, SourceHanSansSC;
  329. font-weight: 400;
  330. font-size: 24rpx;
  331. color: #CCB375;
  332. margin-bottom: 14rpx;
  333. }
  334. .button {
  335. height: 88rpx;
  336. background: radial-gradient(at 0% 0%, #01243A 0%, #004576 100%);
  337. border-radius: 40rpx;
  338. font-size: 32rpx;
  339. font-weight: 400;
  340. color: #ffffff;
  341. line-height: 88rpx;
  342. width: 660rpx;
  343. margin: 0 auto;
  344. }
  345. }
  346. .item-tips {
  347. .title {
  348. font-size: 30rpx;
  349. font-family: Microsoft YaHei;
  350. font-weight: 500;
  351. color: #01243A;
  352. line-height: 30rpx;
  353. }
  354. .tip {
  355. margin-top: 16rpx;
  356. font-size: 24rpx;
  357. font-family: Microsoft YaHei;
  358. font-weight: 400;
  359. color: #999999;
  360. line-height: 24rpx;
  361. }
  362. }
  363. .picture-wrapper {
  364. margin-top: 30rpx;
  365. .bg {
  366. background: #F5F9FB;
  367. border-radius: 10rpx;
  368. padding: 40rpx 30rpx;
  369. display: flex;
  370. justify-content: space-between;
  371. .name {
  372. padding-top: 30rpx;
  373. font-size: 32rpx;
  374. font-family: SourceHanSansSC, SourceHanSansSC;
  375. font-weight: 500;
  376. color: #111;
  377. line-height: 34rpx;
  378. }
  379. .value {
  380. margin-top: 20rpx;
  381. font-size: 22rpx;
  382. font-family: SourceHanSansSC, SourceHanSansSC;
  383. font-weight: 400;
  384. color: #999999;
  385. line-height: 24rpx;
  386. }
  387. .tip {
  388. margin-top: 20rpx;
  389. text-align: center;
  390. width: 100rpx;
  391. height: 30rpx;
  392. border-radius: 6rpx;
  393. border: 1rpx solid #CCB375;
  394. .tip-value {
  395. font-size: 20rpx;
  396. font-family: Microsoft YaHei;
  397. font-weight: 400;
  398. color: #CCB375;
  399. line-height: 30rpx;
  400. opacity: 1;
  401. }
  402. }
  403. }
  404. .icon {
  405. width: 304rpx;
  406. height: 190rpx;
  407. background-image: var(--bgimg);
  408. background-size: 100% 100%;
  409. background-repeat: no-repeat;
  410. }
  411. }
  412. .shibie-wrapper,
  413. .card-box {
  414. margin-top: 30rpx;
  415. border-radius: 12rpx;
  416. background-color: #fff;
  417. width: 100%;
  418. padding: 30rpx 30rpx 0;
  419. box-sizing: border-box;
  420. .title {
  421. font-size: 30rpx;
  422. font-family: SourceHanSansSC, SourceHanSansSC;
  423. font-weight: 500;
  424. color: #01243A;
  425. line-height: 30rpx;
  426. }
  427. }
  428. .buchong-wrapper {
  429. margin-top: 60rpx;
  430. .title {
  431. font-size: 30rpx;
  432. font-family: Microsoft YaHei;
  433. font-weight: 400;
  434. color: #000000;
  435. line-height: 30rpx;
  436. }
  437. }
  438. .green-tip {
  439. margin-top: 50rpx;
  440. font-size: 24rpx;
  441. font-family: Microsoft YaHei;
  442. font-weight: 400;
  443. color: #999;
  444. line-height: 24rpx;
  445. margin-bottom: 60rpx;
  446. }
  447. }
  448. .down {
  449. background: #CCB375;
  450. color: #fff;
  451. border-radius: 5rpx;
  452. font-size: 20rpx;
  453. margin-top: 10rpx;
  454. width: 100rpx;
  455. height: 30rpx;
  456. text-align: center;
  457. line-height: 30rpx;
  458. }
  459. </style>