You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

real-name-authentication.vue 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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="state.form.userIdImgUrlName"
  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="state.form.userIdBackImgUrlName"
  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" :disabled="isSM" />
  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" :disabled="isSM" />
  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" :disabled="isSM" />
  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 = isSM ? false : true"
  64. input-align='right' :disabled="isSM" />
  65. </u-form-item>
  66. </u-form>
  67. </view>
  68. <view v-if="!isSM" 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. compareDates,
  95. confirm
  96. } from "@/utils/utils";
  97. import {
  98. onLoad,
  99. onPageScroll,
  100. } from "@dcloudio/uni-app";
  101. import {
  102. getUserMsg,
  103. realNameAuthentication
  104. } from "@/utils/network/api.js";
  105. import { credentialTypeSelect } from "@/datas/credentialType.js";
  106. import { requestNew } from "@/utils/network/request.js";
  107. import {
  108. setItem,
  109. getItem,
  110. } from "@/utils/storage";
  111. import {
  112. getCodeName
  113. } from "@/datas/queryKey.js";
  114. import navBar from "@/components/nav-bar/nav-bar2.vue";
  115. const labelStyle = {
  116. color: "#004576",
  117. fontSize: "28rpx",
  118. }
  119. const leftIcon = {
  120. height: '100%',
  121. width: '8rpx',
  122. display: 'flex',
  123. 'align-items': 'center',
  124. 'margin-right': '4rpx',
  125. }
  126. const scrollTop = ref(0)
  127. const show1 = ref(false)
  128. const isSM = ref(true)
  129. const state = reactive({
  130. choiceIndex: 1, // 1 身份证正面 2 身份证反面 3行驶证正面 4行驶证反面
  131. isTakePhotoModeShow: false, //选择拍照方式是否出来
  132. form: {
  133. address: "",
  134. idNum: "",
  135. userName: "", //开户人姓名
  136. userIdImgUrl: "",
  137. userIdImgUrlName: "",
  138. userIdBackImgUrl: "",
  139. userIdBackImgUrlName: "",
  140. gender: "",
  141. idType: "", //用户证件类型 101//身份证
  142. idTypeStr: "",
  143. userIdBackImgBase64:"1",
  144. userIdImgBase64:"2"
  145. },
  146. });
  147. const close = (e) => {
  148. console.log("e", e)
  149. state.isTakePhotoModeShow = e
  150. }
  151. const changeIdType = (item) => {
  152. state.form.idType = item[0].value
  153. state.form.idTypeStr = item[0].label
  154. console.log(item)
  155. }
  156. async function savaHandle(){
  157. if (!state.form.userName) {
  158. msg('请输入姓名');
  159. return;
  160. }
  161. if (!state.form.userIdImgUrl) {
  162. msg('请上传身份证的人像面');
  163. return;
  164. }
  165. if (!state.form.userIdBackImgUrl) {
  166. msg('请上传身份证的国徽面');
  167. return;
  168. }
  169. if (!checkStr(state.form.idNum, 'card')) {
  170. msg('请输入正确身份证号');
  171. return;
  172. }
  173. if (!state.form.idType) {
  174. msg('请选择证件类型');
  175. return;
  176. }
  177. const options = {
  178. type: 2,
  179. data: {
  180. ...state.form
  181. },
  182. method: "POST",
  183. showLoading: true,
  184. };
  185. requestNew(realNameAuthentication, options).then((res) => {
  186. console.log("提交", res);
  187. confirm('实名认证成功!', () => {
  188. uni.navigateBack();
  189. }, '成功', false);
  190. });
  191. };
  192. onLoad((option : any) => {
  193. console.log("option", option)
  194. initInfo();
  195. });
  196. const initInfo = () => {
  197. const options = {};
  198. requestNew(getUserMsg, options).then((res) => {
  199. const data = res;
  200. console.log(data, "认证信息"); //|| !data.userNegImgUrl || !data.userPosImgUrl
  201. if (data.userName && data.userIdNum) {
  202. state.form.address = data.userAddress;
  203. state.form.idNum = data.userIdNum;
  204. state.form.idType = data.userIdType;
  205. const idTypeStrItem = credentialTypeSelect.find(item => item.value === data.userIdType);
  206. state.form.idTypeStr = idTypeStrItem.label;
  207. state.form.userIdImgUrl = data.userPosImgUrl;
  208. state.form.userIdImgUrlName = data.userPosImgUrl;
  209. state.form.userIdBackImgUrl = data.userNegImgUrl;
  210. state.form.userIdBackImgUrlName = data.userNegImgUrl;
  211. state.form.userName = data.userName;
  212. } else {
  213. // 无用户信息则按未认证进行初始化
  214. state.form.idType = credentialTypeSelect[0].value
  215. state.form.idTypeStr = credentialTypeSelect[0].label
  216. }
  217. // 修改是否可以进行实名认证逻辑-wxx
  218. if (!data.userIdNum || !data.userNegImgUrl || !data.userPosImgUrl) {
  219. isSM.value = false
  220. }
  221. });
  222. }
  223. //监听页面滚动
  224. onPageScroll((e) => {
  225. scrollTop.value = e.scrollTop;
  226. });
  227. const replaceInput = (event) => {
  228. console.log("event", event)
  229. const screeningStr = /[^\u4E00-\u9FA5]/g; //想禁止什么类型,在这里替换正则就可以了
  230. if (screeningStr.test(event)) {
  231. setTimeout(() => {
  232. state.form.userName = event.replace(screeningStr, '');
  233. }, 100)
  234. } else {
  235. setTimeout(() => {
  236. state.form.userName = event;
  237. }, 100)
  238. }
  239. console.log("event.replace(screeningStr, '')", event.replace(screeningStr, ''), event, state.form.userName)
  240. }
  241. const takePhotoMode = (index) => {
  242. if (isSM.value) {
  243. return;
  244. }
  245. console.log("index", index)
  246. state.isTakePhotoModeShow = true
  247. state.choiceIndex = index
  248. }
  249. const ocrResult =(data) => {
  250. console.log("图片地址val", data)
  251. if (state.choiceIndex == 1) {
  252. state.form.userName = data.name;
  253. if (data.gender == '男') {
  254. state.form.gender = 'MALE'
  255. } else if (data.gender == '女') {
  256. state.form.gender = 'FEMALE'
  257. } else {
  258. state.form.gender = 'UNKOWN'
  259. }
  260. state.form.idNum = data.idno;
  261. state.form.userIdImgUrl = data.imageUrl;
  262. state.form.userIdImgUrlName = data.imageName;
  263. state.form.address = data.address;
  264. } else {
  265. state.form.userIdBackImgUrl = data.imageUrl;
  266. state.form.userIdBackImgUrlName = data.imageName;
  267. compareDates(data.enddate)
  268. }
  269. }
  270. </script>
  271. <style lang="scss" scoped>
  272. .title {
  273. font-size: 35rpx;
  274. font-family: Microsoft YaHei;
  275. font-weight: 400;
  276. color: #01243A;
  277. line-height: 35rpx;
  278. margin-bottom: 20rpx;
  279. }
  280. .content-wrap {
  281. position: absolute;
  282. top: 30rpx;
  283. width: 100%;
  284. box-sizing: border-box;
  285. padding: 0 30rpx 210rpx;
  286. .t-con {
  287. width: 100%;
  288. background-color: #fff;
  289. border-radius: 12rpx;
  290. padding: 40rpx 30rpx 30rpx;
  291. box-sizing: border-box;
  292. }
  293. .t-select {
  294. display: flex;
  295. padding-bottom: 30rpx;
  296. justify-content: center;
  297. align-items: center;
  298. .item-select {
  299. width: 200rpx;
  300. height: 68rpx;
  301. font-family: SourceHanSansSC, SourceHanSansSC;
  302. font-weight: 400;
  303. font-size: 28rpx;
  304. color: #CCB375;
  305. text-align: center;
  306. line-height: 68rpx;
  307. border: 1rpx solid #CCB375;
  308. &.l-item {
  309. border-radius: 34rpx 0 0 34rpx;
  310. }
  311. &.r-item {
  312. border-radius: 0 34rpx 34rpx 0;
  313. }
  314. &.active {
  315. color: #fff;
  316. background: #CCB375;
  317. }
  318. }
  319. }
  320. .big {
  321. font-size: 30rpx;
  322. font-family: Microsoft YaHei;
  323. font-weight: 400;
  324. color: #333333;
  325. line-height: 24rpx;
  326. }
  327. .nomal {
  328. font-size: 26rpx;
  329. font-family: Microsoft YaHei;
  330. font-weight: 400;
  331. color: #666666;
  332. line-height: 24rpx;
  333. }
  334. }
  335. .content {
  336. .action {
  337. position: absolute;
  338. bottom: 0rpx;
  339. left: 0;
  340. height: 188rpx;
  341. background-color: #fff;
  342. border-radius: 30rpx 30rpx 0 0;
  343. width: 100vw;
  344. display: flex;
  345. align-items: center;
  346. justify-content: center;
  347. flex-direction: column;
  348. .btn-tip {
  349. font-family: SourceHanSansSC, SourceHanSansSC;
  350. font-weight: 400;
  351. font-size: 24rpx;
  352. color: #CCB375;
  353. margin-bottom: 14rpx;
  354. }
  355. .button {
  356. height: 88rpx;
  357. background: radial-gradient(at 0% 0%, #01243A 0%, #004576 100%);
  358. border-radius: 40rpx;
  359. font-size: 32rpx;
  360. font-weight: 400;
  361. color: #ffffff;
  362. line-height: 88rpx;
  363. width: 660rpx;
  364. margin: 0 auto;
  365. }
  366. }
  367. .item-tips {
  368. .title {
  369. font-size: 30rpx;
  370. font-family: Microsoft YaHei;
  371. font-weight: 500;
  372. color: #01243A;
  373. line-height: 30rpx;
  374. }
  375. .tip {
  376. margin-top: 16rpx;
  377. font-size: 24rpx;
  378. font-family: Microsoft YaHei;
  379. font-weight: 400;
  380. color: #999999;
  381. line-height: 24rpx;
  382. }
  383. }
  384. .picture-wrapper {
  385. margin-top: 30rpx;
  386. .bg {
  387. background: #F5F9FB;
  388. border-radius: 10rpx;
  389. padding: 40rpx 30rpx;
  390. display: flex;
  391. justify-content: space-between;
  392. .name {
  393. padding-top: 30rpx;
  394. font-size: 32rpx;
  395. font-family: SourceHanSansSC, SourceHanSansSC;
  396. font-weight: 500;
  397. color: #111;
  398. line-height: 34rpx;
  399. }
  400. .value {
  401. margin-top: 20rpx;
  402. font-size: 22rpx;
  403. font-family: SourceHanSansSC, SourceHanSansSC;
  404. font-weight: 400;
  405. color: #999999;
  406. line-height: 24rpx;
  407. }
  408. .tip {
  409. margin-top: 20rpx;
  410. text-align: center;
  411. width: 100rpx;
  412. height: 30rpx;
  413. border-radius: 6rpx;
  414. border: 1rpx solid #CCB375;
  415. .tip-value {
  416. font-size: 20rpx;
  417. font-family: Microsoft YaHei;
  418. font-weight: 400;
  419. color: #CCB375;
  420. line-height: 30rpx;
  421. opacity: 1;
  422. }
  423. }
  424. }
  425. .icon {
  426. width: 304rpx;
  427. height: 190rpx;
  428. background-image: var(--bgimg);
  429. background-size: 100% 100%;
  430. background-repeat: no-repeat;
  431. }
  432. }
  433. .shibie-wrapper,
  434. .card-box {
  435. margin-top: 30rpx;
  436. border-radius: 12rpx;
  437. background-color: #fff;
  438. width: 100%;
  439. padding: 30rpx 30rpx 0;
  440. box-sizing: border-box;
  441. .title {
  442. font-size: 30rpx;
  443. font-family: SourceHanSansSC, SourceHanSansSC;
  444. font-weight: 500;
  445. color: #01243A;
  446. line-height: 30rpx;
  447. }
  448. }
  449. .buchong-wrapper {
  450. margin-top: 60rpx;
  451. .title {
  452. font-size: 30rpx;
  453. font-family: Microsoft YaHei;
  454. font-weight: 400;
  455. color: #000000;
  456. line-height: 30rpx;
  457. }
  458. }
  459. .green-tip {
  460. margin-top: 50rpx;
  461. font-size: 24rpx;
  462. font-family: Microsoft YaHei;
  463. font-weight: 400;
  464. color: #999;
  465. line-height: 24rpx;
  466. margin-bottom: 60rpx;
  467. }
  468. }
  469. .down {
  470. background: #CCB375;
  471. color: #fff;
  472. border-radius: 5rpx;
  473. font-size: 20rpx;
  474. margin-top: 10rpx;
  475. width: 100rpx;
  476. height: 30rpx;
  477. text-align: center;
  478. line-height: 30rpx;
  479. }
  480. </style>