洛阳学员端
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.

136 lines
2.7 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
  1. <template>
  2. <!-- 选择驾校弹出框 -->
  3. <view class="box">
  4. <view class="schoolTit">
  5. 选择驾校
  6. </view>
  7. <view class="searchBox">
  8. <u-search placeholder="请输入驾校名称" v-model.trim="keyword" @search="searchSchool" @custom="searchSchool" @clear="searchSchool">
  9. </u-search>
  10. </view>
  11. <scroll-view scroll-y="true" style="height: 700rpx" @scrolltolower="loadMoreFn">
  12. <view class="ul">
  13. <view class="li" v-for="(item,index) in listData" :key="index" @click="chooseSchool(item)">
  14. <view class="name">
  15. {{ $u.utils.truncateText(item.name, 18) }}
  16. </view>
  17. <view class="starText">
  18. {{item.stars}}
  19. </view>
  20. <!-- <view class="distance">
  21. {{ $u.utils.distanceFn(item.distance)}}
  22. </view> -->
  23. </view>
  24. </view>
  25. <u-loadmore :status="status" icon-type="circle" />
  26. </scroll-view>
  27. </view>
  28. </template>
  29. <script>
  30. import { schoolPage } from '@/config/api.js'
  31. export default {
  32. data() {
  33. return {
  34. keyword: '',
  35. status: 'loadmore',
  36. listData: [],
  37. total: 10,
  38. params: {
  39. pageNo: 1,
  40. pageSize: 20,
  41. lat: 30.27419537786047,
  42. lng: 120.20633397715788,
  43. sercheType: '1',
  44. }
  45. }
  46. },
  47. created() {
  48. if(this.vuex_cityInfo.lat) {
  49. this.params.lat = this.vuex_cityInfo.lat
  50. this.params.lng = this.vuex_cityInfo.lng
  51. }
  52. this.schoolPageFn()
  53. this.params.name = ''
  54. },
  55. methods: {
  56. // 选择驾校
  57. chooseSchool(item) {
  58. this.$emit('chooseSchool', item)
  59. },
  60. // 获取驾校列表
  61. async schoolPageFn() {
  62. const {data: res} = await schoolPage(this.params)
  63. this.params.pageNo ++
  64. this.listData.push(...res.list)
  65. this.total = res.total
  66. if(this.listData.length>=this.total) this.status = 'nomore'
  67. console.log(res)
  68. },
  69. searchSchool() {
  70. this.params.pageNo = 1
  71. this.params.name = this.keyword
  72. this.listData = []
  73. this.schoolPageFn()
  74. },
  75. loadMoreFn() {
  76. if(this.listData.length<this.total) {
  77. this.schoolPageFn()
  78. }
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .schoolTit {
  85. line-height: 90rpx;
  86. text-align: center;
  87. font-size: 28rpx;
  88. }
  89. .searchBox {
  90. width: 100%;
  91. padding: 0 20rpx 20rpx 20rpx;
  92. border-bottom: 1rpx solid #ededed;
  93. }
  94. .ul {
  95. width: 100%;
  96. padding: 0 20rpx;
  97. .li {
  98. width: 100%;
  99. display: flex;
  100. align-items: center;
  101. height: 90rpx;
  102. font-size: 24rpx;
  103. border-bottom: 1rpx solid #ededed;
  104. &:last-child {
  105. border: none;
  106. }
  107. .name {
  108. width: 0;
  109. flex: 1;
  110. font-size: 28rpx;
  111. }
  112. .starText {
  113. color: red;
  114. width: 100rpx;
  115. text-align: right;
  116. flex-shrink: 0;
  117. white-space: nowrap;
  118. }
  119. .distance {
  120. width: 120rpx;
  121. text-align: right;
  122. flex-shrink: 0;
  123. white-space: nowrap;
  124. }
  125. }
  126. }
  127. </style>