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.2KB

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