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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  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", "album"], //从相册选择
  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 strReplace = (str : string) => {
  225. // let imgUrl = str.replace("http://192.168.101.145:9000", envs[process.env.NODE_ENV].baseUrl);
  226. // imgUrl = imgUrl.replace("http://100.64.2.113:9000", envs[process.env.NODE_ENV].baseUrl);
  227. // return imgUrl;
  228. // };
  229. const state = reactive({
  230. phoneType: 0, // 1 身份证正面 2 身份证反面 3行驶证正面 4行驶证反面
  231. choiceIndex: 1, // 1 身份证正面 2 身份证反面
  232. isTakePhotoModeShow: false, //选择拍照方式是否出来
  233. showImg: true,
  234. images: "",
  235. actionSheetShow: false,
  236. actionSheetList: [{
  237. label: "蓝色",
  238. value: 0,
  239. }, {
  240. label: "黄色",
  241. value: 1,
  242. },
  243. {
  244. label: "黑色",
  245. value: 2,
  246. },
  247. {
  248. label: "白色",
  249. value: 3,
  250. },
  251. {
  252. label: "渐变绿色",
  253. value: 4,
  254. },
  255. {
  256. label: "黄绿双拼色",
  257. value: 5,
  258. },
  259. {
  260. label: "蓝白渐变色",
  261. value: 6,
  262. },
  263. {
  264. label: "未确定",
  265. value: 9,
  266. },
  267. {
  268. label: "绿色",
  269. value: 11,
  270. },
  271. {
  272. label: "红色",
  273. value: 12,
  274. },
  275. ],
  276. showCaridCorlor: '',
  277. carIdcorlorCode: '',
  278. form: {
  279. openId: getItem('openId'), //用户标识.
  280. // man: "", //所有人
  281. // character: "", //使用性质
  282. register: "", //注册日期
  283. customerId: "", //用户编号 .
  284. vehicleId: "", //车牌编号 .
  285. issueDate: "", //发证日期 .
  286. vehPosImgUrl: "", //行驶证正面 .
  287. vehNegImgUrl: "", //行驶证证反面 .
  288. type: 0, //0,客车 1.货车 .
  289. useUserType: 0, //车辆用户类型 .
  290. // useUserTypeName: "普通车",
  291. vehicleSign: 2, //前/后装标识 .
  292. vin: "", //车辆识别代号 .
  293. engineNum: "", //发动机号码 .
  294. vehicleType: "", //车辆类型 .
  295. vehicleModel: "", //行驶证品牌型号 .
  296. approvedCount: undefined, //核定人数 .
  297. totalMass: undefined, //总质量 .
  298. maintenaceMass: undefined, //整备质量.
  299. permittedWeight: "", //核定载质量 .
  300. vehicleDimensions: "", //车辆尺寸 .
  301. permittedTowWeight: "", //准牵引总质量 .
  302. axleCount: "", //车轴数 .
  303. ownerName: "", //车主姓名
  304. ownerIdType: "", //车主证件类型
  305. ownerIdNum: "", //车主证件号码
  306. ownPosImgUrl: "", //车主证件正面图片
  307. ownNegImgUrl: "", //车主证件反面图片
  308. agreementId: "", //签约编号
  309. channelId: "", //编号渠道
  310. scenePayType: "", //
  311. transportIdNum: "", //道路运输证编号
  312. licenseIdNum: "", //经营许可证编号
  313. vehBodyUrl: "", //车身照片
  314. proxyUrl: "", //委托书地址,
  315. emergencyFlag: '', //应急车辆标识 0-非应急车辆 1-应急车辆
  316. contacts: '', //指定联系人列表
  317. ownerAddress: '', //所有人联系地址
  318. axisType: '', //轴型
  319. ownerTel: '', //所有人联系方式
  320. axleDistance: '', //轴距
  321. testRecord: '', //检验记录
  322. fileNum: '', //档案编号
  323. useCharacter: '', //车辆使用性质
  324. registerDate: '' //注册日期
  325. },
  326. orderId: "",
  327. isMyPeopple: true,
  328. });
  329. onLoad((option : any) => {
  330. state.form.orderId = option.orderId;
  331. });
  332. const camera = () => {
  333. state.phoneType = 0
  334. }
  335. const xiangce = (val) => {
  336. console.log("val", val)
  337. if (state.choiceIndex == 3) {
  338. var imageType = 1;
  339. } else {
  340. var imageType = 2;
  341. }
  342. uni.chooseImage({
  343. count: 1, //只能选取一张照片
  344. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  345. sourceType: ["album"], //从相册选择
  346. success: function (res) {
  347. if (state.choiceIndex == 3 || state.choiceIndex == 4) {
  348. state.showImg = false
  349. state.images = res.tempFilePaths[0]
  350. state.phoneType = state.choiceIndex
  351. state.isTakePhotoModeShow = false
  352. return
  353. }
  354. },
  355. })
  356. }
  357. const takePhoto = (val) => {
  358. console.log("拍照", val)
  359. state.phoneType = val;
  360. }
  361. const confirmReturn = (val) => {
  362. state.phoneType = 0
  363. state.isTakePhotoModeShow = false
  364. var imageType = state.choiceIndex;
  365. console.log("图片地址val", val.tempImagePath)
  366. if (state.choiceIndex == 3) {
  367. var imageType = 1;
  368. } else {
  369. var imageType = 2;
  370. }
  371. uni.uploadFile({
  372. url: 'https://qtzl.etcjz.cn/minIo/upload', //仅为示例,非真实的接口地址
  373. filePath: val.tempImagePath,
  374. name: 'file',
  375. formData: {
  376. 'user': 'test',
  377. "bucket": 'default-bucket'
  378. },
  379. success: (uploadFileRes) => {
  380. let uploadFileImage = 'http://100.64.2.113:9000' + '/default-bucket/' + JSON.parse(uploadFileRes.data).data.ossFilePath
  381. var data = {
  382. source: "1",
  383. agencyId: "52010106004",
  384. imageType: imageType,
  385. fileName: val.tempImagePath,
  386. imageUrl: uploadFileImage
  387. };
  388. const options = {
  389. type: 2,
  390. data: data,
  391. method: "POST",
  392. showLoading: true,
  393. };
  394. request(etcCarOcrCard, options).then((res) => {
  395. const data = stringToJson(res.bizContent);
  396. if (state.choiceIndex === "3") {
  397. state.form.vehicleId = data.plate_a;
  398. state.form.ownerName = data.man;
  399. state.form.vehicleType = data.vehicle;
  400. // state.form.useCharacter = data.character;
  401. state.form.vin = data.vin;
  402. state.form.engineNum = data.engine;
  403. state.form.registerDate = data.register;
  404. state.form.issueDate = data.issue;
  405. state.form.vehPosImgUrl = data.imageUrl;
  406. state.form.vehicleModel = data.model;
  407. } else {
  408. state.form.approvedCount = parseFloat(data.apc);
  409. state.form.maintenaceMass = parseFloat(data.unladen);
  410. state.form.vehicleDimensions = data.overall;
  411. state.form.totalMass = parseFloat(data.gross);
  412. state.form.vehNegImgUrl = data.imageUrl;
  413. }
  414. state.isTakePhotoModeShow = false
  415. });
  416. // })
  417. // .catch((error) => { });
  418. },
  419. })
  420. }
  421. const takePhotoMode = (index) => {
  422. console.log("index", index)
  423. state.isTakePhotoModeShow = true
  424. state.choiceIndex = index
  425. }
  426. const cancle = () => {
  427. state.isTakePhotoModeShow = false
  428. }
  429. </script>
  430. <style lang="scss" scoped>
  431. .content {
  432. position: relative;
  433. // margin-top: -50rpx;
  434. padding: 0rpx 30rpx;
  435. position: relative;
  436. .img-pos {
  437. position: absolute;
  438. left: 270rpx;
  439. top: -38rpx;
  440. right: 50rpx;
  441. .img-flex {
  442. display: flex;
  443. justify-content: space-between;
  444. align-items: center;
  445. .car-img {
  446. width: 86rpx;
  447. height: 42rpx;
  448. }
  449. .flag-img {
  450. width: 30rpx;
  451. height: 35rpx;
  452. }
  453. }
  454. }
  455. .action {
  456. padding-left: 20rpx;
  457. padding-right: 20rpx;
  458. padding-bottom: 30rpx;
  459. .button {
  460. height: 80rpx;
  461. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  462. border-radius: 40rpx;
  463. font-size: 32rpx;
  464. font-weight: 400;
  465. color: #ffffff;
  466. line-height: 80rpx;
  467. }
  468. }
  469. .item-tips {
  470. .title {
  471. font-size: 30rpx;
  472. font-family: Microsoft YaHei;
  473. font-weight: 400;
  474. color: #000000;
  475. line-height: 24rpx;
  476. }
  477. .tip {
  478. margin-top: 16rpx;
  479. font-size: 24rpx;
  480. font-family: Microsoft YaHei;
  481. font-weight: 400;
  482. color: #999999;
  483. line-height: 24rpx;
  484. }
  485. }
  486. .picture-wrapper {
  487. margin-top: 40rpx;
  488. .bg {
  489. background: #ffffff;
  490. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  491. border-radius: 20rpx;
  492. padding: 40rpx;
  493. display: flex;
  494. // align-items: center;
  495. justify-content: space-between;
  496. .name {
  497. font-size: 34rpx;
  498. font-family: Microsoft YaHei;
  499. font-weight: 400;
  500. color: #000000;
  501. line-height: 34rpx;
  502. }
  503. .value {
  504. margin-top: 20rpx;
  505. font-size: 24rpx;
  506. font-family: Microsoft YaHei;
  507. font-weight: 400;
  508. color: #999999;
  509. line-height: 24rpx;
  510. }
  511. .tip {
  512. margin-top: 20rpx;
  513. text-align: center;
  514. width: 110rpx;
  515. height: 40rpx;
  516. background: rgba(33, 190, 177, 0.2);
  517. border-radius: 6rpx;
  518. .tip-value {
  519. font-size: 20rpx;
  520. font-family: Microsoft YaHei;
  521. font-weight: 400;
  522. color: #0a8f8a;
  523. line-height: 40rpx;
  524. opacity: 1;
  525. }
  526. }
  527. }
  528. .icon {
  529. width: 294rpx;
  530. height: 188rpx;
  531. }
  532. }
  533. .shibie-wrapper {
  534. margin-top: 60rpx;
  535. .title {
  536. font-size: 30rpx;
  537. font-family: Microsoft YaHei;
  538. font-weight: 400;
  539. color: #000000;
  540. line-height: 30rpx;
  541. }
  542. }
  543. .buchong-wrapper {
  544. margin-top: 60rpx;
  545. .title {
  546. font-size: 30rpx;
  547. font-family: Microsoft YaHei;
  548. font-weight: 400;
  549. color: #000000;
  550. line-height: 30rpx;
  551. }
  552. }
  553. .green-tip {
  554. margin-top: 50rpx;
  555. font-size: 24rpx;
  556. font-family: Microsoft YaHei;
  557. font-weight: 400;
  558. color: #00b38b;
  559. line-height: 24rpx;
  560. margin-bottom: 60rpx;
  561. }
  562. }
  563. .choice-takePhoto {
  564. position: absolute;
  565. bottom: 0;
  566. background-color: white;
  567. width: 100%;
  568. border-radius: 20rpx 20rpx 0 0;
  569. }
  570. .choice-takePhoto>view:first-child {
  571. text-align: center;
  572. height: 80rpx;
  573. line-height: 80rpx;
  574. border-bottom: 1rpx solid rgba(127, 127, 127, 0.3);
  575. background-color: white;
  576. }
  577. .choice-takePhoto>view:last-child {
  578. text-align: center;
  579. height: 80rpx;
  580. line-height: 80rpx;
  581. border-top: 6rpx solid rgba(127, 127, 127, 0.1);
  582. background-color: white;
  583. }
  584. .choice-takePhoto>view {
  585. text-align: center;
  586. height: 80rpx;
  587. line-height: 80rpx;
  588. background-color: white;
  589. }
  590. .choice-takePhoto-wrap {
  591. width: 100%;
  592. height: 100vh;
  593. background-color: rgba(127, 127, 127, 0.2);
  594. position: fixed;
  595. left: 0;
  596. top: 0;
  597. z-index: 11111;
  598. }
  599. </style>