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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view v-if="state.list.length!=0">
  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">{{item.color}}</text></view>
  7. <view class="card-no">卡号:{{item.cardId}}</view>
  8. <view class="card-no">签号:{{item.obuId}}</view>
  9. </view>
  10. <view class="btn-unbind" @click="del(item.vehicleId)">解除绑定</view>
  11. </view>
  12. </view>
  13. <view v-else class="no">暂无车辆信息</view>
  14. </template>
  15. <script lang="ts" setup>
  16. import { reactive } from "vue";
  17. import {request} from "@/utils/network/request.js";
  18. import {stringToJson} from "@/utils/network/encryption.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. request(selectCarInfo, options).then((res) => {
  46. console.log("车辆信息:",res)
  47. const data = stringToJson(res.bizContent).vehicleManages
  48. // for(var i=0;i<data.length;i++){
  49. // for(var j=0;j<vehiclePlateColor.length;j++){
  50. // if(data[i].vehiclePlateColor==vehiclePlateColor[j]['id']){
  51. // data[i].color=vehiclePlateColor[j]['color']
  52. // }
  53. // }
  54. // }
  55. for (var i = 0; i < data.length; i++) {
  56. for (var j = 0; j < vehiclePlateColorPai.length; j++) {
  57. if (data[i].vehiclePlateColor == vehiclePlateColorPai[j]['id']) {
  58. data[i].color = vehiclePlateColorPai[j]['color']
  59. }
  60. }
  61. }
  62. console.log("data",data)
  63. state.list=data;
  64. })
  65. .catch((err) => {
  66. });
  67. }
  68. // 删除
  69. const del = (id) => {
  70. uni.showModal({
  71. title: '提示',
  72. content: '是否删除该条车辆信息',
  73. success: function(res) {
  74. if (res.confirm) {
  75. console.log('用户点击确定');
  76. let data = {
  77. vehicleId: id,
  78. openId: getItem('openId')
  79. }
  80. const options = {
  81. type: 2,
  82. data: data,
  83. method: "POST",
  84. showLoading: true,
  85. };
  86. request(delCarInfo, options).then((res) => {
  87. const data = stringToJson(res.bizContent);
  88. console.log(data)
  89. state.list = data.vehicleManages
  90. if (data.info == '成功.') {
  91. uni.showToast({
  92. title: "删除成功",
  93. icon: "none"
  94. })
  95. queryCarMsg();
  96. }
  97. });
  98. } else if (res.cancel) {
  99. console.log('用户点击取消');
  100. }
  101. }
  102. });
  103. }
  104. </script>
  105. <style scoped>
  106. .car-item {
  107. display: flex;
  108. align-items: center;
  109. padding: 36rpx 0;
  110. width: 95%;
  111. margin:0 auto;
  112. background:#f6f6f6;
  113. border-radius: 16rpx;
  114. padding: 20rpx;
  115. box-sizing: border-box;
  116. margin-top:30rpx;
  117. }
  118. .car-item .btn-unbind {
  119. border: 1px solid #00B38B;
  120. border-radius: 30rpx;
  121. height: 60rpx;
  122. box-sizing: border-box;
  123. line-height: 60rpx;
  124. font-size: 24rpx;
  125. padding: 0 20rpx;
  126. background: rgba(0, 179, 139, .1);
  127. color: #00B38B;
  128. }
  129. .car-pic {
  130. width: 120rpx;
  131. height: 120rpx;
  132. margin-right: 12rpx;
  133. }
  134. .car-info {
  135. display: flex;
  136. flex-direction: column;
  137. flex: 1;
  138. color: #999;
  139. font-size: 22rpx;
  140. }
  141. .car-no {
  142. font-size: 30rpx;
  143. color: #333;
  144. }
  145. .card-no {
  146. margin-top: 14rpx;
  147. }
  148. .no{
  149. text-align: center;
  150. margin: 50rpx auto;
  151. }
  152. .color{
  153. padding: 4rpx 8rpx;
  154. border-radius: 10rpx;
  155. color: white;
  156. background-color: rgb(6, 112, 255);
  157. display: inline-block;
  158. margin-left: 20rpx;
  159. font-size: 24rpx;
  160. }
  161. </style>