index.vue 4.0 KB

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