message.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 style="margin-left: 20rpx;" @click="navigateToAddCarPage()">
  9. 新增
  10. </view>
  11. </view>
  12. <view class="margin padding boxss" v-for="(item, index) in list" :key="index">
  13. <view class="flex" style="justify-content: space-between;">
  14. <view class="flex">
  15. <view>
  16. <image :src="item.carPhoto ? item.carPhoto : ''" style="width: 200rpx;height: 140rpx;" mode=""></image>
  17. </view>
  18. <view style="margin-left: 20rpx;">
  19. <view>{{ item.carPlate }}</view>
  20. <view style="color: #999;">{{ item.carBrand }} - {{ item.carColor }}</view>
  21. <view style="color: #00c18a;" v-if="item.status === 2">已认证</view>
  22. <view style="color: #e6a23c;" v-if="item.status === 1">审核中</view>
  23. <view style="color: #f56c6c;" v-if="item.status === 3">审核失败</view>
  24. </view>
  25. </view>
  26. <view >
  27. <view style="margin-left: 20rpx; background: #00c18a; padding: 8rpx 15rpx; border-radius: 11rpx; color: #fff;" v-if="item.checked === 0">使用中</view>
  28. <view style="margin-left: 20rpx; background: #e6a23c; padding: 8rpx 15rpx; border-radius: 11rpx; color: #fff;" v-if="item.checked === 1">未使用</view>
  29. </view>
  30. </view>
  31. <view style="border-top: 1rpx solid #f3f4f6; margin: 20rpx 0;"></view>
  32. <view class="flex" style="justify-content: space-between;color: #999;">
  33. <view class="">
  34. <!-- 编辑图标 -->
  35. <view style="position: absolute; left: 130rpx;" @click="navigateToAddCarPage(item)">
  36. <image v-if="globalImages" :src="globalImages + 'imgs/edit.png'" style="width: 32rpx;height: 32rpx;" mode="">
  37. </image>
  38. </view>
  39. <!-- 删除图标 -->
  40. <view style="position: absolute; left: 60rpx;" @click="handleDelete(item.carId)">
  41. <image v-if="globalImages" :src="globalImages + 'imgs/del.png'" style="width: 32rpx;height: 32rpx;" mode="">
  42. </image>
  43. </view>
  44. </view>
  45. <view @click="updateChecked(item)">切换使用</view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import { waitForGlobalImages } from '@/utils/globalImageLoader'
  52. export default {
  53. data() {
  54. return {
  55. globalImages: '',
  56. list: [],
  57. checkeditem: {}
  58. }
  59. },
  60. onLoad() {
  61. waitForGlobalImages().then((path) => {
  62. console.log('✅ 全局图片路径:', path)
  63. this.globalImages = path
  64. })
  65. this.selectCarList()
  66. },
  67. onShow() {
  68. this.selectCarList()
  69. },
  70. // 监听导航栏按钮点击事件
  71. onNavigationBarButtonTap(e) {
  72. console.log('走了');
  73. // 点击图片按钮时跳转
  74. this.navigateToAddCarPage();
  75. },
  76. methods: {
  77. navigateToAddCarPage(item) {
  78. let url = '/my/setting/addCar'; // 默认跳转到新增页面
  79. if (item) {
  80. url += `?item=${encodeURIComponent(JSON.stringify(item))}`; // 如果传入了 carId,则跳转到编辑页面
  81. }
  82. uni.navigateTo({
  83. url: url
  84. });
  85. },
  86. // list数据
  87. selectCarList() {
  88. this.$Request.getT('/app/car/selectCarList').then(res => {
  89. if (res.code == 0) {
  90. if (res.data) {
  91. this.list = res.data
  92. this.checkeditem = this.list.find(item => item.checked === 1)
  93. } else {
  94. this.list = ''
  95. }
  96. }
  97. })
  98. },
  99. insertCar() {
  100. this.$Request.postT("/app/car/insertCar").then(res => {
  101. });
  102. },
  103. updateCar() {
  104. this.$Request.postT("/app/car/updateCar").then(res => {
  105. });
  106. },
  107. handleDelete(id) {
  108. let data = {
  109. carId: id
  110. }
  111. this.$Request.postT("/app/car/deleteCar", data).then(res => {
  112. if (res.code == 0) {
  113. uni.showModal({
  114. title: '提示',
  115. content: '删除成功',
  116. showCancel: false,
  117. success: () => {
  118. this.selectCarList()
  119. }
  120. });
  121. } else {
  122. uni.showModal({
  123. title: '提示',
  124. content: res.msg,
  125. showCancel: false
  126. });
  127. }
  128. }).catch(err => {
  129. uni.showModal({
  130. title: '提示',
  131. content: '网络错误,请重试',
  132. showCancel: false
  133. });
  134. });
  135. },
  136. updateChecked(item) {
  137. const newChecked = item.checked === 0 ? 1 : 0;
  138. const data = {
  139. ...item,
  140. checked: newChecked
  141. }
  142. this.$Request.postT("/app/car/updateChecked", data).then(res => {
  143. if (res.code == 0) {
  144. uni.showModal({
  145. title: '提示',
  146. content: '切换成功',
  147. showCancel: false,
  148. success: () => {
  149. this.selectCarList()
  150. this.checkeditem = this.list.find(item => item.checked === 1);
  151. }
  152. });
  153. } else {
  154. uni.showModal({
  155. title: '提示',
  156. content: res.msg,
  157. showCancel: false
  158. });
  159. }
  160. }).catch(err => {
  161. uni.showModal({
  162. title: '提示',
  163. content: '网络错误,请重试',
  164. showCancel: false
  165. });
  166. });
  167. }
  168. },
  169. }
  170. </script>
  171. <style scoped lang="scss">
  172. .boxss {
  173. background: #fff;
  174. border-radius: 16rpx;
  175. }
  176. </style>