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.

vehicle-details.vue 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. <template>
  2. <view class="vehicle-details-container">
  3. <!-- 车辆基本信息 -->
  4. <view class="vehicle-info-section">
  5. <view class="info-item">
  6. <text class="label">车牌号</text>
  7. <text class="value">{{ vehicleInfo.vehiclePlate }}</text>
  8. </view>
  9. <view class="info-item">
  10. <text class="label">车牌颜色</text>
  11. <text class="value">{{
  12. getVehiclePlateColor(vehicleInfo.vehiclePlateColor)
  13. }}</text>
  14. </view>
  15. <view class="info-item">
  16. <text class="label">车辆所有人信息</text>
  17. <text class="value">{{ vehicleInfo.ownerName }}</text>
  18. </view>
  19. <view class="info-item">
  20. <text class="label">车辆所有人证件类型</text>
  21. <!-- <text class="value">{{ vehicleInfo.ownerIdType }}</text> -->
  22. <text class="value">{{ getCodeName('ID_TYPE',vehicleInfo.ownerIdType) }}</text>
  23. </view>
  24. <view class="info-item">
  25. <text class="label">车辆所有人证件号码</text>
  26. <text class="value">{{ vehicleInfo.ownerIdNum }}</text>
  27. </view>
  28. <view class="info-item">
  29. <text class="label">车辆所有人电话</text>
  30. <text class="value">{{ vehicleInfo.ownerTel }}</text>
  31. </view>
  32. <!-- <view class="info-item">
  33. <text class="label">车辆号码</text>
  34. <text class="value">{{ vehicleInfo.vehicleId }}</text>
  35. </view> -->
  36. <view class="info-item">
  37. <text class="label">行驶证车辆类型</text>
  38. <text class="value">{{ vehicleInfo.vehicleType }}</text>
  39. </view>
  40. <view class="info-item">
  41. <text class="label">车辆识别号</text>
  42. <text class="value">{{ vehicleInfo.vin }}</text>
  43. </view>
  44. <view class="info-item">
  45. <text class="label">发动机号码</text>
  46. <text class="value">{{ vehicleInfo.engineNum }}</text>
  47. </view>
  48. <view class="info-item">
  49. <text class="label">车辆收费类型</text>
  50. <text class="value">{{ getCodeName('VEHICLE_TYPE',vehicleInfo.type) }}</text>
  51. </view>
  52. <view class="info-item">
  53. <text class="label">核定载人数</text>
  54. <text class="value">{{ vehicleInfo.approvedCount }}</text>
  55. </view>
  56. <view class="info-item">
  57. <text class="label">总质量</text>
  58. <text class="value">{{ vehicleInfo.totalMass }}kg</text>
  59. </view>
  60. <view class="info-item">
  61. <text class="label">整备质量</text>
  62. <text class="value">{{ vehicleInfo.maintenaceMass }}kg</text>
  63. </view>
  64. <view class="info-item">
  65. <text class="label">核定载质量</text>
  66. <text class="value">{{ vehicleInfo.permittedWeight }}kg</text>
  67. </view>
  68. <view class="info-item">
  69. <text class="label">外廊尺寸</text>
  70. <text class="value">{{ vehicleInfo.vehicleDimensions }}</text>
  71. </view>
  72. <view class="info-item">
  73. <text class="label">准牵引总质量</text>
  74. <text class="value">{{ vehicleInfo.permittedTowWeight }}Kg</text>
  75. </view>
  76. <view class="info-item">
  77. <text class="label">车轮数</text>
  78. <text class="value">{{ vehicleInfo.vehicleWheelCount }}</text>
  79. </view>
  80. <view class="info-item">
  81. <text class="label">车轴数</text>
  82. <text class="value">{{ vehicleInfo.axleCount }}</text>
  83. </view>
  84. <view class="info-item">
  85. <text class="label">车辆使用性质</text>
  86. <text class="value">{{ getCodeName('VERHICLE_USE', vehicleInfo.useCharacter) }}</text>
  87. </view>
  88. <view class="info-item">
  89. <text class="label">车辆用户类型</text>
  90. <text class="value">{{ getCodeName('USE_USER_TYPE', vehicleInfo.useUserType) }}</text>
  91. </view>
  92. <!-- 行驶证图片 -->
  93. <view class="license-section">
  94. <view class="license-item">
  95. <text class="license-title">行驶证主页</text>
  96. <view class="license-image-container">
  97. <image
  98. v-if="vehicleInfo.vehPosImgUrl"
  99. :src="getImageUrl(vehicleInfo.vehPosImgUrl)"
  100. class="license-image"
  101. mode="aspectFit"
  102. @click="previewImage(getImageUrl(vehicleInfo.vehPosImgUrl))"
  103. />
  104. <view v-else class="license-placeholder">
  105. <text class="placeholder-text">暂无图片</text>
  106. </view>
  107. </view>
  108. </view>
  109. <view class="license-item">
  110. <text class="license-title">行驶证副页</text>
  111. <view class="license-image-container">
  112. <image
  113. v-if="vehicleInfo.vehNegImgUrl"
  114. :src="getImageUrl(vehicleInfo.vehNegImgUrl)"
  115. class="license-image"
  116. mode="aspectFit"
  117. @click="previewImage(getImageUrl(vehicleInfo.vehNegImgUrl))"
  118. />
  119. <view v-else class="license-placeholder">
  120. <text class="placeholder-text">暂无图片</text>
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. <!-- 车身照和车头照 -->
  126. <view class="license-section">
  127. <view class="license-item">
  128. <text class="license-title">车头照</text>
  129. <view class="license-image-container">
  130. <image
  131. v-if="vehicleInfo.vehBodyUrl"
  132. :src="getImageUrl(vehicleInfo.vehBodyUrl)"
  133. class="license-image"
  134. mode="aspectFit"
  135. @click="previewImage(getImageUrl(vehicleInfo.vehBodyUrl))"
  136. />
  137. <view v-else class="license-placeholder">
  138. <text class="placeholder-text">暂无图片</text>
  139. </view>
  140. </view>
  141. </view>
  142. <!-- <view class="license-item">
  143. <text class="license-title">车头照</text>
  144. <view class="license-image-container">
  145. <image
  146. v-if="vehicleInfo.proxyUrl"
  147. :src="getImageUrl(vehicleInfo.proxyUrl)"
  148. class="license-image"
  149. mode="aspectFit"
  150. @click="previewImage(getImageUrl(vehicleInfo.proxyUrl))"
  151. />
  152. <view v-else class="license-placeholder">
  153. <text class="placeholder-text">暂无图片</text>
  154. </view>
  155. </view>
  156. </view> -->
  157. </view>
  158. </view>
  159. <!-- 底部按钮 -->
  160. <view class="bottom-actions">
  161. <button class="submit-btn" @click="changeVehicleInfo">车辆信息变更</button>
  162. </view>
  163. </view>
  164. </template>
  165. <script lang="ts" setup>
  166. import { reactive, ref } from "vue";
  167. import { onLoad } from "@dcloudio/uni-app";
  168. import { getVehiclePlateColor } from "@/datas/vehiclePlateColor";
  169. import { vehicleInfoView } from "@/utils/network/api.js";
  170. import { requestNew } from "@/utils/network/request.js";
  171. import { fileURL } from "@/datas/fileURL.js";
  172. // import { getItem } from "@/utils/storage";
  173. import {
  174. getCodeName
  175. } from "@/datas/queryKey.js";
  176. import { queryKey } from "@/utils/network/api.js";
  177. import { setItem, getItem } from "@/utils/storage";
  178. const state = reactive({
  179. vehicleId: ''
  180. })
  181. // 响应式数据
  182. const vehicleInfo = reactive({
  183. vehiclePlate: '',
  184. vehiclePlateColor: 0,
  185. vehPosImgUrl: '',
  186. vehNegImgUrl: '',
  187. ownerName: '',
  188. ownerIdType: '',
  189. ownerIdNum: '',
  190. ownerTel: '',
  191. vin: '',
  192. vehicleId: '',
  193. vehicleType: '',
  194. engineNum: '',
  195. type: '',
  196. approvedCount: 0,
  197. totalMass: 0,
  198. maintenaceMass: 0,
  199. permittedWeight: 0,
  200. vehicleDimensions: '',
  201. permittedTowWeight: 0,
  202. vehicleWheelCount: 0,
  203. axleCount: 0,
  204. useCharacter: '',
  205. vehBodyUrl: '',
  206. proxyUrl: '',
  207. verhicleUse: '',
  208. useUserType: ''
  209. });
  210. const plateNumber = ref(["贵", "Z", "M", "J", "U", "7", "0"]);
  211. const currentInputIndex = ref(0);
  212. const selectedColor = ref("blue");
  213. // 确保字典数据已加载
  214. const ensureDictData = () => {
  215. const dictData = getItem('key');
  216. console.log("字典数据查询", dictData);
  217. if (!dictData) {
  218. // 如果字典数据不存在,先加载字典数据
  219. const options = {
  220. type: 2,
  221. data: {},
  222. method: "POST",
  223. };
  224. return requestNew(queryKey, options).then((res) => {
  225. console.log("加载字典数据", res);
  226. // 处理字典接口返回的两种数据结构
  227. const dictData = res.dictTypeAndItem || res;
  228. setItem('key', dictData);
  229. return dictData;
  230. });
  231. }
  232. return Promise.resolve(dictData);
  233. };
  234. // 页面加载
  235. onLoad((options) => {
  236. console.log("车辆详情页面参数:", options);
  237. uni.setNavigationBarTitle({
  238. title: "车辆详情",
  239. });
  240. if (options.vehicleId) {
  241. // 确保字典数据已加载后再获取车辆详情
  242. state.vehicleId = decodeURIComponent(options.vehicleId)
  243. ensureDictData().then(() => {
  244. getVehicleDetails(state.vehicleId);
  245. });
  246. } else {
  247. uni.showToast({
  248. title: "缺少车辆ID参数",
  249. icon: "none",
  250. });
  251. }
  252. });
  253. // 获取车辆详情
  254. const getVehicleDetails = (id: string) => {
  255. const options = {
  256. type: 2,
  257. data: {
  258. vehicleId: id,
  259. },
  260. method: "POST",
  261. showLoading: true,
  262. };
  263. requestNew(vehicleInfoView, options)
  264. .then((res) => {
  265. console.log("车辆详情接口返回:", res);
  266. if (res) {
  267. // 将接口返回的数据赋值给vehicleInfo
  268. Object.assign(vehicleInfo, res);
  269. console.log(vehicleInfo, 'vehicleInfo');
  270. } else {
  271. uni.showToast({
  272. title: res?.message || "获取车辆信息失败",
  273. icon: "none",
  274. });
  275. }
  276. })
  277. .catch((err) => {
  278. console.error("获取车辆详情失败:", err);
  279. uni.showToast({
  280. title: "获取车辆信息失败",
  281. icon: "none",
  282. });
  283. });
  284. };
  285. // 处理图片URL
  286. const getImageUrl = (url: string) => {
  287. if (!url) return '';
  288. // 如果已经是完整URL,直接返回
  289. if (url.startsWith('http://') || url.startsWith('https://')) {
  290. return url;
  291. }
  292. // 从fileURL中删除default-bucket/后缀,然后拼上url
  293. const baseUrl = fileURL.replace('/default-bucket/', '');
  294. return `${baseUrl}/${url}`;
  295. };
  296. // 预览图片
  297. const previewImage = (url: string) => {
  298. if (url) {
  299. uni.previewImage({
  300. urls: [url],
  301. current: url,
  302. });
  303. }
  304. };
  305. // 聚焦输入框
  306. const focusInput = (index: number) => {
  307. currentInputIndex.value = index;
  308. };
  309. // 添加新车牌
  310. const addNewPlate = () => {
  311. uni.showToast({
  312. title: "添加新车牌功能",
  313. icon: "none",
  314. });
  315. };
  316. // 选择车牌颜色
  317. const selectColor = (color: string) => {
  318. selectedColor.value = color;
  319. };
  320. // 选择图片
  321. const chooseImage = () => {
  322. uni.chooseImage({
  323. count: 1,
  324. sizeType: ["compressed"],
  325. sourceType: ["album", "camera"],
  326. success: (res) => {
  327. vehicleInfo.proxyUrl = res.tempFilePaths[0];
  328. },
  329. });
  330. };
  331. // 下一步
  332. const nextStep = () => {
  333. uni.showToast({
  334. title: "下一步功能",
  335. icon: "none",
  336. });
  337. };
  338. // 车辆信息变更
  339. const changeVehicleInfo = () => {
  340. uni.navigateTo({
  341. url: `/subpackage/personal-center/vehicle-change/vehicle-change-choiceType?vehicleId=${vehicleInfo.vehicleId}&vehiclePlate=${vehicleInfo.vehiclePlate}`,
  342. });
  343. };
  344. </script>
  345. <style lang="scss" scoped>
  346. .vehicle-details-container {
  347. min-height: 100vh;
  348. background-color: #f5f5f5;
  349. padding-bottom: 200rpx;
  350. }
  351. .header {
  352. background-color: #fff;
  353. padding: 30rpx;
  354. text-align: center;
  355. border-bottom: 1rpx solid #eee;
  356. .title {
  357. font-size: 36rpx;
  358. font-weight: bold;
  359. color: #333;
  360. }
  361. }
  362. .vehicle-info-section {
  363. background-color: #fff;
  364. margin: 20rpx;
  365. border-radius: 12rpx;
  366. padding: 30rpx;
  367. .info-item {
  368. display: flex;
  369. justify-content: space-between;
  370. align-items: center;
  371. padding: 20rpx 0;
  372. border-bottom: 1rpx solid #f0f0f0;
  373. &:last-child {
  374. border-bottom: none;
  375. }
  376. .label {
  377. font-size: 28rpx;
  378. color: #666;
  379. // flex: 0;
  380. }
  381. .value {
  382. font-size: 28rpx;
  383. color: #333;
  384. // flex: 1;
  385. text-align: right;
  386. }
  387. }
  388. }
  389. .license-section {
  390. background-color: #fff;
  391. margin: 20rpx;
  392. border-radius: 12rpx;
  393. padding: 30rpx;
  394. .license-item {
  395. margin-bottom: 30rpx;
  396. &:last-child {
  397. margin-bottom: 0;
  398. }
  399. .license-title {
  400. font-size: 28rpx;
  401. color: #333;
  402. margin-bottom: 20rpx;
  403. display: block;
  404. }
  405. .license-image-container {
  406. width: 100%;
  407. height: 300rpx;
  408. border: 2rpx dashed #ddd;
  409. border-radius: 8rpx;
  410. display: flex;
  411. align-items: center;
  412. justify-content: center;
  413. .license-image {
  414. width: 100%;
  415. height: 100%;
  416. border-radius: 8rpx;
  417. }
  418. .license-placeholder {
  419. display: flex;
  420. align-items: center;
  421. justify-content: center;
  422. width: 100%;
  423. height: 100%;
  424. .placeholder-text {
  425. color: #999;
  426. font-size: 26rpx;
  427. }
  428. }
  429. }
  430. }
  431. }
  432. .plate-selection-section {
  433. background-color: #fff;
  434. margin: 20rpx;
  435. border-radius: 12rpx;
  436. padding: 30rpx;
  437. .plate-header {
  438. margin-bottom: 30rpx;
  439. .plate-title {
  440. font-size: 32rpx;
  441. color: #333;
  442. font-weight: bold;
  443. }
  444. }
  445. .plate-input-section {
  446. margin-bottom: 30rpx;
  447. .input-label {
  448. font-size: 28rpx;
  449. color: #666;
  450. margin-bottom: 20rpx;
  451. display: block;
  452. }
  453. .plate-input-container {
  454. display: flex;
  455. align-items: center;
  456. gap: 10rpx;
  457. .plate-char-input {
  458. width: 80rpx;
  459. height: 80rpx;
  460. border: 2rpx solid #ddd;
  461. border-radius: 8rpx;
  462. display: flex;
  463. align-items: center;
  464. justify-content: center;
  465. background-color: #fff;
  466. &.active {
  467. border-color: #007aff;
  468. background-color: #f0f8ff;
  469. }
  470. .plate-char {
  471. font-size: 32rpx;
  472. color: #333;
  473. font-weight: bold;
  474. }
  475. }
  476. .plate-add-btn {
  477. width: 80rpx;
  478. height: 80rpx;
  479. border: 2rpx solid #ddd;
  480. border-radius: 8rpx;
  481. display: flex;
  482. flex-direction: column;
  483. align-items: center;
  484. justify-content: center;
  485. background-color: #fff;
  486. .add-icon {
  487. font-size: 24rpx;
  488. color: #007aff;
  489. font-weight: bold;
  490. }
  491. .add-text {
  492. font-size: 20rpx;
  493. color: #007aff;
  494. }
  495. }
  496. }
  497. }
  498. .plate-color-section {
  499. .color-label {
  500. font-size: 28rpx;
  501. color: #666;
  502. margin-bottom: 20rpx;
  503. display: block;
  504. }
  505. .color-options {
  506. display: flex;
  507. gap: 20rpx;
  508. .color-option {
  509. flex: 1;
  510. height: 80rpx;
  511. border-radius: 8rpx;
  512. display: flex;
  513. align-items: center;
  514. justify-content: center;
  515. border: 2rpx solid transparent;
  516. &.blue {
  517. background: linear-gradient(135deg, #007aff, #0056b3);
  518. &.active {
  519. border-color: #007aff;
  520. box-shadow: 0 0 10rpx rgba(0, 122, 255, 0.3);
  521. }
  522. }
  523. &.green {
  524. background: linear-gradient(135deg, #34c759, #28a745);
  525. &.active {
  526. border-color: #34c759;
  527. box-shadow: 0 0 10rpx rgba(52, 199, 89, 0.3);
  528. }
  529. }
  530. .color-text {
  531. color: #fff;
  532. font-size: 28rpx;
  533. font-weight: bold;
  534. }
  535. }
  536. }
  537. }
  538. }
  539. .front-photo-section {
  540. background-color: #fff;
  541. margin: 20rpx;
  542. border-radius: 12rpx;
  543. padding: 30rpx;
  544. .photo-title {
  545. font-size: 28rpx;
  546. color: #333;
  547. margin-bottom: 20rpx;
  548. display: block;
  549. }
  550. .photo-container {
  551. width: 100%;
  552. height: 400rpx;
  553. border: 2rpx dashed #ddd;
  554. border-radius: 8rpx;
  555. display: flex;
  556. align-items: center;
  557. justify-content: center;
  558. .front-photo {
  559. width: 100%;
  560. height: 100%;
  561. border-radius: 8rpx;
  562. }
  563. .photo-placeholder {
  564. display: flex;
  565. align-items: center;
  566. justify-content: center;
  567. width: 100%;
  568. height: 100%;
  569. .placeholder-text {
  570. color: #999;
  571. font-size: 26rpx;
  572. }
  573. }
  574. }
  575. }
  576. .bottom-actions {
  577. position: fixed;
  578. bottom: 0;
  579. left: 0;
  580. right: 0;
  581. background-color: #fff;
  582. padding: 30rpx;
  583. border-top: 1rpx solid #eee;
  584. display: flex;
  585. flex-direction: column;
  586. gap: 20rpx;
  587. .next-btn {
  588. background: linear-gradient(135deg, #007aff, #0056b3);
  589. color: #fff;
  590. border: none;
  591. border-radius: 12rpx;
  592. height: 88rpx;
  593. font-size: 32rpx;
  594. font-weight: bold;
  595. }
  596. .submit-btn {
  597. width:90%;
  598. background: linear-gradient(to bottom, #1e3a8a, #1e1e1e);
  599. color: #fff;
  600. border: none;
  601. border-radius: 50rpx;
  602. height: 88rpx;
  603. font-size: 32rpx;
  604. font-weight: bold;
  605. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.3);
  606. position: relative;
  607. &::before {
  608. content: "";
  609. position: absolute;
  610. top: 0;
  611. left: 0;
  612. right: 0;
  613. height: 2rpx;
  614. background: linear-gradient(to right, #60a5fa, #93c5fd);
  615. border-radius: 50rpx 50rpx 0 0;
  616. }
  617. &::after {
  618. content: "";
  619. position: absolute;
  620. bottom: 0;
  621. left: 0;
  622. right: 0;
  623. height: 2rpx;
  624. background: #000;
  625. border-radius: 0 0 50rpx 50rpx;
  626. }
  627. }
  628. }
  629. </style>