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 11KB

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