index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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','firstAuthentication']),
  47. },
  48. onLoad(options) {
  49. console.log(this.firstAuthentication.id)
  50. _this = this;
  51. if (!this.hasLogin) {
  52. uni.$u.route('/pages/public/login');
  53. }
  54. this.init();
  55. console.log(options)
  56. },
  57. methods: {
  58. init() {
  59. this.$request.baseRequest('get', '/driverCarInfo/selectDriverCar', {
  60. driverId: this.userInfo.driverId,
  61. // driverId:this.firstAuthentication.id
  62. }).then(res => {
  63. if (res.code == '200') {
  64. this.carList = res.data
  65. }else{
  66. uni.$u.toast(res.message);
  67. }
  68. })
  69. .catch(res => {
  70. uni.$u.toast(res.message);
  71. });
  72. },
  73. addCar() {
  74. uni.$u.route('/pages/mine/manageVehicles/addVehicle');
  75. },
  76. edit(val) {
  77. uni.$u.route('/pages/mine/manageVehicles/editVehicle',val);
  78. },
  79. del(val,index) {
  80. this.$request.baseRequest('post', '/driverCarInfo/api/deleteDriverCar', {
  81. id:val.id
  82. }).then(res => {
  83. if (res.code == '200') {
  84. this.$refs.uToast.show({
  85. type: 'success',
  86. message: "删除成功!",
  87. })
  88. this.carList.splice(index,1)
  89. }
  90. })
  91. .catch(res => {
  92. uni.$u.toast(res.message);
  93. });
  94. }
  95. },
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. .content {
  100. background: white;
  101. padding: 20rpx;
  102. }
  103. .content1 {
  104. width: 100%;
  105. }
  106. .content1-item {
  107. width: calc(50% - 0rpx);
  108. }
  109. .top-title {
  110. margin: 0 0 20rpx 0;
  111. .left {
  112. .text1 {
  113. font-size: 29rpx;
  114. color: #1F1F1F;
  115. font-weight: 700;
  116. }
  117. .text2 {
  118. font-size: 29rpx;
  119. color: #999999;
  120. }
  121. }
  122. }
  123. .car-text {
  124. margin-right: 6rpx;
  125. }
  126. .add-car {
  127. background: #EEF4FF;
  128. color: #2772FB;
  129. font-weight: 700;
  130. font-size: 26rpx;
  131. align-items: center;
  132. padding: 4rpx 10rpx 4rpx 20rpx;
  133. border-radius: 30rpx;
  134. }
  135. .car-list {
  136. margin-bottom: 20rpx;
  137. }
  138. .car-list-item {
  139. background: url(../../../static/images/mine/bgh.png) center no-repeat;
  140. background-size: 100% 100%;
  141. padding: 60rpx 43rpx;
  142. .row1 {
  143. font-size: 36rpx;
  144. font-weight: 700;
  145. color: #1F1F1F;
  146. }
  147. .row2 {
  148. display: flex;
  149. justify-content: flex-end;
  150. }
  151. .row3 {
  152. display: flex;
  153. }
  154. }
  155. </style>