index.vue 4.7 KB

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