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

208 lines
4.4 KiB

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