Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

user-card-ETC.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  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. <u-form-item label="地址">
  43. <u-input placeholder='请输入地址' height='38' type='textarea' :autoHeight='true'
  44. v-model="state.form.address" />
  45. </u-form-item> -->
  46. <u-form-item label="手机号" class="phoneBox">
  47. <u-input placeholder='手机号' type="number" v-model="state.form.newMobile" maxlength="11" />
  48. <text @click="getCode" v-if="waitTime==0" class="search">获取验证码</text>
  49. <text class="btn" v-else>{{waitTime}}后重试</text>
  50. </u-form-item>
  51. <u-form-item label="验证码">
  52. <u-input placeholder='请输入验证码' type="number" v-model="state.form.newMobileCode" />
  53. </u-form-item>
  54. </u-form>
  55. </view>
  56. <view class="green-tip">
  57. 如识别信息有误,请手动修改,确认无误后,点击下一步!
  58. </view>
  59. <view class="action">
  60. <button type="default" class="button" @click="savaHandle()">
  61. 下一步
  62. </button>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="choice-takePhoto-wrap" v-if="state.isTakePhotoModeShow" @click="cancle">
  67. <view class="choice-takePhoto">
  68. <view @click.stop="takePhoto(state.choiceIndex)" style="border-radius: 20rpx 20rpx 0 0;">拍照</view>
  69. <view @click.stop="xiangce(state.choiceIndex)">从手机相册选择</view>
  70. <view @click.stop="cancle">取消</view>
  71. </view>
  72. </view>
  73. <viewfinder v-if="state.phoneType" :phoneType="state.phoneType" :images="state.images"
  74. :showStartPhoto="state.showImg" @confirmReturn="confirmReturn" @camera="camera"></viewfinder>
  75. </template>
  76. <script lang="ts" setup>
  77. import {
  78. getItem
  79. } from "@/utils/storage.ts"
  80. import {
  81. reactive,
  82. ref
  83. } from "vue";
  84. import {
  85. msg,
  86. checkStr,
  87. strReplace,
  88. uploadFile,
  89. chooseImageCompress
  90. } from "@/utils/utils";
  91. import {
  92. onLoad
  93. } from "@dcloudio/uni-app";
  94. import {
  95. idCardOcr,
  96. mobileChangeProfile,
  97. newMobileSmsCode,
  98. } from "@/utils/network/api.js";
  99. import { requestNew} from "@/utils/network/request.js";
  100. import {
  101. stringToJson
  102. } from "@/utils/network/encryption.js";
  103. import {
  104. fileURL
  105. } from "@/datas/fileURL.js";
  106. import viewfinder from "../../../../components/viewfinder.vue"
  107. const height = uni.getSystemInfoSync().windowHeight
  108. const defHeadstockImg = `${fileURL}image/applyCard/renxiang.png`;
  109. const defInstallImg = `${fileURL}image/applyCard/guohui.png`;
  110. const state = reactive({
  111. phoneType: 0, // 1 身份证正面 2 身份证反面 3行驶证正面 4行驶证反面
  112. choiceIndex: 1, // 1 身份证正面 2 身份证反面
  113. isTakePhotoModeShow: false, //选择拍照方式是否出来
  114. showImg: true,
  115. images: "",
  116. genderList: [{
  117. value: '男',
  118. label: '男'
  119. },
  120. {
  121. value: '女',
  122. label: '女'
  123. }
  124. ],
  125. codeTips: "获取验证码",
  126. form: {
  127. customerId: '', //用户编号
  128. customerName: "", //开户人姓名
  129. openId: getItem('openId'),
  130. userPosImgUrl: "", //身份证正面
  131. userNegImgUrl: "", //身份证反面
  132. newMobile: "", //开户人手机号
  133. address: "", //开户人地址
  134. newMobileCode: "" //手机号验证码
  135. }
  136. })
  137. const getCode = () => {
  138. console.log(123);
  139. if (checkStr(state.form.newMobile, "mobile")) {
  140. sendCodeApi()
  141. codeInterval()
  142. } else {
  143. uni.showToast({
  144. title: '请输入正确的手机号',
  145. icon: 'none'
  146. });
  147. }
  148. }
  149. let waitTime = ref(0)
  150. //倒计时函数
  151. const codeInterval = () => {
  152. waitTime.value = 60
  153. let timer = setInterval(() => {
  154. if (waitTime.value == 1) {
  155. clearInterval(timer)
  156. }
  157. waitTime.value -= 1
  158. }, 1000)
  159. }
  160. // 发送验证码
  161. const sendCodeApi = () => {
  162. //参数说明
  163. let options = {
  164. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  165. data: {
  166. mobile: state.form.newMobile
  167. }, //请求参数
  168. method: "POST", //提交方式(默认POST)
  169. showLoading: true, //是否显示加载中(默认显示)
  170. };
  171. //调用方式
  172. requestNew(newMobileSmsCode, options)
  173. .then((res) => {
  174. let data = stringToJson(res.bizContent)
  175. console.log(data, "#################");
  176. if (data.info == "成功.") {
  177. console.log('######################CCCCCCCCCCCCCCCCC');
  178. }
  179. })
  180. .catch((err) => {
  181. console.log(err);
  182. });
  183. }
  184. //下一步
  185. const savaHandle = () => {
  186. console.log(state.form);
  187. if (!state.form.userPosImgUrl) {
  188. msg("请上传身份证正面")
  189. return;
  190. }
  191. if (!state.form.userNegImgUrl) {
  192. msg("请上传身份证反面")
  193. return;
  194. }
  195. // if (!state.form.customerName) {
  196. // msg("请输入姓名")
  197. // return;
  198. // }
  199. // if (!state.form.address) {
  200. // msg("请输入地址")
  201. // return;
  202. // }
  203. if (!checkStr(state.form.newMobile, "mobile")) {
  204. msg("请输入正确的手机号")
  205. return;
  206. }
  207. if (!state.form.newMobileCode) {
  208. msg("请输入验证码")
  209. return;
  210. }
  211. const options = {
  212. type: 2,
  213. data: state.form,
  214. method: "POST",
  215. showLoading: true,
  216. };
  217. requestNew(mobileChangeProfile, options).then((res) => {
  218. const data = JSON.parse(res.bizContent)
  219. msg('个人信息变更成功')
  220. setTimeout(() => {
  221. uni.navigateBack({
  222. delta: 1
  223. });
  224. }, 1500)
  225. console.log(data);
  226. });
  227. }
  228. onLoad((options) => {
  229. console.log(options.customerId);
  230. state.form.customerId = options.customerId
  231. })
  232. const takePhotoMode = (index) => {
  233. console.log("index", index)
  234. state.isTakePhotoModeShow = true
  235. state.choiceIndex = index
  236. }
  237. const camera = () => {
  238. state.phoneType = 0
  239. }
  240. const xiangce = (val) => {
  241. console.log("val", val)
  242. var imageType = val;
  243. chooseImageCompress((res)=>{
  244. state.images = res.tempFilePath?res.tempFilePath:res.tempFilePaths[0]
  245. state.showImg = false
  246. state.phoneType = state.choiceIndex
  247. state.isTakePhotoModeShow = false
  248. })
  249. }
  250. const takePhoto = (val) => {
  251. console.log("拍照", val)
  252. state.phoneType = val;
  253. state.showImg = true;
  254. }
  255. const confirmReturn = (val) => {
  256. state.phoneType = 0
  257. state.isTakePhotoModeShow = false
  258. var imageType = state.choiceIndex;
  259. console.log("图片地址val", val.tempImagePath)
  260. uploadFile(val.tempImagePath, imageType, idCardOcr).then((data) => {
  261. if (state.choiceIndex === "1") {
  262. state.form.customerName = data.name;
  263. state.form.userPosImgUrl = data.imageUrl;
  264. state.form.address = data.address;
  265. } else {
  266. state.form.customerIdVld = data.enddate;
  267. state.form.userNegImgUrl = data.imageUrl;
  268. }
  269. state.isTakePhotoModeShow = false
  270. })
  271. }
  272. const cancle = () => {
  273. state.isTakePhotoModeShow = false
  274. }
  275. </script>
  276. <style>
  277. page {
  278. background: #eef7f7;
  279. }
  280. </style>
  281. <style lang="scss" scoped>
  282. ::v-deep .u-size-mini {
  283. white-space: nowrap;
  284. }
  285. .main {
  286. .content {
  287. padding: 50rpx 30rpx 50rpx 30rpx;
  288. .action {
  289. padding-left: 20rpx;
  290. padding-right: 20rpx;
  291. padding-bottom: 30rpx;
  292. .button {
  293. height: 80rpx;
  294. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  295. border-radius: 40rpx;
  296. font-size: 32rpx;
  297. font-weight: 400;
  298. color: #ffffff;
  299. line-height: 80rpx;
  300. }
  301. }
  302. .item-tips {
  303. .title {
  304. font-size: 30rpx;
  305. font-family: Microsoft YaHei;
  306. font-weight: 400;
  307. color: #000000;
  308. line-height: 24rpx;
  309. }
  310. .tip {
  311. margin-top: 16rpx;
  312. font-size: 24rpx;
  313. font-family: Microsoft YaHei;
  314. font-weight: 400;
  315. color: #999999;
  316. line-height: 24rpx;
  317. }
  318. }
  319. .picture-wrapper {
  320. margin-top: 40rpx;
  321. .bg {
  322. background: #ffffff;
  323. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  324. border-radius: 20rpx;
  325. padding: 40rpx;
  326. display: flex;
  327. justify-content: space-between;
  328. .name {
  329. font-size: 34rpx;
  330. font-family: Microsoft YaHei;
  331. font-weight: 400;
  332. color: #000000;
  333. line-height: 34rpx;
  334. }
  335. .value {
  336. margin-top: 20rpx;
  337. font-size: 24rpx;
  338. font-family: Microsoft YaHei;
  339. font-weight: 400;
  340. color: #999999;
  341. line-height: 24rpx;
  342. }
  343. .tip {
  344. margin-top: 20rpx;
  345. text-align: center;
  346. width: 110rpx;
  347. height: 40rpx;
  348. background: rgba(33, 190, 177, 0.2);
  349. border-radius: 6rpx;
  350. .tip-value {
  351. font-size: 20rpx;
  352. font-family: Microsoft YaHei;
  353. font-weight: 400;
  354. color: #0a8f8a;
  355. line-height: 40rpx;
  356. opacity: 1;
  357. }
  358. }
  359. }
  360. .icon {
  361. width: 294rpx;
  362. height: 188rpx;
  363. }
  364. }
  365. .shibie-wrapper {
  366. margin-top: 40rpx;
  367. background: #fff;
  368. padding: 40rpx 30rpx;
  369. border-radius: 20rpx;
  370. box-shadow: 0 4rpx 13rpx 3rpx rgba(223, 223, 223, .8);
  371. .title {
  372. font-size: 30rpx;
  373. font-family: Microsoft YaHei;
  374. font-weight: 400;
  375. color: #000000;
  376. line-height: 30rpx;
  377. }
  378. .phoneBox {
  379. ::v-deep .u-form-item--right__content__slot {
  380. display: flex;
  381. .btn {
  382. flex: 1;
  383. background: transparent;
  384. font-size: 30rpx;
  385. color: #15E5C1;
  386. z-index: 999;
  387. }
  388. }
  389. }
  390. }
  391. .buchong-wrapper {
  392. margin-top: 60rpx;
  393. .title {
  394. font-size: 30rpx;
  395. font-family: Microsoft YaHei;
  396. font-weight: 400;
  397. color: #000000;
  398. line-height: 30rpx;
  399. }
  400. }
  401. .green-tip {
  402. margin-top: 50rpx;
  403. font-size: 24rpx;
  404. font-family: Microsoft YaHei;
  405. font-weight: 400;
  406. color: #00b38b;
  407. line-height: 24rpx;
  408. margin-bottom: 60rpx;
  409. }
  410. }
  411. }
  412. .choice-takePhoto {
  413. position: absolute;
  414. bottom: 0;
  415. background-color: white;
  416. width: 100%;
  417. border-radius: 20rpx 20rpx 0 0;
  418. }
  419. .choice-takePhoto>view:first-child {
  420. text-align: center;
  421. height: 80rpx;
  422. line-height: 80rpx;
  423. border-bottom: 1rpx solid rgba(127, 127, 127, 0.3);
  424. background-color: white;
  425. }
  426. .choice-takePhoto>view:last-child {
  427. text-align: center;
  428. height: 80rpx;
  429. line-height: 80rpx;
  430. border-top: 6rpx solid rgba(127, 127, 127, 0.1);
  431. background-color: white;
  432. }
  433. .choice-takePhoto>view {
  434. text-align: center;
  435. height: 80rpx;
  436. line-height: 80rpx;
  437. background-color: white;
  438. }
  439. .choice-takePhoto-wrap {
  440. width: 100%;
  441. height: 100vh;
  442. background-color: rgba(127, 127, 127, 0.2);
  443. position: fixed;
  444. left: 0;
  445. top: 0;
  446. z-index: 11111;
  447. }
  448. .search{
  449. color: #ffffff;
  450. border-color: #19be6b;
  451. background-color: #19be6b;
  452. font-size: 28rpx !important;
  453. padding: 8px 30rpx !important;
  454. white-space: nowrap;
  455. height: 30rpx;
  456. line-height: 30rpx;
  457. border-radius: 16rpx;
  458. }
  459. </style>