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

189 lines
4.0 KiB

10 months ago
  1. <template>
  2. <view class="pageBg">
  3. <view class="topBg">
  4. <topNavbar title="找教练"></topNavbar>
  5. <view class="searchCon pad">
  6. <searchRow placeholder="搜索驾校名称" @searchFn="$goPage('/pages/indexEntry/findShcool/searchShcool/searchShcool')" :disable="true"></searchRow>
  7. </view>
  8. </view>
  9. <view class="pad">
  10. <view class="navBox">
  11. <view class="tab" v-for="(item,index) in tabData" :key="index" :class="{active: (params.sercheType==item.id&&!(params.businessScope||params.district))}" @click="tabClick(item)">
  12. {{ item.text }}</view>
  13. </view>
  14. <view class="ul">
  15. <view class="li" v-for="(item,index) in listData" :key="index" >
  16. <coachItem :item="item" @click.native="goPage(item)"/>
  17. </view>
  18. </view>
  19. </view>
  20. <view style="padding-bottom: 20rpx;" v-if="listData.length">
  21. <u-loadmore :status="status" />
  22. </view>
  23. <nodata v-if="!listData.length&&status=='nomore'"></nodata>
  24. </view>
  25. </template>
  26. <script>
  27. import coachItem from './comp/coachItem.vue'
  28. import { schoolPage } from '@/config/api.js'
  29. export default {
  30. components: { coachItem },
  31. data() {
  32. return {
  33. currentTab: 0,
  34. tabData: [{
  35. text: '全部',
  36. id: 1
  37. },
  38. {
  39. text: 'C1',
  40. id: 2
  41. },
  42. {
  43. text: 'C2',
  44. id: 3
  45. },
  46. ],
  47. params: {
  48. pageNo: 1,
  49. pageSize: 20,
  50. lat: '',
  51. lng: '',
  52. sercheType: 1,
  53. businessScope: '',
  54. district: '',
  55. name: ''
  56. },
  57. total: 20,
  58. listData: [],
  59. status: 'loading'
  60. }
  61. },
  62. onLoad() {
  63. let vuex_cityInfo = this.$store.state.user.vuex_cityInfo
  64. if(!vuex_cityInfo.lat) {
  65. this.$store.dispatch('getCity')
  66. }else {
  67. this.params.lat = vuex_cityInfo.lat
  68. this.params.lng = vuex_cityInfo.lng
  69. }
  70. this.schoolPageFn()
  71. uni.$on('screenConfirm',(obj)=>{
  72. this.params = Object.assign(this.params, obj)
  73. this.listInit()
  74. })
  75. },
  76. onPullDownRefresh() {
  77. this.listInit()
  78. },
  79. onReachBottom() {
  80. if(this.total>this.listData.length) {
  81. this.schoolPageFn()
  82. }
  83. },
  84. methods: {
  85. searchFn(val) {
  86. this.params.name = val
  87. this.listInit()
  88. },
  89. goScreen() {
  90. let url = `/pages/indexEntry/findShcool/screen/screen?businessScope=${this.params.businessScope}&district=${this.params.district}`
  91. this.$goPage(url)
  92. },
  93. goPage(item) {
  94. this.$goPage('/pages/indexEntry/findShcool/shcoolDetail/shcoolDetail?schoolId='+ item.id)
  95. },
  96. tabClick(item) {
  97. this.params.sercheType = item.id
  98. this.params.businessScope = ''
  99. this.params.district = ''
  100. this.listInit()
  101. },
  102. async listInit() {
  103. this.listData = []
  104. this.params.pageNo = 1
  105. await this.schoolPageFn()
  106. uni.stopPullDownRefresh()
  107. },
  108. // 获取驾校列表
  109. async schoolPageFn() {
  110. let obj = {}
  111. for(let key in this.params) {
  112. if(this.params[key]) {
  113. obj[key] = this.params[key]
  114. }
  115. }
  116. const {data: res} = await schoolPage(obj)
  117. this.params.pageNo ++
  118. this.listData.push(...res.list)
  119. this.total = res.total
  120. if(this.listData.length>=this.total) this.status = 'nomore'
  121. console.log(res)
  122. }
  123. }
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. .pageBg {
  128. width: 100%;
  129. .navBox {
  130. display: flex;
  131. // justify-content: space-between;
  132. padding: 20rpx 0;
  133. .tab {
  134. font-size: 28rpx;
  135. color: #999;
  136. line-height: 50rpx;
  137. border-radius: 10rpx;
  138. background: #fff;
  139. text-align: center;
  140. height: 50rpx;
  141. width: 126rpx;
  142. margin-right: 30rpx;
  143. &.active {
  144. background: $themC;
  145. color: #fff;
  146. }
  147. }
  148. .screen {
  149. width: 150rpx;
  150. display: flex;
  151. justify-content: center;
  152. align-items: center;
  153. position: relative;
  154. background: #fff;
  155. color: #999;
  156. border-radius: 10rpx;
  157. &.active {
  158. background: $themC;
  159. color: #fff;
  160. }
  161. .txt {
  162. font-size: 28rpx;
  163. margin-right: 10rpx;
  164. }
  165. .screenIcon {
  166. width: 18rpx;
  167. height: 12rpx;
  168. }
  169. }
  170. }
  171. .ul {
  172. width: 100%;
  173. .li {
  174. }
  175. }
  176. }
  177. .topBg {
  178. padding-bottom: 20rpx;
  179. }
  180. </style>