Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

change-user-info.vue 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <template>
  2. <view class="item-tips">
  3. <view class="title"> 上传后请核对识别信息 </view>
  4. <view class="tip"> 如有错误请及时手动修改 </view>
  5. </view>
  6. <view class="content" v-if="state.userType == '1'">
  7. <view class="h2-title">用户证件信息</view>
  8. <view class="picture-wrapper" @click="takePhotoMode(1)">
  9. <view class="bg">
  10. <view class="">
  11. <view class="name"> 人像面 </view>
  12. <view class="value"> 上传身份证的人像面 </view>
  13. <view class="tip">
  14. <view class="tip-value"> 拍摄规范 </view>
  15. </view>
  16. </view>
  17. <image v-if="!submitForm.idCardFront" class="icon" :src="`${$imgUrl}issuance/sfz.png`">
  18. </image>
  19. <image v-else class="icon" :src="getFullImageUrl(submitForm.idCardFront)"></image>
  20. </view>
  21. </view>
  22. <view class="picture-wrapper" @click="takePhotoMode(2)">
  23. <view class="bg">
  24. <view class="">
  25. <view class="name"> 国徽面 </view>
  26. <view class="value"> 上传身份证的国徽面 </view>
  27. <view class="tip">
  28. <view class="tip-value"> 拍摄规范 </view>
  29. </view>
  30. </view>
  31. <image v-if="!submitForm.idCardBack" class="icon" :src="`${$imgUrl}issuance/sff.png`">
  32. </image>
  33. <image v-else class="icon" :src="getFullImageUrl(submitForm.idCardBack)"></image>
  34. </view>
  35. </view>
  36. </view>
  37. <template v-else-if="state.userType == '2'">
  38. <view class="content">
  39. <view class="h2-title">单位证件信息</view>
  40. <view class="picture-wrapper" @click="takePhotoMode(5)">
  41. <view class="bg">
  42. <view class="">
  43. <view class="name"> 营业执照 </view>
  44. <view class="value"> 上传企业的营业执照 </view>
  45. <view class="tip">
  46. <view class="tip-value"> 拍摄规范 </view>
  47. </view>
  48. </view>
  49. <image v-if="!submitForm.idCardFront" class="icon" :src="`${$imgUrl}applyCard/zhizhao.png`">
  50. </image>
  51. <image v-else class="icon" :src="getFullImageUrl(submitForm.idCardFront)"></image>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="content" >
  56. <view class="h2-title">经办人身份信息</view>
  57. <view class="picture-wrapper" @click="takePhotoMode(1)">
  58. <view class="bg">
  59. <view class="">
  60. <view class="name"> 人像面 </view>
  61. <view class="value"> 上传身份证的人像面 </view>
  62. <view class="tip">
  63. <view class="tip-value"> 拍摄规范 </view>
  64. </view>
  65. </view>
  66. <image v-if="!submitForm.agentIdCardFront" class="icon" :src="`${$imgUrl}issuance/sfz.png`">
  67. </image>
  68. <image v-else class="icon" :src="getFullImageUrl(submitForm.agentIdCardFront)"></image>
  69. </view>
  70. </view>
  71. <view class="picture-wrapper" @click="takePhotoMode(2)">
  72. <view class="bg">
  73. <view class="">
  74. <view class="name"> 国徽面 </view>
  75. <view class="value"> 上传身份证的国徽面 </view>
  76. <view class="tip">
  77. <view class="tip-value"> 拍摄规范 </view>
  78. </view>
  79. </view>
  80. <image v-if="!submitForm.agentIdCardBack" class="icon" :src="`${$imgUrl}issuance/sff.png`">
  81. </image>
  82. <image v-else class="icon" :src="getFullImageUrl(submitForm.agentIdCardBack)"></image>
  83. </view>
  84. </view>
  85. </view>
  86. </template>
  87. <view class="shibie-wrapper">
  88. <u-form label-width="230" :model="submitForm" ref="myForm" :label-style='labelStyle'>
  89. <view class="from">
  90. <u-form-item prop="name" :label="state.userType == '2' ? '单位名称' : '姓名'">
  91. <u-input v-model="submitForm.name" class="input" :placeholder="state.userType == '2' ? '请输入单位名称' : '请输入姓名'" inputAlign="right" />
  92. </u-form-item>
  93. <u-form-item prop="idNo" label="证件号">
  94. <u-input v-model="submitForm.idNo" class="input" placeholder="请输入证件号" inputAlign="right" />
  95. </u-form-item>
  96. <template v-if="state.userType == '1'">
  97. <u-form-item prop="address" label="身份证地址" >
  98. <u-input v-model="submitForm.address" class="input" placeholder="请输入身份证地址" inputAlign="right" />
  99. </u-form-item>
  100. <u-form-item prop="tel" label="手机号">
  101. <u-input v-model="submitForm.tel" class="input" placeholder="请输入手机号" inputAlign="right" />
  102. </u-form-item>
  103. <u-form-item prop="verifyCode" label="验证码" v-if="state.phoneStore !== submitForm.tel">
  104. <view class="from_item no-border">
  105. <u-input v-model="submitForm.verifyCode" placeholder="请输入验证码" class="input" inputAlign="right" type="number" />
  106. <view class="hint2">
  107. <view class="green">{{ codeDuration === 0 ? "" : codeDuration }}</view>
  108. <view class="grey" @click="getCode">{{ codeDuration === 0 ? "发送验证码" : "秒后可重发" }}</view>
  109. </view>
  110. </view>
  111. </u-form-item>
  112. </template>
  113. </view>
  114. </u-form>
  115. </view>
  116. <view class="shibie-wrapper" v-if="state.userType == '2'">
  117. <u-form label-width="230" :model="submitForm" ref="myForm" :label-style='labelStyle'>
  118. <view class="from">
  119. <u-form-item prop="agentName" label="经办人姓名">
  120. <u-input v-model="submitForm.agentName" class="input" placeholder="请输入经办人姓名" inputAlign="right" />
  121. </u-form-item>
  122. <u-form-item prop="agentIdNo" label="经办人证件号">
  123. <u-input v-model="submitForm.agentIdNo" class="input" placeholder="请输入经办人证件号" inputAlign="right" />
  124. </u-form-item>
  125. <u-form-item prop="tel" label="手机号">
  126. <u-input v-model="submitForm.tel" class="input" placeholder="请输入手机号" inputAlign="right" />
  127. </u-form-item>
  128. <u-form-item prop="verifyCode" label="验证码" v-if="state.phoneStore !== submitForm.tel">
  129. <view class="from_item no-border">
  130. <u-input v-model="submitForm.verifyCode" placeholder="请输入验证码" class="input" inputAlign="right" type="number" />
  131. <view class="hint2">
  132. <view class="green">{{ codeDuration === 0 ? "" : codeDuration }}</view>
  133. <view class="grey" @click="getCode">{{ codeDuration === 0 ? "发送验证码" : "秒后可重发" }}</view>
  134. </view>
  135. </view>
  136. </u-form-item>
  137. </view>
  138. </u-form>
  139. </view>
  140. <FixedFooter>
  141. <button type="default" class="ui-btn" @click="submit">提交</button>
  142. </FixedFooter>
  143. <!--证件照上传 start-->
  144. <uploadImg
  145. :isTakePhotoModeShow="state.isTakePhotoModeShow"
  146. :phoneType="state.choiceIndex"
  147. @close="close"
  148. @ocrResult="ocrResult">
  149. </uploadImg>
  150. <!--证件照上传 end-->
  151. </template>
  152. <script setup lang="ts">
  153. import { ref, reactive } from 'vue'
  154. import { onReady, onLoad } from "@dcloudio/uni-app";
  155. import uploadImg from '@/components/uploadOcr';
  156. import { msg, getFullImageUrl, compareDates, checkStr } from "@/utils/utils";
  157. import { changeUserInfo, sendMessage, getUserMsg, getCustomerDetail, userInfoIndex } from '@/utils/network/api'
  158. import { requestNew } from "@/utils/network/request.js";
  159. import FixedFooter from '@/components/common/FixedFooter'
  160. import { getItem } from '@/utils/storage'
  161. interface OCRData {
  162. imageUrl: string,
  163. bizContent: string,
  164. screditCode: string,
  165. enddate: string
  166. }
  167. //倒计时时常
  168. const codeDuration = ref(0);
  169. let interval = null;
  170. const myForm = ref(null);
  171. const userInfo = getItem('userInfo')
  172. const state = reactive({
  173. isTakePhotoModeShow: false,
  174. choiceIndex: 1, // 1 身份证正面 2 身份证反面 3:营业执照正面
  175. userType: '1', // 用户类型 1:个人用户 2: 公司用户
  176. phoneStore: ''
  177. })
  178. const labelStyle = {
  179. color: "#004576",
  180. fontSize: "28rpx",
  181. }
  182. const submitForm = reactive({
  183. name: '',
  184. idNo: '',
  185. address: '',
  186. agentName: '', // 经办人
  187. agentIdNo: '',
  188. idCardFront: '',
  189. idCardBack: '',
  190. agentIdCardFront: '',
  191. agentIdCardBack : '',
  192. tel: '',
  193. verifyCode: '',
  194. mobileChange: 1, // 默认为否 1: 否 2:是
  195. type: '1', // 1:个人 2:单位
  196. vld: '',
  197. customerId: userInfo.customerId
  198. })
  199. onLoad(() => {
  200. getUserInfo()
  201. })
  202. const submit = () => {
  203. if (!paramsVerify()) return
  204. let params = JSON.parse(JSON.stringify(submitForm))
  205. if (params.tel !== state.phoneStore) {
  206. params.mobileChange = 2
  207. }
  208. let option = {
  209. type: 2,
  210. data: params,
  211. method: "POST",
  212. showLoading: true,
  213. }
  214. requestNew(changeUserInfo, option).then(res => {
  215. uni.navigateTo({
  216. url: '/pages/common/submit-result'
  217. })
  218. })
  219. }
  220. // 字段校验
  221. const paramsVerify = () => {
  222. // 个人类型修改信息
  223. if (state.userType === '1') {
  224. if (!submitForm.idCardFront) {
  225. msg('请上传证件正面照')
  226. return false
  227. } else if (!submitForm.idCardBack) {
  228. msg('请上传证件反面照')
  229. return false
  230. } else if (!submitForm.name) {
  231. msg('请填写证件姓名')
  232. return false
  233. } else if (!submitForm.idNo) {
  234. msg('请填写证件号')
  235. return false
  236. } else if (!submitForm.tel) {
  237. msg('请填写手机号')
  238. return false
  239. } else if (submitForm.tel !== state.phoneStore && !submitForm.verifyCode) {
  240. msg('请填写验证码')
  241. return false
  242. }
  243. return true
  244. } else if (state.userType === '2') {
  245. if (!submitForm.idCardFront) {
  246. msg('请上传证件正面照')
  247. return false
  248. } else if (!submitForm.name) {
  249. msg('请填写证件姓名')
  250. return false
  251. } else if (!submitForm.idNo) {
  252. msg('请填写证件号')
  253. return false
  254. } else if (!submitForm.tel) {
  255. msg('请填写手机号')
  256. return false
  257. } else if (submitForm.tel !== state.phoneStore && !submitForm.verifyCode) {
  258. msg('请填写验证码')
  259. return false
  260. } else if (!submitForm.agentIdCardFront) {
  261. msg('请上传经办人身份证正面照')
  262. return false
  263. } else if (!submitForm.agentIdCardBack) {
  264. msg('请上传经办人身份证反面照')
  265. return false
  266. }
  267. return true
  268. }
  269. }
  270. // 获取用户详情
  271. const getUserInfo = () => {
  272. let option = {
  273. type: 2,
  274. data: {
  275. customerId: userInfo.customerId // 测试Id:52010125072300301
  276. },
  277. method: "POST",
  278. showLoading: true,
  279. }
  280. requestNew(getCustomerDetail, option).then(res => {
  281. state.userType = submitForm.type = res.userType === 'PERSONAL_USER' ? '1' : '2'
  282. state.phoneStore = submitForm.tel = res.customerTel
  283. if (state.userType === '1') {
  284. submitForm.name = res.customerName
  285. submitForm.idNo = res.channelId
  286. submitForm.address = res.customerAddress
  287. submitForm.idCardFront = res.customerPosImgUrl
  288. submitForm.idCardBack = res.customerNegImgUrl
  289. submitForm.vld = res.customerVid
  290. } else if (state.userType === '2') {
  291. submitForm.name = res.customerName
  292. submitForm.idNo = res.channelId
  293. submitForm.address = res.customerAddress
  294. submitForm.idCardFront = res.customerPosImgUrl
  295. submitForm.agentName = res.agentName
  296. submitForm.agentIdNo = res.agentIdNum
  297. submitForm.agentIdCardFront = res.agentPosImgUrl
  298. submitForm.agentIdCardBack = res.agentNegImgUrl
  299. }
  300. })
  301. }
  302. const close = (e) => {
  303. state.isTakePhotoModeShow = e
  304. }
  305. const takePhotoMode = (index: number) => {
  306. state.isTakePhotoModeShow = true
  307. state.choiceIndex = index
  308. }
  309. const ocrResult = (data: OCRData) => {
  310. let bizContent = data.bizContent = data.bizContent ? JSON.parse(data.bizContent) : {}
  311. if (state.choiceIndex === 1) {
  312. if (!bizContent.idno) {
  313. msg('识别失败,请重新上传')
  314. } else {
  315. if (state.userType === '1') {
  316. submitForm.name = bizContent.name;
  317. submitForm.address = bizContent.address;
  318. submitForm.idNo = bizContent.idno;
  319. submitForm.idCardFront = data.imageUrl;
  320. } else {
  321. submitForm.agentName = bizContent.name;
  322. submitForm.agentIdNo = bizContent.idno;
  323. submitForm.agentIdCardFront = data.imageUrl;
  324. }
  325. }
  326. } else if (state.choiceIndex === 2) {
  327. if (!bizContent.begindate) {
  328. msg('识别失败,请重新上传')
  329. } else {
  330. if (state.userType === '1') {
  331. submitForm.idCardBack = data.imageUrl;
  332. submitForm.vld = data.enddate
  333. compareDates(data.enddate)
  334. } else {
  335. submitForm.agentIdCardBack = data.imageUrl;
  336. }
  337. }
  338. } else if (state.choiceIndex === 5) {
  339. submitForm.name = bizContent.unitName;
  340. submitForm.idNo = bizContent.screditCode;
  341. submitForm.idCardFront = data.imageUrl
  342. }
  343. }
  344. // 发送验证码
  345. const getCode = () => {
  346. if (codeDuration.value !== 0) {
  347. return;
  348. }
  349. if (!submitForm.tel) {
  350. msg("请输入手机号!");
  351. return;
  352. }
  353. if (!checkStr(submitForm.tel, "mobile")) {
  354. msg("请输入正确的手机号!");
  355. return;
  356. }
  357. const options = {
  358. type: 2,
  359. data: {
  360. mobile: submitForm.tel,
  361. businessType: 3
  362. },
  363. method: "POST",
  364. showLoading: true,
  365. };
  366. requestNew(sendMessage, options)
  367. .then(() => {
  368. codeInterval();
  369. msg("验证码发送成功!");
  370. })
  371. .catch((err) => {
  372. console.log(err);
  373. });
  374. }
  375. /* 验证码倒计时 */
  376. const codeInterval = () => {
  377. codeDuration.value = 60;
  378. interval = setInterval(() => {
  379. codeDuration.value--;
  380. if (codeDuration.value === 0) {
  381. if (interval) {
  382. clearInterval(interval);
  383. interval = null;
  384. }
  385. }
  386. }, 1000);
  387. };
  388. </script>
  389. <style lang="scss" scoped>
  390. .content{
  391. padding: 30rpx 30rpx;
  392. background-color: #FFFFFF;
  393. margin: 30rpx 30rpx 0;
  394. border-radius: 12rpx;
  395. .h2-title{
  396. font-size: 30rpx;
  397. font-weight: bold;
  398. }
  399. }
  400. .item-tips {
  401. margin: 24rpx 30rpx;
  402. .title {
  403. font-size: 30rpx;
  404. font-family: Microsoft YaHei;
  405. font-weight: 500;
  406. line-height: 30rpx;
  407. color: #CCB375;
  408. }
  409. .tip {
  410. margin-top: 16rpx;
  411. font-size: 24rpx;
  412. font-family: Microsoft YaHei;
  413. font-weight: 400;
  414. color: #999999;
  415. line-height: 24rpx;
  416. }
  417. }
  418. .picture-wrapper {
  419. margin: 30rpx 0 0;
  420. .bg {
  421. background: #F5F9FB;
  422. border-radius: 10rpx;
  423. padding: 40rpx 30rpx;
  424. display: flex;
  425. // align-items: center;
  426. justify-content: space-between;
  427. .name {
  428. padding-top: 30rpx;
  429. font-size: 32rpx;
  430. font-family: SourceHanSansSC, SourceHanSansSC;
  431. font-weight: 500;
  432. color: #111;
  433. line-height: 34rpx;
  434. }
  435. .value {
  436. margin-top: 20rpx;
  437. font-size: 22rpx;
  438. font-family: SourceHanSansSC, SourceHanSansSC;
  439. font-weight: 400;
  440. color: #999999;
  441. line-height: 24rpx;
  442. }
  443. .tip {
  444. margin-top: 20rpx;
  445. text-align: center;
  446. width: 100rpx;
  447. height: 30rpx;
  448. // background: rgba(204, 179, 117);
  449. border-radius: 6rpx;
  450. border: 1rpx solid #CCB375;
  451. .tip-value {
  452. font-size: 20rpx;
  453. font-family: Microsoft YaHei;
  454. font-weight: 400;
  455. color: #CCB375;
  456. line-height: 30rpx;
  457. opacity: 1;
  458. }
  459. }
  460. }
  461. .icon {
  462. width: 304rpx;
  463. height: 190rpx;
  464. background-image: var(--bgimg);
  465. background-size: 100% 100%;
  466. background-repeat: no-repeat;
  467. }
  468. }
  469. .shibie-wrapper {
  470. margin: 30rpx 30rpx;
  471. border-radius: 12rpx;
  472. background-color: #fff;
  473. box-sizing: border-box;
  474. overflow: hidden;
  475. }
  476. .from {
  477. background-color: #fff;
  478. padding: 24rpx 30rpx;
  479. ::v-deep .u-form-item {
  480. padding: 0;
  481. line-height: normal;
  482. .u-form-item__message {
  483. margin-bottom: 12rpx;
  484. }
  485. }
  486. .from_item {
  487. display: flex;
  488. flex-wrap: nowrap;
  489. justify-content: space-between;
  490. align-items: center;
  491. height: 80rpx;
  492. border-bottom: 1rpx solid #dcdcdc;
  493. .btn {
  494. font-size: 24rpx;
  495. font-family: Microsoft YaHei;
  496. font-weight: 400;
  497. color: #ffffff;
  498. background: #00b38b;
  499. border-radius: 10rpx;
  500. padding: 10rpx 15rpx;
  501. }
  502. ::v-deep .input {
  503. text-align: left;
  504. flex: 1;
  505. background: transparent;
  506. input {
  507. text-align: left;
  508. }
  509. }
  510. }
  511. .no-border{
  512. border-color: transparent;
  513. }
  514. }
  515. </style>