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.

user-card.vue 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  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. getItem
  90. } from "@/utils/storage.ts"
  91. import {
  92. reactive,
  93. ref
  94. } from "vue";
  95. import {
  96. msg,
  97. checkStr,
  98. strReplace,
  99. uploadFile
  100. } from "@/utils/utils";
  101. import {
  102. onLoad,
  103. onShow
  104. } from "@dcloudio/uni-app";
  105. import {
  106. etcOcrCard,
  107. userInfoChange,
  108. sendCode,
  109. envs,
  110. } from "@/utils/network/api.js";
  111. import {
  112. request
  113. } from "@/utils/network/request.js";
  114. import {
  115. stringToJson
  116. } from "@/utils/network/encryption.js";
  117. import {
  118. fileURL
  119. } from "@/datas/fileURL.js";
  120. import viewfinder from "../../../../components/viewfinder.vue"
  121. const height = uni.getSystemInfoSync().windowHeight
  122. const defHeadstockImg = `${fileURL}image/applyCard/renxiang.png`;
  123. const defInstallImg = `${fileURL}image/applyCard/guohui.png`;
  124. // const state = reactive({
  125. // headstockImg: null,
  126. // installImg: null,
  127. // });
  128. const state = reactive({
  129. phoneType: 0, // 1 身份证正面 2 身份证反面 3行驶证正面 4行驶证反面
  130. choiceIndex: 1, // 1 身份证正面 2 身份证反面
  131. isTakePhotoModeShow: false, //选择拍照方式是否出来
  132. showImg: true,
  133. images: "",
  134. genderList: [{
  135. value: '男',
  136. label: '男'
  137. },
  138. {
  139. value: '女',
  140. label: '女'
  141. }
  142. ],
  143. codeTips: "获取验证码",
  144. form: {
  145. // orderId: "", //订单ID
  146. customerId: '', //用户编号
  147. customerName: "", //开户人姓名
  148. openId: getItem('openId'),
  149. // userIdType: "101", //用户证件类型 101//身份证
  150. // userIdNum: "", //用户证件号码
  151. userPosImgUrl: "", //身份证正面
  152. userNegImgUrl: "", //身份证反面
  153. tel: "", //开户人手机号
  154. address: "", //开户人地址
  155. newMobileCode: "" //手机号验证码
  156. // sceneType: "", //用户协议支撑服务场景(发行服务机构和用户签订的协议)
  157. // channelId: "", //渠道id
  158. // gender: "",
  159. // customerIdVld: "",
  160. // agentName: "",
  161. // agentGender: "",
  162. // agentTel: '',
  163. // agentPhone: "",
  164. // agentIdType: "101",
  165. // agentIdNum: "",
  166. // agentPosImgUrl: "",
  167. // agentNegImgUrl: "",
  168. // proxyUrl: "",
  169. // agentAddress: "",
  170. // agentIdVld: '',
  171. }
  172. })
  173. // const strReplace = (str : string) => {
  174. // let imgUrl = str.replace("http://192.168.101.145:9000", envs[process.env.NODE_ENV].baseUrl);
  175. // imgUrl = imgUrl.replace("http://100.64.2.113:9000", envs[process.env.NODE_ENV].baseUrl);
  176. // return imgUrl;
  177. // };
  178. const getCode = () => {
  179. console.log(123);
  180. if (checkStr(state.form.tel, "mobile")) {
  181. sendCodeApi()
  182. codeInterval()
  183. } else {
  184. uni.showToast({
  185. title: '请输入正确的手机号',
  186. icon: 'none'
  187. });
  188. }
  189. }
  190. let waitTime = ref(0)
  191. //倒计时函数
  192. const codeInterval = () => {
  193. waitTime.value = 60
  194. let timer = setInterval(() => {
  195. if (waitTime.value == 1) {
  196. clearInterval(timer)
  197. }
  198. waitTime.value -= 1
  199. }, 1000)
  200. }
  201. // 发送验证码
  202. const sendCodeApi = (type) => {
  203. //参数说明
  204. let options = {
  205. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  206. data: {
  207. mobile: state.form.tel
  208. }, //请求参数
  209. method: "POST", //提交方式(默认POST)
  210. showLoading: true, //是否显示加载中(默认显示)
  211. };
  212. //调用方式
  213. request(sendCode, options)
  214. .then((res) => {
  215. let data = stringToJson(res.bizContent)
  216. console.log(data, "#################");
  217. if (data.info == "成功.") {
  218. console.log('######################CCCCCCCCCCCCCCCCC');
  219. }
  220. })
  221. .catch((err) => {
  222. console.log(err);
  223. });
  224. }
  225. //下一步
  226. const savaHandle = () => {
  227. console.log(state.form);
  228. if (!state.form.userPosImgUrl) {
  229. msg("请上传身份证正面")
  230. return;
  231. }
  232. if (!state.form.userNegImgUrl) {
  233. msg("请上传身份证反面")
  234. return;
  235. }
  236. if (!state.form.customerName) {
  237. msg("请输入姓名")
  238. return;
  239. }
  240. if (!state.form.address) {
  241. msg("请输入地址")
  242. return;
  243. }
  244. if (!checkStr(state.form.tel, "mobile")) {
  245. msg("请输入正确的手机号")
  246. return;
  247. }
  248. if (!state.form.newMobileCode) {
  249. msg("请输入验证码")
  250. return;
  251. }
  252. const options = {
  253. type: 2,
  254. data: state.form,
  255. method: "POST",
  256. showLoading: true,
  257. };
  258. request(userInfoChange, options).then((res) => {
  259. // const data = stringToJson(res.bizContent);
  260. const data = JSON.parse(res.bizContent)
  261. console.log(data);
  262. uni.navigateBack({
  263. delta: 1
  264. });
  265. });
  266. }
  267. onLoad((options) => {
  268. console.log(options.customerId);
  269. state.form.customerId = options.customerId
  270. })
  271. const takePhotoMode = (index) => {
  272. console.log("index", index)
  273. state.isTakePhotoModeShow = true
  274. state.choiceIndex = index
  275. }
  276. const camera = () => {
  277. state.phoneType = 0
  278. }
  279. const xiangce = (val) => {
  280. console.log("val", val)
  281. var imageType = val;
  282. uni.chooseImage({
  283. count: 1, //只能选取一张照片
  284. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  285. sourceType: ["album"], //从相册选择
  286. success: function (res) {
  287. state.showImg = false
  288. state.images = res.tempFilePaths[0]
  289. state.phoneType = state.choiceIndex
  290. state.isTakePhotoModeShow = false
  291. },
  292. })
  293. }
  294. const takePhoto = (val) => {
  295. console.log("拍照", val)
  296. state.phoneType = val;
  297. state.showImg = true;
  298. }
  299. const confirmReturn = (val) => {
  300. state.phoneType = 0
  301. state.isTakePhotoModeShow = false
  302. var imageType = state.choiceIndex;
  303. console.log("图片地址val", val.tempImagePath)
  304. uploadFile(val.tempImagePath, imageType, etcOcrCard).then((data) => {
  305. if (state.choiceIndex === "1") {
  306. state.form.customerName = data.name;
  307. state.form.userPosImgUrl = data.imageUrl;
  308. state.form.address = data.address;
  309. } else {
  310. state.form.customerIdVld = data.enddate;
  311. state.form.userNegImgUrl = data.imageUrl;
  312. }
  313. state.isTakePhotoModeShow = false
  314. })
  315. }
  316. const cancle = () => {
  317. state.isTakePhotoModeShow = false
  318. }
  319. </script>
  320. <style>
  321. page {
  322. background: #eef7f7;
  323. }
  324. </style>
  325. <style lang="scss" scoped>
  326. ::v-deep .u-size-mini {
  327. white-space: nowrap;
  328. }
  329. .main {
  330. // overflow: hidden;
  331. .content {
  332. padding: 50rpx 30rpx 50rpx 30rpx;
  333. .action {
  334. padding-left: 20rpx;
  335. padding-right: 20rpx;
  336. padding-bottom: 30rpx;
  337. .button {
  338. height: 80rpx;
  339. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  340. border-radius: 40rpx;
  341. font-size: 32rpx;
  342. font-weight: 400;
  343. color: #ffffff;
  344. line-height: 80rpx;
  345. }
  346. }
  347. .item-tips {
  348. .title {
  349. font-size: 30rpx;
  350. font-family: Microsoft YaHei;
  351. font-weight: 400;
  352. color: #000000;
  353. line-height: 24rpx;
  354. }
  355. .tip {
  356. margin-top: 16rpx;
  357. font-size: 24rpx;
  358. font-family: Microsoft YaHei;
  359. font-weight: 400;
  360. color: #999999;
  361. line-height: 24rpx;
  362. }
  363. }
  364. .picture-wrapper {
  365. margin-top: 40rpx;
  366. .bg {
  367. background: #ffffff;
  368. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  369. border-radius: 20rpx;
  370. padding: 40rpx;
  371. display: flex;
  372. // align-items: center;
  373. justify-content: space-between;
  374. .name {
  375. font-size: 34rpx;
  376. font-family: Microsoft YaHei;
  377. font-weight: 400;
  378. color: #000000;
  379. line-height: 34rpx;
  380. }
  381. .value {
  382. margin-top: 20rpx;
  383. font-size: 24rpx;
  384. font-family: Microsoft YaHei;
  385. font-weight: 400;
  386. color: #999999;
  387. line-height: 24rpx;
  388. }
  389. .tip {
  390. margin-top: 20rpx;
  391. text-align: center;
  392. width: 110rpx;
  393. height: 40rpx;
  394. background: rgba(33, 190, 177, 0.2);
  395. border-radius: 6rpx;
  396. .tip-value {
  397. font-size: 20rpx;
  398. font-family: Microsoft YaHei;
  399. font-weight: 400;
  400. color: #0a8f8a;
  401. line-height: 40rpx;
  402. opacity: 1;
  403. }
  404. }
  405. }
  406. .icon {
  407. width: 294rpx;
  408. height: 188rpx;
  409. }
  410. }
  411. .shibie-wrapper {
  412. margin-top: 40rpx;
  413. background: #fff;
  414. padding: 40rpx 30rpx;
  415. border-radius: 20rpx;
  416. box-shadow: 0 4rpx 13rpx 3rpx rgba(223, 223, 223, .8);
  417. .title {
  418. font-size: 30rpx;
  419. font-family: Microsoft YaHei;
  420. font-weight: 400;
  421. color: #000000;
  422. line-height: 30rpx;
  423. }
  424. .phoneBox {
  425. ::v-deep .u-form-item--right__content__slot {
  426. display: flex;
  427. .btn {
  428. flex: 1;
  429. background: transparent;
  430. font-size: 30rpx;
  431. color: #15E5C1;
  432. z-index: 999;
  433. }
  434. }
  435. }
  436. }
  437. .buchong-wrapper {
  438. margin-top: 60rpx;
  439. .title {
  440. font-size: 30rpx;
  441. font-family: Microsoft YaHei;
  442. font-weight: 400;
  443. color: #000000;
  444. line-height: 30rpx;
  445. }
  446. }
  447. .green-tip {
  448. margin-top: 50rpx;
  449. font-size: 24rpx;
  450. font-family: Microsoft YaHei;
  451. font-weight: 400;
  452. color: #00b38b;
  453. line-height: 24rpx;
  454. margin-bottom: 60rpx;
  455. }
  456. }
  457. }
  458. .choice-takePhoto {
  459. position: absolute;
  460. bottom: 0;
  461. background-color: white;
  462. width: 100%;
  463. border-radius: 20rpx 20rpx 0 0;
  464. }
  465. .choice-takePhoto>view:first-child {
  466. text-align: center;
  467. height: 80rpx;
  468. line-height: 80rpx;
  469. border-bottom: 1rpx solid rgba(127, 127, 127, 0.3);
  470. background-color: white;
  471. }
  472. .choice-takePhoto>view:last-child {
  473. text-align: center;
  474. height: 80rpx;
  475. line-height: 80rpx;
  476. border-top: 6rpx solid rgba(127, 127, 127, 0.1);
  477. background-color: white;
  478. }
  479. .choice-takePhoto>view {
  480. text-align: center;
  481. height: 80rpx;
  482. line-height: 80rpx;
  483. background-color: white;
  484. }
  485. .choice-takePhoto-wrap {
  486. width: 100%;
  487. height: 100vh;
  488. background-color: rgba(127, 127, 127, 0.2);
  489. position: fixed;
  490. left: 0;
  491. top: 0;
  492. z-index: 11111;
  493. }
  494. </style>