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.

base-change-people.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <template>
  2. <view class="content">
  3. <view class="item-tips">
  4. <view class="picture-wrapper" @click="takePhotoMode('1')">
  5. <view class="bg">
  6. <view class="">
  7. <view class="name">
  8. 人像面
  9. </view>
  10. <view class="value">
  11. 上传身份证的人像面
  12. </view>
  13. <view class="tip">
  14. <view class="tip-value">
  15. 拍摄规范
  16. </view>
  17. </view>
  18. </view>
  19. <image class="icon" :src="`${$imgUrl}applyCard/renxiang.png`" v-if="!state.imageUrl"></image>
  20. <image class="icon" :src="state.imageUrl" v-else></image>
  21. </view>
  22. </view>
  23. <view class="picture-wrapper" @click="takePhotoMode('2')">
  24. <view class="bg">
  25. <view class="">
  26. <view class="name">
  27. 国徽面
  28. </view>
  29. <view class="value">
  30. 上传身份证的国徽面
  31. </view>
  32. <view class="tip">
  33. <view class="tip-value">
  34. 拍摄规范
  35. </view>
  36. </view>
  37. </view>
  38. <image class="icon" :src="`${$imgUrl}applyCard/guohui.png`" v-if="!state.imageUrl2"></image>
  39. <image class="icon" :src="state.imageUrl2" v-else></image>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="shibie-wrapper">
  44. <view class="title">
  45. 个人信息
  46. </view>
  47. <view class="">
  48. <u-field required labelWidth="200" v-model="state.ocrData.name" input-align='right' label="姓名" disabled>
  49. </u-field>
  50. <u-field required labelWidth="200" v-model="state.ocrData.gender" input-align='right' label="性别"
  51. disabled>
  52. </u-field>
  53. <u-field required labelWidth="200" v-model="state.ocrData.idno" input-align='right' label="证件号"
  54. disabled>
  55. </u-field>
  56. <u-field required labelWidth="200" v-model="state.ocrData.address" input-align='right' label="地址"
  57. disabled>
  58. </u-field>
  59. <u-field required labelWidth="200" v-model="state.ocrData.termValidity" input-align='right'
  60. label="证件有效期" disabled>
  61. </u-field>
  62. <u-field required labelWidth="200" v-model="state.ocrData.phone" input-align='right' label="联系方式"
  63. disabled>
  64. </u-field>
  65. </view>
  66. <!-- <view class="from1">
  67. <uni-forms ref="form_ref" :modelValue="state.ocrData" :rules="rules">
  68. <uni-forms-item label="姓名" name="name" label-width="112" required>
  69. <uni-easyinput type="text" v-model="state.ocrData.name" :inputBorder="false"
  70. placeholderStyle="font-size: 28rpx;" placeholder="请输入" />
  71. </uni-forms-item>
  72. <uni-forms-item label="性别" name="gender" label-width="112" required>
  73. <uni-easyinput type="text" v-model="state.ocrData.gender" :inputBorder="false"
  74. placeholderStyle="font-size: 28rpx;" placeholder="请输入" />
  75. </uni-forms-item>
  76. <uni-forms-item label="证件号" name="phone" label-width="112" required>
  77. <uni-easyinput type="text" v-model="state.ocrData.idno" :inputBorder="false"
  78. placeholderStyle="font-size: 28rpx;" placeholder="请输入" />
  79. </uni-forms-item>
  80. <uni-forms-item label="地址" name="code" label-width="112" required>
  81. <uni-easyinput type="text" v-model="state.ocrData.address" :inputBorder="false"
  82. placeholderStyle="font-size: 28rpx;" placeholder="请输入" />
  83. </uni-forms-item>
  84. <uni-forms-item label="证件有效期" name="code" label-width="112" required>
  85. <uni-easyinput type="text" v-model="state.ocrData.termValidity" :inputBorder="false"
  86. placeholderStyle="font-size: 28rpx;" placeholder="请输入" />
  87. </uni-forms-item>
  88. <uni-forms-item label="联系方式" name="code" label-width="112" required>
  89. <uni-easyinput type="text" v-model="state.ocrData.phone" :inputBorder="false"
  90. placeholderStyle="font-size: 28rpx;" placeholder="请输入" />
  91. </uni-forms-item>
  92. </uni-forms>
  93. </view> -->
  94. </view>
  95. <view class="action">
  96. <button type="default" class="button" @click="savaHandle()">确认下一步</button>
  97. </view>
  98. </view>
  99. <view class="choice-takePhoto-wrap" v-if="state.isTakePhotoModeShow" @click="cancle">
  100. <view class="choice-takePhoto">
  101. <view @click.stop="takePhoto(state.choiceIndex)" style="border-radius: 20rpx 20rpx 0 0;">拍照</view>
  102. <view @click.stop="xiangce(state.choiceIndex)">从手机相册选择</view>
  103. <view @click.stop="cancle">取消</view>
  104. </view>
  105. </view>
  106. <viewfinder v-if="state.phoneType" :phoneType="state.phoneType" :images="state.images"
  107. :showStartPhoto="state.showImg" @confirmReturn="confirmReturn" @camera="camera"></viewfinder>
  108. </template>
  109. <script setup lang="ts">
  110. import {
  111. ref,
  112. reactive
  113. } from "vue";
  114. import {
  115. navTo, uploadFile
  116. } from "@/utils/utils";
  117. import {
  118. etcOcrCard
  119. } from "@/utils/network/api.js";
  120. import {
  121. stringToJson
  122. } from "@/utils/network/encryption";
  123. import {
  124. request
  125. } from "@/utils/network/request.js";
  126. import viewfinder from "@/components/viewfinder.vue"
  127. const savaHandle = () => {
  128. console.log("执行点击事件");
  129. // form_ref.value.validate().then(res => {
  130. // console.log('success', res);
  131. // uni.showToast({
  132. // title: `校验通过`
  133. // })
  134. // }).catch(err => {
  135. // console.log('err', err);
  136. // })
  137. if (state.imageUrl && state.imageUrl2) {
  138. navTo("/subpackage/after-sale/additional-equipment/car-change");
  139. } else {
  140. uni.showToast({
  141. title: "请上传图片",
  142. icon: "none",
  143. });
  144. }
  145. };
  146. const state = reactive({
  147. phoneType: 0, // 1 身份证正面 2 身份证反面 3行驶证正面 4行驶证反面
  148. choiceIndex: 1, // 1 身份证正面 2 身份证反面
  149. isTakePhotoModeShow: false, //选择拍照方式是否出来
  150. images: '',
  151. showImg: true,
  152. ocrData: {
  153. name: "",
  154. gender: "",
  155. idno: "",
  156. address: "",
  157. phone: "18225525252",
  158. termValidity: "",
  159. },
  160. isMyPeopple: true,
  161. imageUrl: "",
  162. imageUrl2: "",
  163. });
  164. const form_ref = ref()
  165. // 验证规则
  166. const rules = {
  167. name: {
  168. rules: [{
  169. required: true,
  170. errorMessage: '请输入',
  171. }]
  172. },
  173. bankID: {
  174. rules: [{
  175. required: true,
  176. errorMessage: '请输入',
  177. }]
  178. },
  179. phone: {
  180. rules: [{
  181. required: true,
  182. errorMessage: '请输入',
  183. }]
  184. },
  185. }
  186. const takePhotoMode = (index, isMy) => {
  187. console.log("index", index, isMy)
  188. state.isTakePhotoModeShow = true
  189. state.choiceIndex = index
  190. state.isMy = isMy
  191. }
  192. const xiangce = (val) => {
  193. console.log("val", val)
  194. var imageType = val;
  195. uni.chooseImage({
  196. count: 1, //只能选取一张照片
  197. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  198. sourceType: ["album"], //从相册选择
  199. success: function (res) {
  200. state.showImg = false
  201. state.images = res.tempFilePaths[0]
  202. state.phoneType = state.choiceIndex
  203. state.isTakePhotoModeShow = false
  204. console.log("tempFilePaths[0].startsWith('file://')", res.tempFilePaths[0], res.tempFilePaths[0].startsWith('file://'))
  205. },
  206. })
  207. }
  208. const takePhoto = (val) => {
  209. state.showImg = true
  210. console.log("拍照", val)
  211. state.phoneType = val;
  212. }
  213. const confirmReturn = (val) => {
  214. state.phoneType = 0
  215. state.isTakePhotoModeShow = false
  216. var imageType = state.choiceIndex;
  217. console.log("图片地址val", val.tempImagePath)
  218. uploadFile(val.tempImagePath, imageType, etcOcrCard).then((data) => {
  219. console.log("身份证上传", data)
  220. if (state.choiceIndex == 1) {
  221. state.imageUrl = data.imageUrl;
  222. state.ocrData.name = data.name;
  223. state.ocrData.gender = data.gender;
  224. state.ocrData.idno = data.idno;
  225. state.ocrData.address = data.address;
  226. } else {
  227. state.ocrData.termValidity = data.begindate + "-" + data
  228. .enddate;
  229. state.imageUrl2 = data.imageUrl;
  230. }
  231. state.isTakePhotoModeShow = false
  232. })
  233. }
  234. const cancle = () => {
  235. state.isTakePhotoModeShow = false
  236. }
  237. </script>
  238. <style lang="scss" scoped>
  239. .content {
  240. padding: 50rpx 30rpx 50rpx 30rpx;
  241. .action {
  242. margin-top: 60rpx;
  243. padding-left: 20rpx;
  244. padding-right: 20rpx;
  245. padding-bottom: 30rpx;
  246. .button {
  247. height: 80rpx;
  248. background: linear-gradient(-90deg, #43A1E0 0%, #13E7C1 100%);
  249. border-radius: 40rpx;
  250. font-size: 32rpx;
  251. font-weight: 400;
  252. color: #FFFFFF;
  253. line-height: 80rpx;
  254. }
  255. }
  256. .item-tips {
  257. .title {
  258. font-size: 30rpx;
  259. font-family: Microsoft YaHei;
  260. font-weight: 400;
  261. color: #000000;
  262. line-height: 24rpx;
  263. }
  264. .tip {
  265. margin-top: 16rpx;
  266. font-size: 24rpx;
  267. font-family: Microsoft YaHei;
  268. font-weight: 400;
  269. color: #999999;
  270. line-height: 24rpx;
  271. }
  272. }
  273. .picture-wrapper {
  274. margin-top: 40rpx;
  275. .bg {
  276. background: #FFFFFF;
  277. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  278. border-radius: 20rpx;
  279. padding: 40rpx;
  280. display: flex;
  281. // align-items: center;
  282. justify-content: space-between;
  283. .name {
  284. font-size: 34rpx;
  285. font-family: Microsoft YaHei;
  286. font-weight: 400;
  287. color: #000000;
  288. line-height: 34rpx
  289. }
  290. .value {
  291. margin-top: 20rpx;
  292. font-size: 24rpx;
  293. font-family: Microsoft YaHei;
  294. font-weight: 400;
  295. color: #999999;
  296. line-height: 24rpx;
  297. }
  298. .tip {
  299. margin-top: 20rpx;
  300. text-align: center;
  301. width: 110rpx;
  302. height: 40rpx;
  303. background: rgba(33, 190, 177, 0.2);
  304. border-radius: 6rpx;
  305. .tip-value {
  306. font-size: 20rpx;
  307. font-family: Microsoft YaHei;
  308. font-weight: 400;
  309. color: #0A8F8A;
  310. line-height: 40rpx;
  311. opacity: 1;
  312. }
  313. }
  314. }
  315. .icon {
  316. width: 294rpx;
  317. height: 188rpx;
  318. }
  319. }
  320. .shibie-wrapper {
  321. margin-top: 60rpx;
  322. .title {
  323. font-size: 30rpx;
  324. font-family: Microsoft YaHei;
  325. font-weight: 400;
  326. color: #000000;
  327. line-height: 30rpx;
  328. }
  329. ::v-deep .u-flex {
  330. width: 100%;
  331. }
  332. ::v-deep .u-field {
  333. border-bottom: 1rpx solid #DCDCDC;
  334. }
  335. .from1 {
  336. background-color: #fff;
  337. margin-top: 30rpx;
  338. // padding: 0 30rpx;
  339. ::v-deep .uni-forms-item {
  340. border-bottom: 1rpx solid #ccc;
  341. padding: 15rpx 0;
  342. margin-bottom: 0;
  343. .uni-forms-item__label {
  344. font-size: 28rpx;
  345. height: 50rpx;
  346. }
  347. .uni-forms-item__content {
  348. display: flex;
  349. }
  350. .uni-easyinput__content-input {
  351. font-size: 28rpx;
  352. height: 50rpx;
  353. }
  354. }
  355. .btn {
  356. line-height: 38rpx;
  357. font-size: 24rpx;
  358. font-family: Microsoft YaHei;
  359. font-weight: 400;
  360. color: #FFFFFF;
  361. background: #00B38B;
  362. border-radius: 10rpx;
  363. padding: 10rpx 15rpx
  364. }
  365. }
  366. }
  367. .buchong-wrapper {
  368. margin-top: 60rpx;
  369. .title {
  370. font-size: 30rpx;
  371. font-family: Microsoft YaHei;
  372. font-weight: 400;
  373. color: #000000;
  374. line-height: 30rpx;
  375. }
  376. }
  377. .green-tip {
  378. margin-top: 50rpx;
  379. font-size: 24rpx;
  380. font-family: Microsoft YaHei;
  381. font-weight: 400;
  382. color: #00B38B;
  383. line-height: 24rpx;
  384. margin-bottom: 60rpx;
  385. }
  386. }
  387. .choice-takePhoto {
  388. position: absolute;
  389. bottom: 0;
  390. background-color: white;
  391. width: 100%;
  392. border-radius: 20rpx 20rpx 0 0;
  393. }
  394. .choice-takePhoto>view:first-child {
  395. text-align: center;
  396. height: 80rpx;
  397. line-height: 80rpx;
  398. border-bottom: 1rpx solid rgba(127, 127, 127, 0.3);
  399. background-color: white;
  400. }
  401. .choice-takePhoto>view:last-child {
  402. text-align: center;
  403. height: 80rpx;
  404. line-height: 80rpx;
  405. border-top: 6rpx solid rgba(127, 127, 127, 0.1);
  406. background-color: white;
  407. }
  408. .choice-takePhoto>view {
  409. text-align: center;
  410. height: 80rpx;
  411. line-height: 80rpx;
  412. background-color: white;
  413. }
  414. .choice-takePhoto-wrap {
  415. width: 100%;
  416. height: 100vh;
  417. background-color: rgba(127, 127, 127, 0.2);
  418. position: fixed;
  419. left: 0;
  420. top: 0;
  421. z-index: 11111;
  422. }
  423. </style>