index.vue 4.9 KB

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