You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
3.5 KiB

9 months ago
9 months ago
9 months ago
9 months ago
  1. <template>
  2. <view class="pageBg">
  3. <view class="pageBgImg">
  4. <topNavbar title="我的车辆"></topNavbar>
  5. <view class="pad">
  6. <view class="searcBox">
  7. <searchRow placeholder="搜索车牌号" @searchFn="searchFn" ref="searchRef"></searchRow>
  8. </view>
  9. <view class="card" style="margin-bottom: 24rpx;" v-if="identity== '实操教练'">
  10. <view class="add">
  11. <view class="lab">绑定车辆</view>
  12. <view class="btnBg" @click="$goPage('/pages/userCenter/myCar/notBound/notBound')">立即绑定</view>
  13. </view>
  14. </view>
  15. <view class="ul">
  16. <view class="card" v-for="(item,index) in list" :key="index">
  17. <unbind v-if="identity== '实操教练'" @cancelBind="cancelBind(item)">
  18. <view class="li" >
  19. <view class="plate">{{item.licnum}}</view>
  20. <view class="name">{{item.manufacturer}}</view>
  21. </view>
  22. </unbind>
  23. <view class="li" v-else>
  24. <view class="plate">{{item.licnum}}</view>
  25. <view class="name">{{item.manufacturer}}</view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view style="padding-bottom: 20rpx;" v-if="list.length>4">
  31. <u-loadmore :status="status" />
  32. </view>
  33. <nodata v-if="!list.length&&status=='nomore'"></nodata>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import { carPage, coachUnbinding, siteCarPage } from '@/config/api.js'
  39. import unbind from './comp/unbind.vue'
  40. export default {
  41. components: {
  42. unbind
  43. },
  44. data() {
  45. return {
  46. list: [],
  47. params: {
  48. pageNo: 1,
  49. pageSize: 20
  50. },
  51. total: 20,
  52. status: 'loading'
  53. }
  54. },
  55. onLoad() {
  56. this.params.schoolId = this.vuex_schoolId
  57. if(this.identity== '实操教练') {
  58. this.params.coachId = this.vuex_coachId
  59. }
  60. },
  61. onShow() {
  62. if(this.params.licnum) this.$refs.searchRef.keyword = ''
  63. this.params.licnum = ''
  64. this.listInit()
  65. },
  66. onPullDownRefresh() {
  67. this.listInit().then(()=>{uni.stopPullDownRefresh()})
  68. },
  69. onReachBottom() {
  70. if(this.total>this.list.length) {
  71. this.carPageFn()
  72. }
  73. },
  74. methods: {
  75. async listInit() {
  76. this.list = []
  77. this.params.pageNo = 1
  78. await this.carPageFn()
  79. },
  80. async carPageFn() {
  81. if(this.identity=='考场模拟教练') {
  82. var {data: res} = await siteCarPage(this.params)
  83. }else {
  84. var {data: res} = await carPage(this.params)
  85. }
  86. this.params.pageNo ++
  87. this.list.push(...res.list)
  88. this.total = res.total
  89. if(this.list.length>=this.total) this.status = 'nomore'
  90. console.log(res)
  91. },
  92. searchFn(val) {
  93. console.log(val)
  94. this.params.licnum = val
  95. this.list = []
  96. this.params.pageNo = 1
  97. this.carPageFn()
  98. },
  99. // 取消绑定
  100. async cancelBind(item) {
  101. let obj = {
  102. "carId": item.id,
  103. "coachId": this.vuex_coachId,
  104. "coachName": this.vuex_userInfo.name
  105. }
  106. const res = await coachUnbinding(obj)
  107. if(res.code==0) {
  108. this.$u.toast('解绑成功')
  109. this.listInit()
  110. }
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="scss" scoped>
  116. .searcBox {
  117. padding: 0 0 24rpx 0;
  118. }
  119. .card {
  120. margin-bottom: 20rpx;
  121. overflow: hidden;
  122. height: 100rpx;
  123. .add {
  124. display: flex;
  125. align-items: center;
  126. justify-content: space-between;
  127. height: 108rpx;
  128. padding: 0 40rpx;
  129. .lab {
  130. font-size: 32rpx;
  131. color: #333;
  132. font-weight: 500;
  133. }
  134. .btnBg {
  135. width: 192rpx;
  136. }
  137. }
  138. .li {
  139. height: 100rpx;
  140. display: flex;
  141. align-items: center;
  142. justify-content: space-between;
  143. padding: 0 24rpx;
  144. .plate {
  145. color: $themC;
  146. font-weight: 500;
  147. }
  148. .name {
  149. color: #686B73;
  150. }
  151. }
  152. }
  153. </style>