index.vue 5.5 KB

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