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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  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 getCode = () => {
  174. console.log(123);
  175. if (checkStr(state.form.tel, "mobile")) {
  176. sendCodeApi()
  177. codeInterval()
  178. } else {
  179. uni.showToast({
  180. title: '请输入正确的手机号',
  181. icon: 'none'
  182. });
  183. }
  184. }
  185. let waitTime = ref(0)
  186. //倒计时函数
  187. const codeInterval = () => {
  188. waitTime.value = 60
  189. let timer = setInterval(() => {
  190. if (waitTime.value == 1) {
  191. clearInterval(timer)
  192. }
  193. waitTime.value -= 1
  194. }, 1000)
  195. }
  196. // 发送验证码
  197. const sendCodeApi = (type) => {
  198. //参数说明
  199. let options = {
  200. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  201. data: {
  202. mobile: state.form.tel
  203. }, //请求参数
  204. method: "POST", //提交方式(默认POST)
  205. showLoading: true, //是否显示加载中(默认显示)
  206. };
  207. //调用方式
  208. request(sendCode, options)
  209. .then((res) => {
  210. let data = stringToJson(res.bizContent)
  211. console.log(data, "#################");
  212. if (data.info == "成功.") {
  213. console.log('######################CCCCCCCCCCCCCCCCC');
  214. }
  215. })
  216. .catch((err) => {
  217. console.log(err);
  218. });
  219. }
  220. //下一步
  221. const savaHandle = () => {
  222. console.log(state.form);
  223. if (!state.form.userPosImgUrl) {
  224. msg("请上传身份证正面")
  225. return;
  226. }
  227. if (!state.form.userNegImgUrl) {
  228. msg("请上传身份证反面")
  229. return;
  230. }
  231. if (!state.form.customerName) {
  232. msg("请输入姓名")
  233. return;
  234. }
  235. if (!state.form.address) {
  236. msg("请输入地址")
  237. return;
  238. }
  239. if (!checkStr(state.form.tel, "mobile")) {
  240. msg("请输入正确的手机号")
  241. return;
  242. }
  243. if (!state.form.newMobileCode) {
  244. msg("请输入验证码")
  245. return;
  246. }
  247. const options = {
  248. type: 2,
  249. data: state.form,
  250. method: "POST",
  251. showLoading: true,
  252. };
  253. request(userInfoChange, options).then((res) => {
  254. const data = JSON.parse(res.bizContent)
  255. msg('个人信息变更成功')
  256. setTimeout(() => {
  257. uni.navigateBack({
  258. delta: 1
  259. });
  260. }, 1500)
  261. console.log(data);
  262. });
  263. }
  264. onLoad((options) => {
  265. console.log(options.customerId);
  266. state.form.customerId = options.customerId
  267. })
  268. const takePhotoMode = (index) => {
  269. console.log("index", index)
  270. state.isTakePhotoModeShow = true
  271. state.choiceIndex = index
  272. }
  273. const camera = () => {
  274. state.phoneType = 0
  275. }
  276. const xiangce = (val) => {
  277. console.log("val", val)
  278. var imageType = val;
  279. uni.chooseImage({
  280. count: 1, //只能选取一张照片
  281. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  282. sourceType: ["album"], //从相册选择
  283. success: function (res) {
  284. state.showImg = false
  285. state.images = res.tempFilePaths[0]
  286. state.phoneType = state.choiceIndex
  287. state.isTakePhotoModeShow = false
  288. },
  289. })
  290. }
  291. const takePhoto = (val) => {
  292. console.log("拍照", val)
  293. state.phoneType = val;
  294. state.showImg = true;
  295. }
  296. const confirmReturn = (val) => {
  297. state.phoneType = 0
  298. state.isTakePhotoModeShow = false
  299. var imageType = state.choiceIndex;
  300. console.log("图片地址val", val.tempImagePath)
  301. uploadFile(val.tempImagePath, imageType, etcOcrCard).then((data) => {
  302. if (state.choiceIndex === "1") {
  303. state.form.customerName = data.name;
  304. state.form.userPosImgUrl = data.imageUrl;
  305. state.form.address = data.address;
  306. } else {
  307. state.form.customerIdVld = data.enddate;
  308. state.form.userNegImgUrl = data.imageUrl;
  309. }
  310. state.isTakePhotoModeShow = false
  311. })
  312. }
  313. const cancle = () => {
  314. state.isTakePhotoModeShow = false
  315. }
  316. </script>
  317. <style>
  318. page {
  319. background: #eef7f7;
  320. }
  321. </style>
  322. <style lang="scss" scoped>
  323. ::v-deep .u-size-mini {
  324. white-space: nowrap;
  325. }
  326. .main {
  327. .content {
  328. padding: 50rpx 30rpx 50rpx 30rpx;
  329. .action {
  330. padding-left: 20rpx;
  331. padding-right: 20rpx;
  332. padding-bottom: 30rpx;
  333. .button {
  334. height: 80rpx;
  335. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  336. border-radius: 40rpx;
  337. font-size: 32rpx;
  338. font-weight: 400;
  339. color: #ffffff;
  340. line-height: 80rpx;
  341. }
  342. }
  343. .item-tips {
  344. .title {
  345. font-size: 30rpx;
  346. font-family: Microsoft YaHei;
  347. font-weight: 400;
  348. color: #000000;
  349. line-height: 24rpx;
  350. }
  351. .tip {
  352. margin-top: 16rpx;
  353. font-size: 24rpx;
  354. font-family: Microsoft YaHei;
  355. font-weight: 400;
  356. color: #999999;
  357. line-height: 24rpx;
  358. }
  359. }
  360. .picture-wrapper {
  361. margin-top: 40rpx;
  362. .bg {
  363. background: #ffffff;
  364. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  365. border-radius: 20rpx;
  366. padding: 40rpx;
  367. display: flex;
  368. justify-content: space-between;
  369. .name {
  370. font-size: 34rpx;
  371. font-family: Microsoft YaHei;
  372. font-weight: 400;
  373. color: #000000;
  374. line-height: 34rpx;
  375. }
  376. .value {
  377. margin-top: 20rpx;
  378. font-size: 24rpx;
  379. font-family: Microsoft YaHei;
  380. font-weight: 400;
  381. color: #999999;
  382. line-height: 24rpx;
  383. }
  384. .tip {
  385. margin-top: 20rpx;
  386. text-align: center;
  387. width: 110rpx;
  388. height: 40rpx;
  389. background: rgba(33, 190, 177, 0.2);
  390. border-radius: 6rpx;
  391. .tip-value {
  392. font-size: 20rpx;
  393. font-family: Microsoft YaHei;
  394. font-weight: 400;
  395. color: #0a8f8a;
  396. line-height: 40rpx;
  397. opacity: 1;
  398. }
  399. }
  400. }
  401. .icon {
  402. width: 294rpx;
  403. height: 188rpx;
  404. }
  405. }
  406. .shibie-wrapper {
  407. margin-top: 40rpx;
  408. background: #fff;
  409. padding: 40rpx 30rpx;
  410. border-radius: 20rpx;
  411. box-shadow: 0 4rpx 13rpx 3rpx rgba(223, 223, 223, .8);
  412. .title {
  413. font-size: 30rpx;
  414. font-family: Microsoft YaHei;
  415. font-weight: 400;
  416. color: #000000;
  417. line-height: 30rpx;
  418. }
  419. .phoneBox {
  420. ::v-deep .u-form-item--right__content__slot {
  421. display: flex;
  422. .btn {
  423. flex: 1;
  424. background: transparent;
  425. font-size: 30rpx;
  426. color: #15E5C1;
  427. z-index: 999;
  428. }
  429. }
  430. }
  431. }
  432. .buchong-wrapper {
  433. margin-top: 60rpx;
  434. .title {
  435. font-size: 30rpx;
  436. font-family: Microsoft YaHei;
  437. font-weight: 400;
  438. color: #000000;
  439. line-height: 30rpx;
  440. }
  441. }
  442. .green-tip {
  443. margin-top: 50rpx;
  444. font-size: 24rpx;
  445. font-family: Microsoft YaHei;
  446. font-weight: 400;
  447. color: #00b38b;
  448. line-height: 24rpx;
  449. margin-bottom: 60rpx;
  450. }
  451. }
  452. }
  453. .choice-takePhoto {
  454. position: absolute;
  455. bottom: 0;
  456. background-color: white;
  457. width: 100%;
  458. border-radius: 20rpx 20rpx 0 0;
  459. }
  460. .choice-takePhoto>view:first-child {
  461. text-align: center;
  462. height: 80rpx;
  463. line-height: 80rpx;
  464. border-bottom: 1rpx solid rgba(127, 127, 127, 0.3);
  465. background-color: white;
  466. }
  467. .choice-takePhoto>view:last-child {
  468. text-align: center;
  469. height: 80rpx;
  470. line-height: 80rpx;
  471. border-top: 6rpx solid rgba(127, 127, 127, 0.1);
  472. background-color: white;
  473. }
  474. .choice-takePhoto>view {
  475. text-align: center;
  476. height: 80rpx;
  477. line-height: 80rpx;
  478. background-color: white;
  479. }
  480. .choice-takePhoto-wrap {
  481. width: 100%;
  482. height: 100vh;
  483. background-color: rgba(127, 127, 127, 0.2);
  484. position: fixed;
  485. left: 0;
  486. top: 0;
  487. z-index: 11111;
  488. }
  489. </style>