index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view>
  3. <u-navbar title="车辆管理"></u-navbar>
  4. <view class="carNone" v-if="carList.length == 0">
  5. <img src="static/img/none2.svg" alt="">
  6. <p>暂无绑定车辆</p>
  7. <view class="carNone-btn" @click="addCar">
  8. 添加车牌
  9. </view>
  10. </view>
  11. <view class="car" v-else>
  12. <view class="car-item" v-for="(item,index) in carList" :key="item.id" @click="toCarAdd(item)">
  13. <span v-if="item.defaultFlag">默认</span>
  14. <font>{{item.carNum}}</font>
  15. </view>
  16. <view class="car-btn" @click="addCar">添加车牌</view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import * as userApi from '@/apis/user.js'
  22. export default {
  23. data() {
  24. return {
  25. carList: [],
  26. }
  27. },
  28. onShow() {
  29. this.getCarList();
  30. },
  31. methods: {
  32. toCarAdd(item) {
  33. uni.navigateTo({
  34. url: '/pages/user/car/carAdd?id=' + item.id
  35. })
  36. },
  37. getCarList() {
  38. uni.showLoading({
  39. title: "加载中",
  40. mask: true,
  41. })
  42. userApi.regUserCarList().then((res) => {
  43. uni.hideLoading();
  44. this.carList = res.data;
  45. }).catch(error => {
  46. uni.showToast({
  47. title: error,
  48. icon: "none"
  49. })
  50. })
  51. },
  52. addCar() {
  53. uni.navigateTo({
  54. url: '/pages/user/car/carAdd'
  55. })
  56. }
  57. }
  58. }
  59. </script>
  60. <style>
  61. page{
  62. background: #fff;
  63. }
  64. </style>
  65. <style lang="scss" scoped>
  66. .carNone{
  67. display: flex;
  68. flex-direction: column;
  69. justify-content: center;
  70. height: calc(100vh - 44px);
  71. align-items: center;
  72. img{
  73. width: 256px;
  74. height: 256px;
  75. }
  76. p{
  77. margin-top: -60px;
  78. }
  79. .carNone-btn{
  80. font-size: 16px;
  81. color:#00B962;
  82. border: 1px solid #00B962;
  83. padding: 10px 70px;
  84. border-radius: 20px;
  85. margin-top: 48px;
  86. }
  87. }
  88. .car{
  89. padding: 24px;
  90. .car-item{
  91. margin: 10px;
  92. background-color: #00B962;
  93. height: 80px;
  94. border-radius: 8px;
  95. position: relative;
  96. text-align: center;
  97. font{
  98. color:#fff;
  99. font-size: 36px;
  100. line-height:80px;
  101. }
  102. span{
  103. position: absolute;
  104. height: 24px;
  105. width: 48px;
  106. background-color: #008A4B ;
  107. color:#fff;
  108. right: 0;
  109. top: 0;
  110. text-align: center;
  111. line-height: 24px;
  112. border-radius: 0 8px 0 8px;
  113. }
  114. }
  115. .car-btn{
  116. font-size: 16px;
  117. color:#00B962;
  118. border: 1px solid #00B962;
  119. border-radius: 21px;
  120. padding: 10px 0;
  121. text-align: center;
  122. margin-top: 12px;
  123. }
  124. }
  125. </style>