您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

vehicle-details.vue 17KB

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