index.vue 5.3 KB

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