index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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"
  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. onLoad(options) {
  63. console.log(this.firstAuthentication.id)
  64. _this = this;
  65. if (!this.hasLogin) {
  66. uni.$u.route('/pages/public/login');
  67. }
  68. this.init();
  69. console.log(options)
  70. },
  71. methods: {
  72. confirmClick() {
  73. this.isShowAlert = false
  74. this.$request.baseRequest('post', '/driverCarInfo/api/deleteDriverCar', {
  75. id: this.obj.id
  76. }).then(res => {
  77. if (res.code == '200') {
  78. this.$refs.uToast.show({
  79. type: 'success',
  80. message: "删除成功!",
  81. })
  82. this.carList.splice(this.index, 1)
  83. uni.hideLoading()
  84. }
  85. })
  86. .catch(res => {
  87. uni.$u.toast(res.message);
  88. });
  89. },
  90. cancelClick() {
  91. this.isShowAlert = false
  92. },
  93. init() {
  94. this.$request.baseRequest('get', '/driverCarInfo/selectDriverCar', {
  95. driverId: this.firstAuthentication.id,
  96. // driverId:this.firstAuthentication.id
  97. }).then(res => {
  98. if (res.code == '200') {
  99. this.carList = res.data
  100. } else {
  101. uni.$u.toast(res.message);
  102. }
  103. })
  104. .catch(res => {
  105. uni.$u.toast(res.message);
  106. });
  107. },
  108. addCar() {
  109. uni.$u.route('/pages/mine/manageVehicles/addVehicle');
  110. },
  111. edit(val) {
  112. uni.$u.route('/pages/mine/manageVehicles/editVehicle', val);
  113. },
  114. del(val, index) {
  115. this.obj = val
  116. this.index = index
  117. this.isShowAlert = true
  118. }
  119. },
  120. }
  121. </script>
  122. <style lang="scss" scoped>
  123. .content {
  124. background: white;
  125. padding: 20rpx;
  126. }
  127. .content1 {
  128. width: 100%;
  129. }
  130. .content1-item {
  131. width: calc(50% - 0rpx);
  132. }
  133. .top-title {
  134. margin: 0 0 20rpx 0;
  135. .left {
  136. .text1 {
  137. font-size: 29rpx;
  138. color: #1F1F1F;
  139. font-weight: 700;
  140. }
  141. .text2 {
  142. font-size: 29rpx;
  143. color: #999999;
  144. }
  145. }
  146. }
  147. .car-text {
  148. margin-right: 6rpx;
  149. }
  150. .add-car {
  151. background: #EEF4FF;
  152. color: #2772FB;
  153. font-weight: 700;
  154. font-size: 26rpx;
  155. align-items: center;
  156. padding: 4rpx 10rpx 4rpx 20rpx;
  157. border-radius: 30rpx;
  158. }
  159. .car-list {
  160. margin-bottom: 20rpx;
  161. display: flex;
  162. }
  163. .car-list-item {
  164. background: url(../../../static/images/mine/bgh.png) center no-repeat;
  165. background-size: 100% 100%;
  166. padding: 60rpx 43rpx;
  167. width: 70%;
  168. .row1 {
  169. font-size: 36rpx;
  170. font-weight: 700;
  171. color: #1F1F1F;
  172. }
  173. .row2 {
  174. display: flex;
  175. justify-content: flex-end;
  176. }
  177. .row3 {
  178. display: flex;
  179. }
  180. }
  181. .left-img {
  182. width: 30%;
  183. display: flex;
  184. align-items: center;
  185. justify-content: center;
  186. }
  187. </style>