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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  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. // 响应式数据
  179. const vehicleInfo = reactive({
  180. vehiclePlate: '',
  181. vehiclePlateColor: 0,
  182. vehPosImgUrl: '',
  183. vehNegImgUrl: '',
  184. ownerName: '',
  185. ownerIdType: '',
  186. ownerIdNum: '',
  187. ownerTel: '',
  188. vin: '',
  189. vehicleId: '',
  190. vehicleType: '',
  191. engineNum: '',
  192. type: '',
  193. approvedCount: 0,
  194. totalMass: 0,
  195. maintenaceMass: 0,
  196. permittedWeight: 0,
  197. vehicleDimensions: '',
  198. permittedTowWeight: 0,
  199. vehicleWheelCount: 0,
  200. axleCount: 0,
  201. useCharacter: '',
  202. vehBodyUrl: '',
  203. proxyUrl: '',
  204. verhicleUse: '',
  205. useUserType: ''
  206. });
  207. const plateNumber = ref(["贵", "Z", "M", "J", "U", "7", "0"]);
  208. const currentInputIndex = ref(0);
  209. const selectedColor = ref("blue");
  210. // 确保字典数据已加载
  211. const ensureDictData = () => {
  212. const dictData = getItem('key');
  213. if (!dictData) {
  214. // 如果字典数据不存在,先加载字典数据
  215. const options = {
  216. type: 2,
  217. data: {},
  218. method: "POST",
  219. };
  220. return requestNew(queryKey, options).then((res) => {
  221. console.log("加载字典数据", res);
  222. // 处理字典接口返回的两种数据结构
  223. const dictData = res.dictTypeAndItem || res;
  224. setItem('key', dictData);
  225. return dictData;
  226. });
  227. }
  228. return Promise.resolve(dictData);
  229. };
  230. // 页面加载
  231. onLoad((options) => {
  232. console.log("车辆详情页面参数:", options);
  233. uni.setNavigationBarTitle({
  234. title: "车辆详情",
  235. });
  236. if (options.id) {
  237. // 确保字典数据已加载后再获取车辆详情
  238. ensureDictData().then(() => {
  239. getVehicleDetails(options.id);
  240. });
  241. } else {
  242. uni.showToast({
  243. title: "缺少车辆ID参数",
  244. icon: "none",
  245. });
  246. }
  247. });
  248. // 获取车辆详情
  249. const getVehicleDetails = (id: string) => {
  250. const options = {
  251. type: 2,
  252. data: {
  253. vehicleId: id,
  254. },
  255. method: "POST",
  256. showLoading: true,
  257. };
  258. requestNew(vehicleInfoView, options)
  259. .then((res) => {
  260. console.log("车辆详情接口返回:", res);
  261. if (res) {
  262. // 将接口返回的数据赋值给vehicleInfo
  263. Object.assign(vehicleInfo, res);
  264. console.log(vehicleInfo, 'vehicleInfo');
  265. } else {
  266. uni.showToast({
  267. title: res?.message || "获取车辆信息失败",
  268. icon: "none",
  269. });
  270. }
  271. })
  272. .catch((err) => {
  273. console.error("获取车辆详情失败:", err);
  274. uni.showToast({
  275. title: "获取车辆信息失败",
  276. icon: "none",
  277. });
  278. });
  279. };
  280. // 处理图片URL
  281. const getImageUrl = (url: string) => {
  282. if (!url) return '';
  283. // 如果已经是完整URL,直接返回
  284. if (url.startsWith('http://') || url.startsWith('https://')) {
  285. return url;
  286. }
  287. // 从fileURL中删除default-bucket/后缀,然后拼上url
  288. const baseUrl = fileURL.replace('/default-bucket/', '');
  289. return `${baseUrl}/${url}`;
  290. };
  291. // 预览图片
  292. const previewImage = (url: string) => {
  293. if (url) {
  294. uni.previewImage({
  295. urls: [url],
  296. current: url,
  297. });
  298. }
  299. };
  300. // 聚焦输入框
  301. const focusInput = (index: number) => {
  302. currentInputIndex.value = index;
  303. };
  304. // 添加新车牌
  305. const addNewPlate = () => {
  306. uni.showToast({
  307. title: "添加新车牌功能",
  308. icon: "none",
  309. });
  310. };
  311. // 选择车牌颜色
  312. const selectColor = (color: string) => {
  313. selectedColor.value = color;
  314. };
  315. // 选择图片
  316. const chooseImage = () => {
  317. uni.chooseImage({
  318. count: 1,
  319. sizeType: ["compressed"],
  320. sourceType: ["album", "camera"],
  321. success: (res) => {
  322. vehicleInfo.proxyUrl = res.tempFilePaths[0];
  323. },
  324. });
  325. };
  326. // 下一步
  327. const nextStep = () => {
  328. uni.showToast({
  329. title: "下一步功能",
  330. icon: "none",
  331. });
  332. };
  333. // 车辆信息变更
  334. const changeVehicleInfo = () => {
  335. uni.navigateTo({
  336. url: `/subpackage/personal-center/vehicle-change/vehicle-change-choiceType?vehicleId=${vehicleInfo.vehicleId}&vehiclePlate=${vehicleInfo.vehiclePlate}`,
  337. });
  338. };
  339. </script>
  340. <style lang="scss" scoped>
  341. .vehicle-details-container {
  342. min-height: 100vh;
  343. background-color: #f5f5f5;
  344. padding-bottom: 200rpx;
  345. }
  346. .header {
  347. background-color: #fff;
  348. padding: 30rpx;
  349. text-align: center;
  350. border-bottom: 1rpx solid #eee;
  351. .title {
  352. font-size: 36rpx;
  353. font-weight: bold;
  354. color: #333;
  355. }
  356. }
  357. .vehicle-info-section {
  358. background-color: #fff;
  359. margin: 20rpx;
  360. border-radius: 12rpx;
  361. padding: 30rpx;
  362. .info-item {
  363. display: flex;
  364. justify-content: space-between;
  365. align-items: center;
  366. padding: 20rpx 0;
  367. border-bottom: 1rpx solid #f0f0f0;
  368. &:last-child {
  369. border-bottom: none;
  370. }
  371. .label {
  372. font-size: 28rpx;
  373. color: #666;
  374. // flex: 0;
  375. }
  376. .value {
  377. font-size: 28rpx;
  378. color: #333;
  379. // flex: 1;
  380. text-align: right;
  381. }
  382. }
  383. }
  384. .license-section {
  385. background-color: #fff;
  386. margin: 20rpx;
  387. border-radius: 12rpx;
  388. padding: 30rpx;
  389. .license-item {
  390. margin-bottom: 30rpx;
  391. &:last-child {
  392. margin-bottom: 0;
  393. }
  394. .license-title {
  395. font-size: 28rpx;
  396. color: #333;
  397. margin-bottom: 20rpx;
  398. display: block;
  399. }
  400. .license-image-container {
  401. width: 100%;
  402. height: 300rpx;
  403. border: 2rpx dashed #ddd;
  404. border-radius: 8rpx;
  405. display: flex;
  406. align-items: center;
  407. justify-content: center;
  408. .license-image {
  409. width: 100%;
  410. height: 100%;
  411. border-radius: 8rpx;
  412. }
  413. .license-placeholder {
  414. display: flex;
  415. align-items: center;
  416. justify-content: center;
  417. width: 100%;
  418. height: 100%;
  419. .placeholder-text {
  420. color: #999;
  421. font-size: 26rpx;
  422. }
  423. }
  424. }
  425. }
  426. }
  427. .plate-selection-section {
  428. background-color: #fff;
  429. margin: 20rpx;
  430. border-radius: 12rpx;
  431. padding: 30rpx;
  432. .plate-header {
  433. margin-bottom: 30rpx;
  434. .plate-title {
  435. font-size: 32rpx;
  436. color: #333;
  437. font-weight: bold;
  438. }
  439. }
  440. .plate-input-section {
  441. margin-bottom: 30rpx;
  442. .input-label {
  443. font-size: 28rpx;
  444. color: #666;
  445. margin-bottom: 20rpx;
  446. display: block;
  447. }
  448. .plate-input-container {
  449. display: flex;
  450. align-items: center;
  451. gap: 10rpx;
  452. .plate-char-input {
  453. width: 80rpx;
  454. height: 80rpx;
  455. border: 2rpx solid #ddd;
  456. border-radius: 8rpx;
  457. display: flex;
  458. align-items: center;
  459. justify-content: center;
  460. background-color: #fff;
  461. &.active {
  462. border-color: #007aff;
  463. background-color: #f0f8ff;
  464. }
  465. .plate-char {
  466. font-size: 32rpx;
  467. color: #333;
  468. font-weight: bold;
  469. }
  470. }
  471. .plate-add-btn {
  472. width: 80rpx;
  473. height: 80rpx;
  474. border: 2rpx solid #ddd;
  475. border-radius: 8rpx;
  476. display: flex;
  477. flex-direction: column;
  478. align-items: center;
  479. justify-content: center;
  480. background-color: #fff;
  481. .add-icon {
  482. font-size: 24rpx;
  483. color: #007aff;
  484. font-weight: bold;
  485. }
  486. .add-text {
  487. font-size: 20rpx;
  488. color: #007aff;
  489. }
  490. }
  491. }
  492. }
  493. .plate-color-section {
  494. .color-label {
  495. font-size: 28rpx;
  496. color: #666;
  497. margin-bottom: 20rpx;
  498. display: block;
  499. }
  500. .color-options {
  501. display: flex;
  502. gap: 20rpx;
  503. .color-option {
  504. flex: 1;
  505. height: 80rpx;
  506. border-radius: 8rpx;
  507. display: flex;
  508. align-items: center;
  509. justify-content: center;
  510. border: 2rpx solid transparent;
  511. &.blue {
  512. background: linear-gradient(135deg, #007aff, #0056b3);
  513. &.active {
  514. border-color: #007aff;
  515. box-shadow: 0 0 10rpx rgba(0, 122, 255, 0.3);
  516. }
  517. }
  518. &.green {
  519. background: linear-gradient(135deg, #34c759, #28a745);
  520. &.active {
  521. border-color: #34c759;
  522. box-shadow: 0 0 10rpx rgba(52, 199, 89, 0.3);
  523. }
  524. }
  525. .color-text {
  526. color: #fff;
  527. font-size: 28rpx;
  528. font-weight: bold;
  529. }
  530. }
  531. }
  532. }
  533. }
  534. .front-photo-section {
  535. background-color: #fff;
  536. margin: 20rpx;
  537. border-radius: 12rpx;
  538. padding: 30rpx;
  539. .photo-title {
  540. font-size: 28rpx;
  541. color: #333;
  542. margin-bottom: 20rpx;
  543. display: block;
  544. }
  545. .photo-container {
  546. width: 100%;
  547. height: 400rpx;
  548. border: 2rpx dashed #ddd;
  549. border-radius: 8rpx;
  550. display: flex;
  551. align-items: center;
  552. justify-content: center;
  553. .front-photo {
  554. width: 100%;
  555. height: 100%;
  556. border-radius: 8rpx;
  557. }
  558. .photo-placeholder {
  559. display: flex;
  560. align-items: center;
  561. justify-content: center;
  562. width: 100%;
  563. height: 100%;
  564. .placeholder-text {
  565. color: #999;
  566. font-size: 26rpx;
  567. }
  568. }
  569. }
  570. }
  571. .bottom-actions {
  572. position: fixed;
  573. bottom: 0;
  574. left: 0;
  575. right: 0;
  576. background-color: #fff;
  577. padding: 30rpx;
  578. border-top: 1rpx solid #eee;
  579. display: flex;
  580. flex-direction: column;
  581. gap: 20rpx;
  582. .next-btn {
  583. background: linear-gradient(135deg, #007aff, #0056b3);
  584. color: #fff;
  585. border: none;
  586. border-radius: 12rpx;
  587. height: 88rpx;
  588. font-size: 32rpx;
  589. font-weight: bold;
  590. }
  591. .submit-btn {
  592. width:90%;
  593. background: linear-gradient(to bottom, #1e3a8a, #1e1e1e);
  594. color: #fff;
  595. border: none;
  596. border-radius: 50rpx;
  597. height: 88rpx;
  598. font-size: 32rpx;
  599. font-weight: bold;
  600. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.3);
  601. position: relative;
  602. &::before {
  603. content: "";
  604. position: absolute;
  605. top: 0;
  606. left: 0;
  607. right: 0;
  608. height: 2rpx;
  609. background: linear-gradient(to right, #60a5fa, #93c5fd);
  610. border-radius: 50rpx 50rpx 0 0;
  611. }
  612. &::after {
  613. content: "";
  614. position: absolute;
  615. bottom: 0;
  616. left: 0;
  617. right: 0;
  618. height: 2rpx;
  619. background: #000;
  620. border-radius: 0 0 50rpx 50rpx;
  621. }
  622. }
  623. }
  624. </style>