message.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view>
  3. <view class="flex padding-lg align-center">
  4. <image v-if="globalImages" :src="globalImages + 'imgs/dui.png'" style="width: 30rpx;height: 30rpx;" mode=""></image>
  5. <view style="margin-left: 20rpx;">
  6. 当前使用车辆: {{ checkeditem.carBrand }}
  7. </view>
  8. </view>
  9. <view class="margin padding boxss" v-for="(item, index) in list" :key="index">
  10. <view class="flex" style="justify-content: space-between;">
  11. <view class="flex">
  12. <view>
  13. <image :src="item.carPhoto ? item.carPhoto : ''" style="width: 200rpx;height: 140rpx;" mode=""></image>
  14. </view>
  15. <view style="margin-left: 20rpx;">
  16. <view>{{ item.carPlate }}</view>
  17. <view style="color: #999;">{{ item.carBrand }} - {{ item.carColor }}</view>
  18. <view style="color: #00c18a;" v-if="item.status === 2">已认证</view>
  19. <view style="color: #e6a23c;" v-if="item.status === 1">审核中</view>
  20. <view style="color: #f56c6c;" v-if="item.status === 3">审核失败</view>
  21. </view>
  22. </view>
  23. <view >
  24. <view style="margin-left: 20rpx; background: #00c18a; padding: 8rpx 15rpx; border-radius: 11rpx; color: #fff;" v-if="item.checked === 0">使用中</view>
  25. <view style="margin-left: 20rpx; background: #e6a23c; padding: 8rpx 15rpx; border-radius: 11rpx; color: #fff;" v-if="item.checked === 1">未使用</view>
  26. </view>
  27. </view>
  28. <view style="border-top: 1rpx solid #f3f4f6; margin: 20rpx 0;"></view>
  29. <view class="flex" style="justify-content: space-between;color: #999;">
  30. <view class="">
  31. <!-- 编辑图标 -->
  32. <view style="position: absolute; left: 130rpx;" @tap="handleEdit(item)">
  33. <image v-if="globalImages" :src="globalImages + 'imgs/edit.png'" style="width: 32rpx;height: 32rpx;" mode="">
  34. </image>
  35. </view>
  36. <!-- 删除图标 -->
  37. <view style="position: absolute; left: 60rpx;" @click="handleDelete(item.carId)">
  38. <image v-if="globalImages" :src="globalImages + 'imgs/del.png'" style="width: 32rpx;height: 32rpx;" mode="">
  39. </image>
  40. </view>
  41. </view>
  42. <view @click="updateChecked(item)">切换使用</view>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import { waitForGlobalImages } from '@/utils/globalImageLoader'
  49. export default {
  50. data() {
  51. return {
  52. globalImages: '',
  53. list: [],
  54. checkeditem: {}
  55. }
  56. },
  57. onLoad() {
  58. waitForGlobalImages().then((path) => {
  59. console.log('✅ 全局图片路径:', path)
  60. this.globalImages = path
  61. })
  62. this.selectCarList()
  63. },
  64. methods: {
  65. // list数据
  66. selectCarList() {
  67. this.$Request.getT('/app/car/selectCarList').then(res => {
  68. if (res.code == 0) {
  69. if (res.data) {
  70. this.list = res.data
  71. this.checkeditem = this.list.find(item => item.checked === 1)
  72. } else {
  73. this.list = ''
  74. }
  75. }
  76. })
  77. },
  78. insertCar() {
  79. this.$Request.postT("/app/car/insertCar").then(res => {
  80. });
  81. },
  82. updateCar() {
  83. this.$Request.postT("/app/car/updateCar").then(res => {
  84. });
  85. },
  86. handleDelete(id) {
  87. let data = {
  88. carId: id
  89. }
  90. this.$Request.postT("/app/car/deleteCar", data).then(res => {
  91. if (res.code == 0) {
  92. uni.showModal({
  93. title: '提示',
  94. content: '删除成功',
  95. showCancel: false,
  96. success: () => {
  97. this.selectCarList()
  98. }
  99. });
  100. } else {
  101. uni.showModal({
  102. title: '提示',
  103. content: res.msg,
  104. showCancel: false
  105. });
  106. }
  107. }).catch(err => {
  108. uni.showModal({
  109. title: '提示',
  110. content: '网络错误,请重试',
  111. showCancel: false
  112. });
  113. });
  114. },
  115. updateChecked(item) {
  116. const newChecked = item.checked === 0 ? 1 : 0;
  117. const data = {
  118. ...item,
  119. checked: newChecked
  120. }
  121. this.$Request.postT("/app/car/updateChecked", data).then(res => {
  122. if (res.code == 0) {
  123. uni.showModal({
  124. title: '提示',
  125. content: '切换成功',
  126. showCancel: false,
  127. success: () => {
  128. this.selectCarList()
  129. this.checkeditem = this.list.find(item => item.checked === 1);
  130. }
  131. });
  132. } else {
  133. uni.showModal({
  134. title: '提示',
  135. content: res.msg,
  136. showCancel: false
  137. });
  138. }
  139. }).catch(err => {
  140. uni.showModal({
  141. title: '提示',
  142. content: '网络错误,请重试',
  143. showCancel: false
  144. });
  145. });
  146. }
  147. },
  148. }
  149. </script>
  150. <style scoped lang="scss">
  151. .boxss {
  152. background: #fff;
  153. border-radius: 16rpx;
  154. }
  155. </style>