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.

137 lines
2.9 KiB

7 months ago
7 months ago
  1. <template>
  2. <view class="pageBgImg">
  3. <topNavbar title="未绑定的车辆"></topNavbar>
  4. <view class="pad">
  5. <view class="searcBox">
  6. <searchRow placeholder="搜索车牌号" @searchFn="searchFn"></searchRow>
  7. </view>
  8. <view class="ul">
  9. <view class="card" v-for="(item,index) in list" :key="index">
  10. <view class="name">车牌号{{item.licnum}}</view>
  11. <view class="text">车辆型号{{item.manufacturer}}</view>
  12. <view class="flex-b">
  13. <view class="text">培训车型{{item.perdritype}}</view>
  14. <view class="btnBg" @click="bindClick(item)">立即绑定</view>
  15. </view>
  16. </view>
  17. </view>
  18. <view style="padding-bottom: 20rpx;" v-if="list.length">
  19. <u-loadmore :status="status" />
  20. </view>
  21. <nodata v-if="!list.length&&status=='nomore'"></nodata>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import { carPage, coachBinding } from '@/config/api.js'
  27. export default {
  28. data() {
  29. return {
  30. list: [],
  31. params: {
  32. pageNo: 1,
  33. pageSize: 20,
  34. coachId: 0
  35. },
  36. total: 20,
  37. status: 'loading'
  38. }
  39. },
  40. onLoad() {
  41. this.params.schoolId = this.vuex_schoolId
  42. this.carPageFn()
  43. },
  44. onPullDownRefresh() {
  45. this.list = []
  46. this.params.pageNo = 1
  47. this.carPageFn().then(()=>{uni.stopPullDownRefresh()})
  48. },
  49. onReachBottom() {
  50. if(this.total>this.list.length) {
  51. this.carPageFn()
  52. }
  53. },
  54. methods: {
  55. async carPageFn() {
  56. const {data: res} = await carPage(this.params)
  57. this.params.pageNo ++
  58. this.list.push(...res.list)
  59. this.total = res.total
  60. if(this.list.length>=this.total) this.status = 'nomore'
  61. console.log(res)
  62. },
  63. searchFn(val) {
  64. console.log(val)
  65. this.params.licnum = val
  66. this.list = []
  67. this.params.pageNo = 1
  68. this.carPageFn()
  69. },
  70. async coachBindingFn(item) {
  71. let obj = {
  72. "carId": item.id,
  73. "coachId": this.vuex_coachId,
  74. "coachName": this.vuex_userInfo.name
  75. }
  76. const res = await coachBinding(obj)
  77. if(res.code==0) {
  78. this.$u.toast('绑定成功')
  79. setTimeout(()=>{
  80. uni.navigateBack()
  81. }, 1500)
  82. }
  83. console.log(res)
  84. },
  85. bindClick(item) {
  86. let title = `确定要将 ${item.licnum} 教练车绑定到您的名下吗?`
  87. let _this = this
  88. uni.showModal({
  89. title,
  90. success: function(res) {
  91. if (res.confirm) {
  92. _this.coachBindingFn(item)
  93. } else if (res.cancel) {
  94. console.log('用户点击取消');
  95. }
  96. }
  97. })
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .ul {
  104. padding-top: 20rpx;
  105. .card {
  106. padding: 20rpx;
  107. margin-bottom: 20rpx;
  108. .name {
  109. font-size: 28rpx;
  110. font-weight: 550;
  111. color: $themC;
  112. }
  113. .text {
  114. margin-top: 16rpx;
  115. font-size: 26rpx;
  116. color: #333;
  117. }
  118. .flex-b {
  119. .text {
  120. }
  121. .btnBg {
  122. height: 60rpx;
  123. line-height: 60rpx;
  124. padding: 0 28rpx;
  125. }
  126. }
  127. }
  128. }
  129. </style>