index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <!-- 管理车辆 -->
  2. <template>
  3. <view class="content">
  4. <view class="top-title flex flex-space-between">
  5. <view class="left flex">
  6. <view class="text1">我的机动车</view>
  7. <view class="text2">(共{{carList?carList.length:0}}辆)</view>
  8. </view>
  9. <view @click="addCar" class="add-car flex">
  10. <view class="car-text">添加车辆</view>
  11. <u-icon class="icon" name="plus-circle-fill" color="#2979ff" size="24"></u-icon>
  12. </view>
  13. </view>
  14. <view class="car-list" v-for="(item,index) in carList" :key="index">
  15. <view class="car-list-item">
  16. <view class="row1">
  17. {{item.carNumber}}
  18. </view>
  19. <view class="row2">
  20. <u-icon name="edit-pen" size="26" style="margin-right: 20rpx;" @click="edit(item)"></u-icon>
  21. <u-icon name="trash" size="26" @click="del(item,index)"></u-icon>
  22. </view>
  23. <view class="row3">
  24. <view class="text">车辆状态:</view>
  25. <u-tag v-if="item.status=='已通过'" :text="item.status" type="success" plain plainFill size="mini"></u-tag>
  26. <u-tag v-if="item.status=='未通过'" :text="item.status" type="error" plain plainFill size="mini"></u-tag>
  27. <u-tag v-if="item.status=='审核中'" :text="item.status" type="warning" plain plainFill size="mini"></u-tag>
  28. </view>
  29. </view>
  30. </view>
  31. <u-toast ref="uToast"></u-toast>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. mapState
  37. } from 'vuex';
  38. var _this;
  39. export default {
  40. data() {
  41. return {
  42. carList:[],
  43. };
  44. },
  45. computed: {
  46. ...mapState(['hasLogin', 'userInfo']),
  47. },
  48. onLoad(options) {
  49. _this = this;
  50. if (!this.hasLogin) {
  51. uni.$u.route('/pages/public/login');
  52. }
  53. this.init();
  54. console.log(options)
  55. },
  56. methods: {
  57. init() {
  58. this.$request.baseRequest('post', '/driverCarInfo/selectCar', {
  59. driverId: this.userInfo.driverId,
  60. }).then(res => {
  61. if (res.code == '200') {
  62. this.carList = res.data
  63. }else{
  64. uni.$u.toast(res.message);
  65. }
  66. })
  67. .catch(res => {
  68. uni.$u.toast(res.message);
  69. });
  70. },
  71. addCar() {
  72. uni.$u.route('/pages/mine/manageVehicles/addVehicle');
  73. },
  74. edit(val) {
  75. uni.$u.route('/pages/mine/manageVehicles/editVehicle',val);
  76. },
  77. del(val,index) {
  78. this.$request.baseRequest('post', '/driverCarInfo/api/deleteDriverCar', {
  79. id:val.id
  80. }).then(res => {
  81. if (res.code == '200') {
  82. this.$refs.uToast.show({
  83. type: 'success',
  84. message: "删除成功!",
  85. })
  86. this.carList.splice(index,1)
  87. }
  88. })
  89. .catch(res => {
  90. uni.$u.toast(res.message);
  91. });
  92. }
  93. },
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. .content {
  98. background: white;
  99. padding: 20rpx;
  100. }
  101. .content1 {
  102. width: 100%;
  103. }
  104. .content1-item {
  105. width: calc(50% - 0rpx);
  106. }
  107. .top-title {
  108. margin: 0 0 20rpx 0;
  109. .left {
  110. .text1 {
  111. font-size: 29rpx;
  112. color: #1F1F1F;
  113. font-weight: 700;
  114. }
  115. .text2 {
  116. font-size: 29rpx;
  117. color: #999999;
  118. }
  119. }
  120. }
  121. .car-text {
  122. margin-right: 6rpx;
  123. }
  124. .add-car {
  125. background: #EEF4FF;
  126. color: #2772FB;
  127. font-weight: 700;
  128. font-size: 26rpx;
  129. align-items: center;
  130. padding: 4rpx 10rpx 4rpx 20rpx;
  131. border-radius: 30rpx;
  132. }
  133. .car-list {
  134. margin-bottom: 20rpx;
  135. }
  136. .car-list-item {
  137. background: url(../../../static/images/mine/bgh.png) center no-repeat;
  138. background-size: 100% 100%;
  139. padding: 60rpx 43rpx;
  140. .row1 {
  141. font-size: 36rpx;
  142. font-weight: 700;
  143. color: #1F1F1F;
  144. }
  145. .row2 {
  146. display: flex;
  147. justify-content: flex-end;
  148. }
  149. .row3 {
  150. display: flex;
  151. }
  152. }
  153. </style>