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.

user-card.vue 15KB

2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <template>
  2. <view class="main" :style="{height: height+'px'}">
  3. <view class="content">
  4. <view class="item-tips">
  5. <view class="title"> 上传后请核对识别信息 </view>
  6. <view class="tip"> 如有错误请及时手动修改 </view>
  7. </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="!state.form.userPosImgUrl" class="icon" :src="`${$imgUrl}applyCard/renxiang.png`">
  18. </image>
  19. <image v-else class="icon" :src="strReplace(state.form.userPosImgUrl)"></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="!state.form.userNegImgUrl" class="icon" :src="`${$imgUrl}applyCard/guohui.png`">
  32. </image>
  33. <image v-else class="icon" :src="strReplace(state.form.userNegImgUrl)"></image>
  34. </view>
  35. </view>
  36. <view class="shibie-wrapper">
  37. <view class="title"> 识别内容如下 </view>
  38. <u-form label-width="200" :model="state.form" ref="uForm">
  39. <u-form-item label="姓名">
  40. <u-input v-model="state.form.customerName" placeholder='请输入姓名' />
  41. </u-form-item>
  42. <!--
  43. <u-form-item label="性别">
  44. <u-input placeholder='请选择性别' v-model="state.form.gender" @click="userGenderAction()"
  45. type="select" />
  46. </u-form-item> -->
  47. <!-- <u-form-item label="身份证号">
  48. <u-input placeholder='请输入身份证' type="idcard" v-model="state.form.userIdNum" />
  49. </u-form-item> -->
  50. <u-form-item label="地址">
  51. <u-input placeholder='请输入地址' height='38' type='textarea' :autoHeight='true'
  52. v-model="state.form.address" />
  53. </u-form-item>
  54. <!-- <u-form-item label="证件有效期">
  55. <u-input v-model="state.form.begindate" type="select" />
  56. </u-form-item> -->
  57. <u-form-item label="手机号" class="phoneBox">
  58. <u-input placeholder='手机号' type="number" v-model="state.form.tel" maxlength="11" />
  59. <u-button type="success" size="mini" @click="getCode" v-if="waitTime==0">获取验证码</u-button>
  60. <text class="btn" v-else>{{waitTime}}后重试</text>
  61. </u-form-item>
  62. <u-form-item label="验证码">
  63. <u-input placeholder='请输入验证码' type="number" v-model="state.form.newMobileCode" />
  64. </u-form-item>
  65. </u-form>
  66. </view>
  67. <view class="green-tip">
  68. 如识别信息有误,请手动修改,确认无误后,点击下一步!
  69. </view>
  70. <view class="action">
  71. <button type="default" class="button" @click="savaHandle()">
  72. 下一步
  73. </button>
  74. </view>
  75. </view>
  76. </view>
  77. <view class="choice-takePhoto-wrap" v-if="state.isTakePhotoModeShow" @click="cancle">
  78. <view class="choice-takePhoto">
  79. <view @click.stop="takePhoto(state.choiceIndex)" style="border-radius: 20rpx 20rpx 0 0;">拍照</view>
  80. <view @click.stop="xiangce(state.choiceIndex)">从手机相册选择</view>
  81. <view @click.stop="cancle">取消</view>
  82. </view>
  83. </view>
  84. <viewfinder v-if="state.phoneType" :phoneType="state.phoneType" :images="state.images"
  85. :showStartPhoto="state.showImg" @confirmReturn="confirmReturn" @camera="camera"></viewfinder>
  86. </template>
  87. <script lang="ts" setup>
  88. import {
  89. pathToBase64
  90. } from "@/utils/image-tools/index.js";
  91. import {
  92. getItem
  93. } from "@/utils/storage.ts"
  94. import {
  95. reactive,
  96. ref
  97. } from "vue";
  98. import {
  99. msg,
  100. checkStr,
  101. strReplace
  102. } from "@/utils/utils";
  103. import {
  104. onLoad,
  105. onShow
  106. } from "@dcloudio/uni-app";
  107. import {
  108. etcOcrCard,
  109. userInfoChange,
  110. sendCode,
  111. envs,
  112. } from "@/utils/network/api.js";
  113. import {
  114. request
  115. } from "@/utils/network/request.js";
  116. import {
  117. stringToJson
  118. } from "@/utils/network/encryption.js";
  119. import {
  120. fileURL
  121. } from "@/datas/fileURL.js";
  122. import viewfinder from "../../../../components/viewfinder.vue"
  123. const height = uni.getSystemInfoSync().windowHeight
  124. const defHeadstockImg = `${fileURL}image/applyCard/renxiang.png`;
  125. const defInstallImg = `${fileURL}image/applyCard/guohui.png`;
  126. // const state = reactive({
  127. // headstockImg: null,
  128. // installImg: null,
  129. // });
  130. const state = reactive({
  131. phoneType: 0, // 1 身份证正面 2 身份证反面 3行驶证正面 4行驶证反面
  132. choiceIndex: 1, // 1 身份证正面 2 身份证反面
  133. isTakePhotoModeShow: false, //选择拍照方式是否出来
  134. showImg: true,
  135. images: "",
  136. genderList: [{
  137. value: '男',
  138. label: '男'
  139. },
  140. {
  141. value: '女',
  142. label: '女'
  143. }
  144. ],
  145. codeTips: "获取验证码",
  146. form: {
  147. // orderId: "", //订单ID
  148. customerId: '', //用户编号
  149. customerName: "", //开户人姓名
  150. openId: getItem('openId'),
  151. // userIdType: "101", //用户证件类型 101//身份证
  152. // userIdNum: "", //用户证件号码
  153. userPosImgUrl: "", //身份证正面
  154. userNegImgUrl: "", //身份证反面
  155. tel: "", //开户人手机号
  156. address: "", //开户人地址
  157. newMobileCode: "" //手机号验证码
  158. // sceneType: "", //用户协议支撑服务场景(发行服务机构和用户签订的协议)
  159. // channelId: "", //渠道id
  160. // gender: "",
  161. // customerIdVld: "",
  162. // agentName: "",
  163. // agentGender: "",
  164. // agentTel: '',
  165. // agentPhone: "",
  166. // agentIdType: "101",
  167. // agentIdNum: "",
  168. // agentPosImgUrl: "",
  169. // agentNegImgUrl: "",
  170. // proxyUrl: "",
  171. // agentAddress: "",
  172. // agentIdVld: '',
  173. }
  174. })
  175. // const strReplace = (str : string) => {
  176. // let imgUrl = str.replace("http://192.168.101.145:9000", envs[process.env.NODE_ENV].baseUrl);
  177. // imgUrl = imgUrl.replace("http://100.64.2.113:9000", envs[process.env.NODE_ENV].baseUrl);
  178. // return imgUrl;
  179. // };
  180. const getCode = () => {
  181. console.log(123);
  182. if (checkStr(state.form.tel, "mobile")) {
  183. sendCodeApi()
  184. codeInterval()
  185. } else {
  186. uni.showToast({
  187. title: '请输入正确的手机号',
  188. icon: 'none'
  189. });
  190. }
  191. }
  192. let waitTime = ref(0)
  193. //倒计时函数
  194. const codeInterval = () => {
  195. waitTime.value = 60
  196. let timer = setInterval(() => {
  197. if (waitTime.value == 1) {
  198. clearInterval(timer)
  199. }
  200. waitTime.value -= 1
  201. }, 1000)
  202. }
  203. // 发送验证码
  204. const sendCodeApi = (type) => {
  205. //参数说明
  206. let options = {
  207. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  208. data: {
  209. mobile: state.form.tel
  210. }, //请求参数
  211. method: "POST", //提交方式(默认POST)
  212. showLoading: true, //是否显示加载中(默认显示)
  213. };
  214. //调用方式
  215. request(sendCode, options)
  216. .then((res) => {
  217. let data = stringToJson(res.bizContent)
  218. console.log(data, "#################");
  219. if (data.info == "成功.") {
  220. console.log('######################CCCCCCCCCCCCCCCCC');
  221. }
  222. })
  223. .catch((err) => {
  224. console.log(err);
  225. });
  226. }
  227. //选择图片
  228. //orc接口调用
  229. // const cardImageOcr = (val : any) => {
  230. // console.log("点击了");
  231. // var imageType = val;
  232. // uni.chooseImage({
  233. // count: 1, //只能选取一张照片
  234. // sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  235. // sourceType: ["camera", "album"], //从相册选择
  236. // success: function (res) {
  237. // pathToBase64(res.tempFilePaths[0])
  238. // .then((path) => {
  239. // console.log(path);
  240. // console.log("哈哈哈");
  241. // var data = {
  242. // source: "1",
  243. // agencyId: "52010106004",
  244. // imageType: imageType,
  245. // fileName: res.tempFilePaths[0],
  246. // imageBase64: path,
  247. // };
  248. // const options = {
  249. // type: 2,
  250. // data: data,
  251. // method: "POST",
  252. // showLoading: true,
  253. // };
  254. // request(etcOcrCard, options).then((res) => {
  255. // // const data = stringToJson(res.bizContent);
  256. // const data = JSON.parse(res.bizContent)
  257. // if (val === "1") {
  258. // state.form.customerName = data.name;
  259. // state.form.userPosImgUrl = data.imageUrl;
  260. // state.form.address = data.address;
  261. // } else {
  262. // state.form.customerIdVld = data.enddate;
  263. // state.form.userNegImgUrl = data.imageUrl;
  264. // }
  265. // });
  266. // })
  267. // .catch((error) => { });
  268. // },
  269. // });
  270. // };
  271. //下一步
  272. const savaHandle = () => {
  273. console.log(state.form);
  274. if (!state.form.userPosImgUrl) {
  275. msg("请上传身份证正面")
  276. return;
  277. }
  278. if (!state.form.userNegImgUrl) {
  279. msg("请上传身份证反面")
  280. return;
  281. }
  282. if (!state.form.customerName) {
  283. msg("请输入姓名")
  284. return;
  285. }
  286. if (!state.form.address) {
  287. msg("请输入地址")
  288. return;
  289. }
  290. if (!checkStr(state.form.tel, "mobile")) {
  291. msg("请输入正确的手机号")
  292. return;
  293. }
  294. if (!state.form.newMobileCode) {
  295. msg("请输入验证码")
  296. return;
  297. }
  298. const options = {
  299. type: 2,
  300. data: state.form,
  301. method: "POST",
  302. showLoading: true,
  303. };
  304. request(userInfoChange, options).then((res) => {
  305. // const data = stringToJson(res.bizContent);
  306. const data = JSON.parse(res.bizContent)
  307. console.log(data);
  308. uni.navigateBack({
  309. delta: 1
  310. });
  311. });
  312. }
  313. onLoad((options) => {
  314. console.log(options.customerId);
  315. state.form.customerId = options.customerId
  316. })
  317. const takePhotoMode = (index) => {
  318. console.log("index", index)
  319. state.isTakePhotoModeShow = true
  320. state.choiceIndex = index
  321. }
  322. const camera = () => {
  323. state.phoneType = 0
  324. }
  325. const xiangce = (val) => {
  326. console.log("val", val)
  327. var imageType = val;
  328. uni.chooseImage({
  329. count: 1, //只能选取一张照片
  330. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  331. sourceType: ["album"], //从相册选择
  332. success: function (res) {
  333. state.showImg = false
  334. state.images = res.tempFilePaths[0]
  335. state.phoneType = state.choiceIndex
  336. state.isTakePhotoModeShow = false
  337. },
  338. })
  339. }
  340. const takePhoto = (val) => {
  341. console.log("拍照", val)
  342. state.phoneType = val;
  343. }
  344. const confirmReturn = (val) => {
  345. state.phoneType = 0
  346. state.isTakePhotoModeShow = false
  347. var imageType = state.choiceIndex;
  348. console.log("图片地址val", val.tempImagePath)
  349. uni.uploadFile({
  350. url: 'https://qtzl.etcjz.cn/minIo/upload', //仅为示例,非真实的接口地址
  351. filePath: val.tempImagePath,
  352. name: 'file',
  353. formData: {
  354. 'user': 'test',
  355. "bucket": 'default-bucket'
  356. },
  357. success: (uploadFileRes) => {
  358. let uploadFileImage = 'http://100.64.2.113:9000' + '/default-bucket/' + JSON.parse(uploadFileRes.data).data.ossFilePath
  359. console.log("111", JSON.parse(uploadFileRes.data).data.ossFilePath);
  360. var data = {
  361. source: "1",
  362. agencyId: "52010106004",
  363. imageType: imageType,
  364. fileName: val.tempImagePath,
  365. url: uploadFileImage
  366. };
  367. const options = {
  368. type: 2,
  369. data: data,
  370. method: "POST",
  371. showLoading: true,
  372. };
  373. request(etcOcrCard, options).then((res) => {
  374. const data = stringToJson(res.bizContent);
  375. if (state.choiceIndex === "1") {
  376. state.form.customerName = data.name;
  377. state.form.userPosImgUrl = data.imageUrl;
  378. state.form.address = data.address;
  379. } else {
  380. state.form.customerIdVld = data.enddate;
  381. state.form.userNegImgUrl = data.imageUrl;
  382. }
  383. state.isTakePhotoModeShow = false
  384. });
  385. },
  386. })
  387. }
  388. const cancle = () => {
  389. state.isTakePhotoModeShow = false
  390. }
  391. </script>
  392. <style>
  393. page {
  394. background: #eef7f7;
  395. }
  396. </style>
  397. <style lang="scss" scoped>
  398. ::v-deep .u-size-mini {
  399. white-space: nowrap;
  400. }
  401. .main {
  402. // overflow: hidden;
  403. .content {
  404. padding: 50rpx 30rpx 50rpx 30rpx;
  405. .action {
  406. padding-left: 20rpx;
  407. padding-right: 20rpx;
  408. padding-bottom: 30rpx;
  409. .button {
  410. height: 80rpx;
  411. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  412. border-radius: 40rpx;
  413. font-size: 32rpx;
  414. font-weight: 400;
  415. color: #ffffff;
  416. line-height: 80rpx;
  417. }
  418. }
  419. .item-tips {
  420. .title {
  421. font-size: 30rpx;
  422. font-family: Microsoft YaHei;
  423. font-weight: 400;
  424. color: #000000;
  425. line-height: 24rpx;
  426. }
  427. .tip {
  428. margin-top: 16rpx;
  429. font-size: 24rpx;
  430. font-family: Microsoft YaHei;
  431. font-weight: 400;
  432. color: #999999;
  433. line-height: 24rpx;
  434. }
  435. }
  436. .picture-wrapper {
  437. margin-top: 40rpx;
  438. .bg {
  439. background: #ffffff;
  440. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  441. border-radius: 20rpx;
  442. padding: 40rpx;
  443. display: flex;
  444. // align-items: center;
  445. justify-content: space-between;
  446. .name {
  447. font-size: 34rpx;
  448. font-family: Microsoft YaHei;
  449. font-weight: 400;
  450. color: #000000;
  451. line-height: 34rpx;
  452. }
  453. .value {
  454. margin-top: 20rpx;
  455. font-size: 24rpx;
  456. font-family: Microsoft YaHei;
  457. font-weight: 400;
  458. color: #999999;
  459. line-height: 24rpx;
  460. }
  461. .tip {
  462. margin-top: 20rpx;
  463. text-align: center;
  464. width: 110rpx;
  465. height: 40rpx;
  466. background: rgba(33, 190, 177, 0.2);
  467. border-radius: 6rpx;
  468. .tip-value {
  469. font-size: 20rpx;
  470. font-family: Microsoft YaHei;
  471. font-weight: 400;
  472. color: #0a8f8a;
  473. line-height: 40rpx;
  474. opacity: 1;
  475. }
  476. }
  477. }
  478. .icon {
  479. width: 294rpx;
  480. height: 188rpx;
  481. }
  482. }
  483. .shibie-wrapper {
  484. margin-top: 40rpx;
  485. background: #fff;
  486. padding: 40rpx 30rpx;
  487. border-radius: 20rpx;
  488. box-shadow: 0 4rpx 13rpx 3rpx rgba(223, 223, 223, .8);
  489. .title {
  490. font-size: 30rpx;
  491. font-family: Microsoft YaHei;
  492. font-weight: 400;
  493. color: #000000;
  494. line-height: 30rpx;
  495. }
  496. .phoneBox {
  497. ::v-deep .u-form-item--right__content__slot {
  498. display: flex;
  499. .btn {
  500. flex: 1;
  501. background: transparent;
  502. font-size: 30rpx;
  503. color: #15E5C1;
  504. z-index: 999;
  505. }
  506. }
  507. }
  508. }
  509. .buchong-wrapper {
  510. margin-top: 60rpx;
  511. .title {
  512. font-size: 30rpx;
  513. font-family: Microsoft YaHei;
  514. font-weight: 400;
  515. color: #000000;
  516. line-height: 30rpx;
  517. }
  518. }
  519. .green-tip {
  520. margin-top: 50rpx;
  521. font-size: 24rpx;
  522. font-family: Microsoft YaHei;
  523. font-weight: 400;
  524. color: #00b38b;
  525. line-height: 24rpx;
  526. margin-bottom: 60rpx;
  527. }
  528. }
  529. }
  530. .choice-takePhoto {
  531. position: absolute;
  532. bottom: 0;
  533. background-color: white;
  534. width: 100%;
  535. border-radius: 20rpx 20rpx 0 0;
  536. }
  537. .choice-takePhoto>view:first-child {
  538. text-align: center;
  539. height: 80rpx;
  540. line-height: 80rpx;
  541. border-bottom: 1rpx solid rgba(127, 127, 127, 0.3);
  542. background-color: white;
  543. }
  544. .choice-takePhoto>view:last-child {
  545. text-align: center;
  546. height: 80rpx;
  547. line-height: 80rpx;
  548. border-top: 6rpx solid rgba(127, 127, 127, 0.1);
  549. background-color: white;
  550. }
  551. .choice-takePhoto>view {
  552. text-align: center;
  553. height: 80rpx;
  554. line-height: 80rpx;
  555. background-color: white;
  556. }
  557. .choice-takePhoto-wrap {
  558. width: 100%;
  559. height: 100vh;
  560. background-color: rgba(127, 127, 127, 0.2);
  561. position: fixed;
  562. left: 0;
  563. top: 0;
  564. z-index: 11111;
  565. }
  566. </style>