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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  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. isSM.value = false
  215. state.form.idType = credentialTypeSelect[0].value
  216. state.form.idTypeStr = credentialTypeSelect[0].label
  217. }
  218. });
  219. }
  220. //监听页面滚动
  221. onPageScroll((e) => {
  222. scrollTop.value = e.scrollTop;
  223. });
  224. const replaceInput = (event) => {
  225. console.log("event", event)
  226. const screeningStr = /[^\u4E00-\u9FA5]/g; //想禁止什么类型,在这里替换正则就可以了
  227. if (screeningStr.test(event)) {
  228. setTimeout(() => {
  229. state.form.userName = event.replace(screeningStr, '');
  230. }, 100)
  231. } else {
  232. setTimeout(() => {
  233. state.form.userName = event;
  234. }, 100)
  235. }
  236. console.log("event.replace(screeningStr, '')", event.replace(screeningStr, ''), event, state.form.userName)
  237. }
  238. const takePhotoMode = (index) => {
  239. if (isSM.value) {
  240. return;
  241. }
  242. console.log("index", index)
  243. state.isTakePhotoModeShow = true
  244. state.choiceIndex = index
  245. }
  246. const ocrResult =(data) => {
  247. console.log("图片地址val", data)
  248. if (state.choiceIndex == 1) {
  249. state.form.userName = data.name;
  250. if (data.gender == '男') {
  251. state.form.gender = 'MALE'
  252. } else if (data.gender == '女') {
  253. state.form.gender = 'FEMALE'
  254. } else {
  255. state.form.gender = 'UNKOWN'
  256. }
  257. state.form.idNum = data.idno;
  258. state.form.userIdImgUrl = data.imageUrl;
  259. state.form.userIdImgUrlName = data.imageName;
  260. state.form.address = data.address;
  261. } else {
  262. state.form.userIdBackImgUrl = data.imageUrl;
  263. state.form.userIdBackImgUrlName = data.imageName;
  264. compareDates(data.enddate)
  265. }
  266. }
  267. </script>
  268. <style lang="scss" scoped>
  269. .title {
  270. font-size: 35rpx;
  271. font-family: Microsoft YaHei;
  272. font-weight: 400;
  273. color: #01243A;
  274. line-height: 35rpx;
  275. margin-bottom: 20rpx;
  276. }
  277. .content-wrap {
  278. position: absolute;
  279. top: 30rpx;
  280. width: 100%;
  281. box-sizing: border-box;
  282. padding: 0 30rpx 210rpx;
  283. .t-con {
  284. width: 100%;
  285. background-color: #fff;
  286. border-radius: 12rpx;
  287. padding: 40rpx 30rpx 30rpx;
  288. box-sizing: border-box;
  289. }
  290. .t-select {
  291. display: flex;
  292. padding-bottom: 30rpx;
  293. justify-content: center;
  294. align-items: center;
  295. .item-select {
  296. width: 200rpx;
  297. height: 68rpx;
  298. font-family: SourceHanSansSC, SourceHanSansSC;
  299. font-weight: 400;
  300. font-size: 28rpx;
  301. color: #CCB375;
  302. text-align: center;
  303. line-height: 68rpx;
  304. border: 1rpx solid #CCB375;
  305. &.l-item {
  306. border-radius: 34rpx 0 0 34rpx;
  307. }
  308. &.r-item {
  309. border-radius: 0 34rpx 34rpx 0;
  310. }
  311. &.active {
  312. color: #fff;
  313. background: #CCB375;
  314. }
  315. }
  316. }
  317. .big {
  318. font-size: 30rpx;
  319. font-family: Microsoft YaHei;
  320. font-weight: 400;
  321. color: #333333;
  322. line-height: 24rpx;
  323. }
  324. .nomal {
  325. font-size: 26rpx;
  326. font-family: Microsoft YaHei;
  327. font-weight: 400;
  328. color: #666666;
  329. line-height: 24rpx;
  330. }
  331. }
  332. .content {
  333. .action {
  334. position: absolute;
  335. bottom: 0rpx;
  336. left: 0;
  337. height: 188rpx;
  338. background-color: #fff;
  339. border-radius: 30rpx 30rpx 0 0;
  340. width: 100vw;
  341. display: flex;
  342. align-items: center;
  343. justify-content: center;
  344. flex-direction: column;
  345. .btn-tip {
  346. font-family: SourceHanSansSC, SourceHanSansSC;
  347. font-weight: 400;
  348. font-size: 24rpx;
  349. color: #CCB375;
  350. margin-bottom: 14rpx;
  351. }
  352. .button {
  353. height: 88rpx;
  354. background: radial-gradient(at 0% 0%, #01243A 0%, #004576 100%);
  355. border-radius: 40rpx;
  356. font-size: 32rpx;
  357. font-weight: 400;
  358. color: #ffffff;
  359. line-height: 88rpx;
  360. width: 660rpx;
  361. margin: 0 auto;
  362. }
  363. }
  364. .item-tips {
  365. .title {
  366. font-size: 30rpx;
  367. font-family: Microsoft YaHei;
  368. font-weight: 500;
  369. color: #01243A;
  370. line-height: 30rpx;
  371. }
  372. .tip {
  373. margin-top: 16rpx;
  374. font-size: 24rpx;
  375. font-family: Microsoft YaHei;
  376. font-weight: 400;
  377. color: #999999;
  378. line-height: 24rpx;
  379. }
  380. }
  381. .picture-wrapper {
  382. margin-top: 30rpx;
  383. .bg {
  384. background: #F5F9FB;
  385. border-radius: 10rpx;
  386. padding: 40rpx 30rpx;
  387. display: flex;
  388. justify-content: space-between;
  389. .name {
  390. padding-top: 30rpx;
  391. font-size: 32rpx;
  392. font-family: SourceHanSansSC, SourceHanSansSC;
  393. font-weight: 500;
  394. color: #111;
  395. line-height: 34rpx;
  396. }
  397. .value {
  398. margin-top: 20rpx;
  399. font-size: 22rpx;
  400. font-family: SourceHanSansSC, SourceHanSansSC;
  401. font-weight: 400;
  402. color: #999999;
  403. line-height: 24rpx;
  404. }
  405. .tip {
  406. margin-top: 20rpx;
  407. text-align: center;
  408. width: 100rpx;
  409. height: 30rpx;
  410. border-radius: 6rpx;
  411. border: 1rpx solid #CCB375;
  412. .tip-value {
  413. font-size: 20rpx;
  414. font-family: Microsoft YaHei;
  415. font-weight: 400;
  416. color: #CCB375;
  417. line-height: 30rpx;
  418. opacity: 1;
  419. }
  420. }
  421. }
  422. .icon {
  423. width: 304rpx;
  424. height: 190rpx;
  425. background-image: var(--bgimg);
  426. background-size: 100% 100%;
  427. background-repeat: no-repeat;
  428. }
  429. }
  430. .shibie-wrapper,
  431. .card-box {
  432. margin-top: 30rpx;
  433. border-radius: 12rpx;
  434. background-color: #fff;
  435. width: 100%;
  436. padding: 30rpx 30rpx 0;
  437. box-sizing: border-box;
  438. .title {
  439. font-size: 30rpx;
  440. font-family: SourceHanSansSC, SourceHanSansSC;
  441. font-weight: 500;
  442. color: #01243A;
  443. line-height: 30rpx;
  444. }
  445. }
  446. .buchong-wrapper {
  447. margin-top: 60rpx;
  448. .title {
  449. font-size: 30rpx;
  450. font-family: Microsoft YaHei;
  451. font-weight: 400;
  452. color: #000000;
  453. line-height: 30rpx;
  454. }
  455. }
  456. .green-tip {
  457. margin-top: 50rpx;
  458. font-size: 24rpx;
  459. font-family: Microsoft YaHei;
  460. font-weight: 400;
  461. color: #999;
  462. line-height: 24rpx;
  463. margin-bottom: 60rpx;
  464. }
  465. }
  466. .down {
  467. background: #CCB375;
  468. color: #fff;
  469. border-radius: 5rpx;
  470. font-size: 20rpx;
  471. margin-top: 10rpx;
  472. width: 100rpx;
  473. height: 30rpx;
  474. text-align: center;
  475. line-height: 30rpx;
  476. }
  477. </style>