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

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