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.

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