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.

car-create.vue 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. <template>
  2. <view class="content">
  3. <view class="item-tips">
  4. <view class="title"> 上传后请核对识别信息 </view>
  5. <view class="tip"> 如有错误请及时手动修改 </view>
  6. </view>
  7. <view class="picture-wrapper" @click="takePhotoMode('3')">
  8. <view class="bg">
  9. <view class="">
  10. <view class="name"> 行驶证主页 </view>
  11. <view class="value"> 上传行驶证的主页 </view>
  12. <view class="tip">
  13. <view class="tip-value"> 拍摄规范 </view>
  14. </view>
  15. </view>
  16. <image v-if="!state.form.vehPosImgUrl" class="icon" :src="`${$imgUrl}applyCard/car-zhu.png`">
  17. </image>
  18. <image v-else class="icon" :src="strReplace(state.form.vehPosImgUrl)"></image>
  19. </view>
  20. </view>
  21. <view class="picture-wrapper" @click="takePhotoMode('4')">
  22. <view class="bg">
  23. <view class="">
  24. <view class="name"> 行驶证副页 </view>
  25. <view class="value"> 上传行驶证的副页 </view>
  26. <view class="tip">
  27. <view class="tip-value"> 拍摄规范 </view>
  28. </view>
  29. </view>
  30. <image v-if="!state.form.vehNegImgUrl" class="icon" :src="`${$imgUrl}applyCard/car-fu.png`">
  31. </image>
  32. <image v-else class="icon" :src="strReplace(state.form.vehNegImgUrl)"></image>
  33. </view>
  34. </view>
  35. <view class="picture-wrapper" @click="cardFileImageUpdate()">
  36. <view class="bg">
  37. <view class="">
  38. <view class="name"> 车头照 </view>
  39. <view class="value"> 上传汽车的车头照片 </view>
  40. <view class="tip">
  41. <view class="tip-value"> 拍摄规范 </view>
  42. </view>
  43. </view>
  44. <image v-if="!state.form.vehBodyUrl" class="icon" :src="`${$imgUrl}applyCard/chetou.png`">
  45. </image>
  46. <image v-else class="icon" :src="strReplace(state.form.vehBodyUrl)"></image>
  47. </view>
  48. </view>
  49. <view class="shibie-wrapper">
  50. <view class="title"> 识别内容如下 </view>
  51. <view class="">
  52. <u-form label-width="200" :model="state.form" ref="uForm">
  53. <u-form-item label="车牌号">
  54. <u-input inputAlign="right" v-model="state.form.vehicleId" />
  55. </u-form-item>
  56. <u-form-item label="车主姓名">
  57. <u-input inputAlign="right" v-model="state.form.ownerName" />
  58. </u-form-item>
  59. <u-form-item label="车辆类型">
  60. <u-input inputAlign="right" v-model="state.form.vehicleType" />
  61. </u-form-item>
  62. <!-- <u-form-item label="使用性质">
  63. <u-input inputAlign="right" v-model="state.form.useCharacter" />
  64. </u-form-item> -->
  65. <u-form-item label="车辆识别代号">
  66. <u-input inputAlign="right" v-model="state.form.vin" />
  67. </u-form-item>
  68. <u-form-item label="发动机号码">
  69. <u-input inputAlign="right" v-model="state.form.engineNum" />
  70. </u-form-item>
  71. <u-form-item label="注册日期">
  72. <u-input inputAlign="right" v-model="state.form.registerDate" />
  73. </u-form-item>
  74. <u-form-item label="发证日期">
  75. <u-input inputAlign="right" v-model="state.form.issueDate" />
  76. </u-form-item>
  77. <u-form-item label="核定载人数">
  78. <u-input inputAlign="right" v-model="state.form.approvedCount" />
  79. </u-form-item>
  80. <u-form-item label="整备质量">
  81. <u-input inputAlign="right" v-model="state.form.maintenaceMass" />
  82. </u-form-item>
  83. <u-form-item label="外廊尺寸">
  84. <u-input inputAlign="right" v-model="state.form.vehicleDimensions" />
  85. </u-form-item>
  86. <u-form-item label="总质量">
  87. <u-input inputAlign="right" v-model="state.form.totalMass" />
  88. </u-form-item>
  89. <u-form-item label="车牌颜色">
  90. <u-input @click="state.actionSheetShow = true" inputAlign="right"
  91. v-model="state.showCaridCorlor" type="select" />
  92. </u-form-item>
  93. </u-form>
  94. </view>
  95. </view>
  96. <view class="green-tip">
  97. 如识别信息有误,请手动修改,确认无误后,点击下一步!
  98. </view>
  99. <view class="action">
  100. <button type="default" class="button" @click="savaHandle()">
  101. 下一步
  102. </button>
  103. </view>
  104. <u-select v-model="state.actionSheetShow" :list="state.actionSheetList" @confirm="selectConfirm"></u-select>
  105. </view>
  106. <view class="choice-takePhoto-wrap" v-if="state.isTakePhotoModeShow" @click="cancle">
  107. <view class="choice-takePhoto">
  108. <view @click.stop="takePhoto(state.choiceIndex)" style="border-radius: 20rpx 20rpx 0 0;">拍照</view>
  109. <view @click.stop="xiangce(state.choiceIndex)">从手机相册选择</view>
  110. <view @click.stop="cancle">取消</view>
  111. </view>
  112. </view>
  113. <viewfinder v-if="state.phoneType" :phoneType="state.phoneType" :images="state.images"
  114. :showStartPhoto="state.showImg" @confirmReturn="confirmReturn" @camera="camera"></viewfinder>
  115. </template>
  116. <script setup lang="ts">
  117. import {
  118. reactive
  119. } from "vue";
  120. import navBgCar from "./components/nav-bg-car3";
  121. import navBar from "../../components/nav-bar/nav-bar2.vue";
  122. import {
  123. pathToBase64
  124. } from "@/utils/util/imageTool.js";
  125. import viewfinder from "../../../../components/viewfinder.vue";
  126. import {
  127. getItem
  128. } from "@/utils/storage.ts"
  129. import {
  130. etcCarCardInfoSubmit,
  131. etcCarOcrCard,
  132. fileUpload,
  133. createCarInfo,
  134. envs
  135. } from "@/utils/network/api.js";
  136. import {
  137. request
  138. } from "@/utils/network/request.js";
  139. import {
  140. stringToJson
  141. } from "@/utils/network/encryption";
  142. import {
  143. onLoad,
  144. onShow
  145. } from "@dcloudio/uni-app";
  146. import {
  147. strReplace
  148. } from "@/utils/utils";
  149. const savaHandle = () => {
  150. if (state.showCaridCorlor) {
  151. state.form.vehicleId = state.form.vehicleId + '_' + state.carIdcorlorCode
  152. var data = state.form;
  153. console.log(data, "##########");
  154. const options = {
  155. type: 2,
  156. data: data,
  157. method: "POST",
  158. showLoading: true,
  159. };
  160. request(createCarInfo, options).then((res) => {
  161. const data = stringToJson(res.bizContent);
  162. console.log(data)
  163. if (data.info == '成功.') {
  164. uni.reLaunch({
  165. url: "/subpackage/personal-center/setting/car-information/car-manage"
  166. })
  167. }
  168. }).catch(err => {
  169. console.log(err, "在这里");
  170. console.log(state.form.vehicleId.split('_'));
  171. state.form.vehicleId = state.form.vehicleId.split('_')[0]
  172. })
  173. } else {
  174. uni.showToast({
  175. title: "请选择车牌颜色",
  176. icon: "none"
  177. })
  178. }
  179. };
  180. const selectConfirm = (item : any) => {
  181. // item.map((val, index) => {
  182. // state.form.useUserType = val.value;
  183. // state.form.useUserTypeName = val.label;
  184. // });
  185. console.log(item);
  186. if (state.form.vehicleId) {
  187. state.showCaridCorlor = item[0].label
  188. state.carIdcorlorCode = item[0].value
  189. console.log(state.form);
  190. } else {
  191. uni.showToast({
  192. title: '请先填写车牌号',
  193. icon: 'none'
  194. })
  195. }
  196. };
  197. const cardFileImageUpdate = () => {
  198. uni.chooseImage({
  199. count: 1, //只能选取一张照片
  200. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  201. sourceType: ["camera",], //从相册选择
  202. success: function (res) {
  203. pathToBase64(res.tempFilePaths[0])
  204. .then((path) => {
  205. var data = {
  206. fileBase64: path,
  207. };
  208. const options = {
  209. type: 2,
  210. data: data,
  211. method: "POST",
  212. showLoading: true,
  213. };
  214. request(fileUpload, options).then((res) => {
  215. const data = stringToJson(res.bizContent);
  216. console.log(data);
  217. state.form.vehBodyUrl = data.data.url;
  218. });
  219. })
  220. .catch((error) => { });
  221. },
  222. });
  223. };
  224. const state = reactive({
  225. phoneType: 0, // 1 身份证正面 2 身份证反面 3行驶证正面 4行驶证反面
  226. choiceIndex: 1, // 1 身份证正面 2 身份证反面
  227. isTakePhotoModeShow: false, //选择拍照方式是否出来
  228. showImg: true,
  229. images: "",
  230. actionSheetShow: false,
  231. actionSheetList: [{
  232. label: "蓝色",
  233. value: 0,
  234. }, {
  235. label: "黄色",
  236. value: 1,
  237. },
  238. {
  239. label: "黑色",
  240. value: 2,
  241. },
  242. {
  243. label: "白色",
  244. value: 3,
  245. },
  246. {
  247. label: "渐变绿色",
  248. value: 4,
  249. },
  250. {
  251. label: "黄绿双拼色",
  252. value: 5,
  253. },
  254. {
  255. label: "蓝白渐变色",
  256. value: 6,
  257. },
  258. {
  259. label: "未确定",
  260. value: 9,
  261. },
  262. {
  263. label: "绿色",
  264. value: 11,
  265. },
  266. {
  267. label: "红色",
  268. value: 12,
  269. },
  270. ],
  271. showCaridCorlor: '',
  272. carIdcorlorCode: '',
  273. form: {
  274. openId: getItem('openId'), //用户标识.
  275. // man: "", //所有人
  276. // character: "", //使用性质
  277. register: "", //注册日期
  278. customerId: "", //用户编号 .
  279. vehicleId: "", //车牌编号 .
  280. issueDate: "", //发证日期 .
  281. vehPosImgUrl: "", //行驶证正面 .
  282. vehNegImgUrl: "", //行驶证证反面 .
  283. type: 0, //0,客车 1.货车 .
  284. useUserType: 0, //车辆用户类型 .
  285. // useUserTypeName: "普通车",
  286. vehicleSign: 2, //前/后装标识 .
  287. vin: "", //车辆识别代号 .
  288. engineNum: "", //发动机号码 .
  289. vehicleType: "", //车辆类型 .
  290. vehicleModel: "", //行驶证品牌型号 .
  291. approvedCount: undefined, //核定人数 .
  292. totalMass: undefined, //总质量 .
  293. maintenaceMass: undefined, //整备质量.
  294. permittedWeight: "", //核定载质量 .
  295. vehicleDimensions: "", //车辆尺寸 .
  296. permittedTowWeight: "", //准牵引总质量 .
  297. axleCount: "", //车轴数 .
  298. ownerName: "", //车主姓名
  299. ownerIdType: "", //车主证件类型
  300. ownerIdNum: "", //车主证件号码
  301. ownPosImgUrl: "", //车主证件正面图片
  302. ownNegImgUrl: "", //车主证件反面图片
  303. agreementId: "", //签约编号
  304. channelId: "", //编号渠道
  305. scenePayType: "", //
  306. transportIdNum: "", //道路运输证编号
  307. licenseIdNum: "", //经营许可证编号
  308. vehBodyUrl: "", //车身照片
  309. proxyUrl: "", //委托书地址,
  310. emergencyFlag: '', //应急车辆标识 0-非应急车辆 1-应急车辆
  311. contacts: '', //指定联系人列表
  312. ownerAddress: '', //所有人联系地址
  313. axisType: '', //轴型
  314. ownerTel: '', //所有人联系方式
  315. axleDistance: '', //轴距
  316. testRecord: '', //检验记录
  317. fileNum: '', //档案编号
  318. useCharacter: '', //车辆使用性质
  319. registerDate: '' //注册日期
  320. },
  321. orderId: "",
  322. isMyPeopple: true,
  323. });
  324. onLoad((option : any) => {
  325. state.form.orderId = option.orderId;
  326. });
  327. const camera = () => {
  328. state.phoneType = 0
  329. }
  330. const xiangce = (val) => {
  331. console.log("val", val)
  332. if (state.choiceIndex == 3) {
  333. var imageType = 1;
  334. } else {
  335. var imageType = 2;
  336. }
  337. uni.chooseImage({
  338. count: 1, //只能选取一张照片
  339. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  340. sourceType: ["album"], //从相册选择
  341. success: function (res) {
  342. if (state.choiceIndex == 3 || state.choiceIndex == 4) {
  343. state.showImg = false
  344. state.images = res.tempFilePaths[0]
  345. state.phoneType = state.choiceIndex
  346. state.isTakePhotoModeShow = false
  347. return
  348. }
  349. },
  350. })
  351. }
  352. const takePhoto = (val) => {
  353. console.log("拍照", val)
  354. state.phoneType = val;
  355. }
  356. const confirmReturn = (val) => {
  357. state.phoneType = 0
  358. state.isTakePhotoModeShow = false
  359. var imageType = state.choiceIndex;
  360. console.log("图片地址val", val.tempImagePath)
  361. if (state.choiceIndex == 3) {
  362. var imageType = 1;
  363. } else {
  364. var imageType = 2;
  365. }
  366. uni.uploadFile({
  367. url: 'https://qtzl.etcjz.cn/minIo/upload', //仅为示例,非真实的接口地址
  368. filePath: val.tempImagePath,
  369. name: 'file',
  370. formData: {
  371. 'user': 'test',
  372. "bucket": 'default-bucket'
  373. },
  374. success: (uploadFileRes) => {
  375. let uploadFileImage = 'http://100.64.2.113:9000' + '/default-bucket/' + JSON.parse(uploadFileRes.data).data.ossFilePath
  376. var data = {
  377. source: "1",
  378. agencyId: "52010106004",
  379. imageType: imageType,
  380. fileName: val.tempImagePath,
  381. imageUrl: uploadFileImage
  382. };
  383. const options = {
  384. type: 2,
  385. data: data,
  386. method: "POST",
  387. showLoading: true,
  388. };
  389. request(etcCarOcrCard, options).then((res) => {
  390. const data = stringToJson(res.bizContent);
  391. if (state.choiceIndex === "3") {
  392. state.form.vehicleId = data.plate_a;
  393. state.form.ownerName = data.man;
  394. state.form.vehicleType = data.vehicle;
  395. // state.form.useCharacter = data.character;
  396. state.form.vin = data.vin;
  397. state.form.engineNum = data.engine;
  398. state.form.registerDate = data.register;
  399. state.form.issueDate = data.issue;
  400. state.form.vehPosImgUrl = data.imageUrl;
  401. state.form.vehicleModel = data.model;
  402. } else {
  403. state.form.approvedCount = parseFloat(data.apc);
  404. state.form.maintenaceMass = parseFloat(data.unladen);
  405. state.form.vehicleDimensions = data.overall;
  406. state.form.totalMass = parseFloat(data.gross);
  407. state.form.vehNegImgUrl = data.imageUrl;
  408. }
  409. state.isTakePhotoModeShow = false
  410. });
  411. },
  412. })
  413. }
  414. const takePhotoMode = (index) => {
  415. console.log("index", index)
  416. state.isTakePhotoModeShow = true
  417. state.choiceIndex = index
  418. }
  419. const cancle = () => {
  420. state.isTakePhotoModeShow = false
  421. }
  422. </script>
  423. <style lang="scss" scoped>
  424. .content {
  425. position: relative;
  426. // margin-top: -50rpx;
  427. padding: 0rpx 30rpx;
  428. position: relative;
  429. .img-pos {
  430. position: absolute;
  431. left: 270rpx;
  432. top: -38rpx;
  433. right: 50rpx;
  434. .img-flex {
  435. display: flex;
  436. justify-content: space-between;
  437. align-items: center;
  438. .car-img {
  439. width: 86rpx;
  440. height: 42rpx;
  441. }
  442. .flag-img {
  443. width: 30rpx;
  444. height: 35rpx;
  445. }
  446. }
  447. }
  448. .action {
  449. padding-left: 20rpx;
  450. padding-right: 20rpx;
  451. padding-bottom: 30rpx;
  452. .button {
  453. height: 80rpx;
  454. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  455. border-radius: 40rpx;
  456. font-size: 32rpx;
  457. font-weight: 400;
  458. color: #ffffff;
  459. line-height: 80rpx;
  460. }
  461. }
  462. .item-tips {
  463. .title {
  464. font-size: 30rpx;
  465. font-family: Microsoft YaHei;
  466. font-weight: 400;
  467. color: #000000;
  468. line-height: 24rpx;
  469. }
  470. .tip {
  471. margin-top: 16rpx;
  472. font-size: 24rpx;
  473. font-family: Microsoft YaHei;
  474. font-weight: 400;
  475. color: #999999;
  476. line-height: 24rpx;
  477. }
  478. }
  479. .picture-wrapper {
  480. margin-top: 40rpx;
  481. .bg {
  482. background: #ffffff;
  483. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  484. border-radius: 20rpx;
  485. padding: 40rpx;
  486. display: flex;
  487. // align-items: center;
  488. justify-content: space-between;
  489. .name {
  490. font-size: 34rpx;
  491. font-family: Microsoft YaHei;
  492. font-weight: 400;
  493. color: #000000;
  494. line-height: 34rpx;
  495. }
  496. .value {
  497. margin-top: 20rpx;
  498. font-size: 24rpx;
  499. font-family: Microsoft YaHei;
  500. font-weight: 400;
  501. color: #999999;
  502. line-height: 24rpx;
  503. }
  504. .tip {
  505. margin-top: 20rpx;
  506. text-align: center;
  507. width: 110rpx;
  508. height: 40rpx;
  509. background: rgba(33, 190, 177, 0.2);
  510. border-radius: 6rpx;
  511. .tip-value {
  512. font-size: 20rpx;
  513. font-family: Microsoft YaHei;
  514. font-weight: 400;
  515. color: #0a8f8a;
  516. line-height: 40rpx;
  517. opacity: 1;
  518. }
  519. }
  520. }
  521. .icon {
  522. width: 294rpx;
  523. height: 188rpx;
  524. }
  525. }
  526. .shibie-wrapper {
  527. margin-top: 60rpx;
  528. .title {
  529. font-size: 30rpx;
  530. font-family: Microsoft YaHei;
  531. font-weight: 400;
  532. color: #000000;
  533. line-height: 30rpx;
  534. }
  535. }
  536. .buchong-wrapper {
  537. margin-top: 60rpx;
  538. .title {
  539. font-size: 30rpx;
  540. font-family: Microsoft YaHei;
  541. font-weight: 400;
  542. color: #000000;
  543. line-height: 30rpx;
  544. }
  545. }
  546. .green-tip {
  547. margin-top: 50rpx;
  548. font-size: 24rpx;
  549. font-family: Microsoft YaHei;
  550. font-weight: 400;
  551. color: #00b38b;
  552. line-height: 24rpx;
  553. margin-bottom: 60rpx;
  554. }
  555. }
  556. .choice-takePhoto {
  557. position: absolute;
  558. bottom: 0;
  559. background-color: white;
  560. width: 100%;
  561. border-radius: 20rpx 20rpx 0 0;
  562. }
  563. .choice-takePhoto>view:first-child {
  564. text-align: center;
  565. height: 80rpx;
  566. line-height: 80rpx;
  567. border-bottom: 1rpx solid rgba(127, 127, 127, 0.3);
  568. background-color: white;
  569. }
  570. .choice-takePhoto>view:last-child {
  571. text-align: center;
  572. height: 80rpx;
  573. line-height: 80rpx;
  574. border-top: 6rpx solid rgba(127, 127, 127, 0.1);
  575. background-color: white;
  576. }
  577. .choice-takePhoto>view {
  578. text-align: center;
  579. height: 80rpx;
  580. line-height: 80rpx;
  581. background-color: white;
  582. }
  583. .choice-takePhoto-wrap {
  584. width: 100%;
  585. height: 100vh;
  586. background-color: rgba(127, 127, 127, 0.2);
  587. position: fixed;
  588. left: 0;
  589. top: 0;
  590. z-index: 11111;
  591. }
  592. </style>