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

vehicle-information.vue 3.7KB

1年前
1年前
10 个月前
1年前
10 个月前
1年前
1年前
1年前
1年前
1年前
10 个月前
1年前
10 个月前
1年前
1年前
1年前
10 个月前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view v-if="state.list.length!=0" style="padding-bottom:30rpx ;">
  3. <view class="car-item" v-for="(item,index) in state.list">
  4. <image :src="`${$imgUrl}che.png`" class="car-pic" @click="carDetails(item)"></image>
  5. <view class="car-info" @click="carDetails(item)">
  6. <view class="car-no"><text class="no">{{item.vehiclePlate}}</text><text class="color"
  7. :style="{ background: item.showColor}">{{item.color}}</text></view>
  8. <view class="card-no">卡号:{{item.cardId}}</view>
  9. <view class="card-no">签号:{{item.obuId}}</view>
  10. </view>
  11. <view class="btn-unbind" @click="del(item.vehicleId)">解除绑定</view>
  12. </view>
  13. </view>
  14. <view v-else class="no">暂无车辆信息</view>
  15. </template>
  16. <script lang="ts" setup>
  17. import { reactive } from "vue";
  18. import { requestNew } from "@/utils/network/request.js";
  19. import { onLoad } from "@dcloudio/uni-app";
  20. import { selectCarInfo, delCarInfo } from "@/utils/network/api.js";
  21. import { getItem } from "@/utils/storage";
  22. import { vehiclePlateColorPai } from "@/datas/vehiclePlateColor.js";
  23. const state = reactive({
  24. list: ''
  25. })
  26. onLoad((option : any) => {
  27. queryCarMsg();
  28. })
  29. const carDetails = (item) => {
  30. const params = encodeURIComponent(JSON.stringify(item))
  31. uni.navigateTo({
  32. url: `/subpackage/personal-center/car-details?params=${params}`
  33. })
  34. }
  35. const queryCarMsg = () => {
  36. const options = {
  37. type: 2,
  38. data: {
  39. "openId": getItem('openId')
  40. },
  41. method: "POST",
  42. showLoading: true,
  43. };
  44. //调用方式
  45. requestNew(selectCarInfo, options).then((res) => {
  46. console.log("车辆信息:", res)
  47. const data = res.vehicleManages
  48. for (var i = 0; i < data.length; i++) {
  49. for (var j = 0; j < vehiclePlateColorPai.length; j++) {
  50. if (data[i].vehiclePlateColor == vehiclePlateColorPai[j]['id']) {
  51. data[i].color = vehiclePlateColorPai[j]['color']
  52. data[i].showColor = vehiclePlateColorPai[j]['showColor']
  53. }
  54. }
  55. }
  56. console.log("data", data)
  57. state.list = data;
  58. })
  59. .catch((err) => {
  60. });
  61. }
  62. // 删除
  63. const del = (id) => {
  64. uni.showModal({
  65. title: '提示',
  66. content: '是否删除该条车辆信息',
  67. success: function (res) {
  68. if (res.confirm) {
  69. console.log('用户点击确定');
  70. let data = {
  71. vehicleId: id,
  72. openId: getItem('openId')
  73. }
  74. const options = {
  75. type: 2,
  76. data: data,
  77. method: "POST",
  78. showLoading: true,
  79. };
  80. requestNew(delCarInfo, options).then((res) => {
  81. const data = res;
  82. console.log(data)
  83. uni.showToast({
  84. title: "删除成功",
  85. icon: "none"
  86. })
  87. queryCarMsg();
  88. });
  89. } else if (res.cancel) {
  90. console.log('用户点击取消');
  91. }
  92. }
  93. });
  94. }
  95. </script>
  96. <style scoped>
  97. .car-item {
  98. display: flex;
  99. align-items: center;
  100. padding: 36rpx 0;
  101. width: 95%;
  102. margin: 0 auto;
  103. background: #f6f6f6;
  104. border-radius: 16rpx;
  105. padding: 20rpx;
  106. box-sizing: border-box;
  107. margin-top: 30rpx;
  108. }
  109. .car-item .btn-unbind {
  110. border: 1px solid #00B38B;
  111. border-radius: 30rpx;
  112. height: 56rpx;
  113. box-sizing: border-box;
  114. line-height: 56rpx;
  115. font-size: 24rpx;
  116. padding: 0 20rpx;
  117. background: rgba(0, 179, 139, .1);
  118. color: #00B38B;
  119. margin-bottom: 10rpx;
  120. }
  121. .car-pic {
  122. width: 120rpx;
  123. height: 120rpx;
  124. margin-right: 16rpx;
  125. }
  126. .car-info {
  127. display: flex;
  128. flex-direction: column;
  129. flex: 1;
  130. color: #999;
  131. font-size: 22rpx;
  132. }
  133. .car-no {
  134. font-size: 30rpx;
  135. color: #333;
  136. }
  137. .card-no {
  138. margin-top: 14rpx;
  139. }
  140. .no {
  141. text-align: center;
  142. margin: 50rpx auto;
  143. }
  144. .color {
  145. padding: 4rpx 8rpx;
  146. border-radius: 10rpx;
  147. color: white;
  148. background-color: rgb(6, 112, 255);
  149. display: inline-block;
  150. margin-left: 20rpx;
  151. font-size: 24rpx;
  152. }
  153. </style>