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

vehicle-information.vue 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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"></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 {vehiclePlateColorPai} 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. 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. }
  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. request(delCarInfo, options).then((res) => {
  81. const data = stringToJson(res.bizContent);
  82. console.log(data)
  83. state.list = data.vehicleManages
  84. if (data.info == '成功.') {
  85. uni.showToast({
  86. title: "删除成功",
  87. icon: "none"
  88. })
  89. queryCarMsg();
  90. }
  91. });
  92. } else if (res.cancel) {
  93. console.log('用户点击取消');
  94. }
  95. }
  96. });
  97. }
  98. </script>
  99. <style scoped>
  100. .car-item {
  101. display: flex;
  102. align-items: center;
  103. padding: 36rpx 0;
  104. width: 95%;
  105. margin:0 auto;
  106. background:#f6f6f6;
  107. border-radius: 16rpx;
  108. padding: 20rpx;
  109. box-sizing: border-box;
  110. margin-top:30rpx;
  111. }
  112. .car-item .btn-unbind {
  113. border: 1px solid #00B38B;
  114. border-radius: 30rpx;
  115. height: 60rpx;
  116. box-sizing: border-box;
  117. line-height: 60rpx;
  118. font-size: 24rpx;
  119. padding: 0 20rpx;
  120. background: rgba(0, 179, 139, .1);
  121. color: #00B38B;
  122. }
  123. .car-pic {
  124. width: 120rpx;
  125. height: 120rpx;
  126. margin-right: 12rpx;
  127. }
  128. .car-info {
  129. display: flex;
  130. flex-direction: column;
  131. flex: 1;
  132. color: #999;
  133. font-size: 22rpx;
  134. }
  135. .car-no {
  136. font-size: 30rpx;
  137. color: #333;
  138. }
  139. .card-no {
  140. margin-top: 14rpx;
  141. }
  142. .no{
  143. text-align: center;
  144. margin: 50rpx auto;
  145. }
  146. .color{
  147. padding: 4rpx 8rpx;
  148. border-radius: 10rpx;
  149. color: white;
  150. background-color: rgb(6, 112, 255);
  151. display: inline-block;
  152. margin-left: 20rpx;
  153. font-size: 24rpx;
  154. }
  155. </style>