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-information.vue 3.9KB

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