classList.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view class="content">
  3. <view class="filter-box">
  4. <u-search placeholder="请输入关键字" v-model="filterText" @search="setFilterText" @custom="setFilterText"></u-search>
  5. </view>
  6. <scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" :refresher-enabled="true"
  7. :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white" @refresherrefresh="onRefresh"
  8. @refresherrestore="onRestore">
  9. <u-card :head-border-bottom="false" :foot-border-top="false" padding="0px" margin="10px" borderRadius="40" v-for="(item, index) in tableList"
  10. :key="index" class="card-box" @click="selectClass(item)">
  11. <view class="card-content" slot="head" style="padding-top: 10px;">
  12. <view class="card-name">{{item.name}}</view>
  13. </view>
  14. <view class="card-content" slot="body">
  15. <view class="card-info-text">
  16. <u-icon name="clock"></u-icon>
  17. {{item.classStartDate}}&nbsp;~&nbsp;{{item.classEndDate}}
  18. </view>
  19. <view class="card-info-text" v-for="(site, index2) in item.classExtrasList" :key="index2">
  20. <u-icon name="calendar" style="visibility: hidden;"></u-icon>
  21. <text>{{site.week}}&nbsp;{{site.startTime}}-{{site.endTime}}</text>
  22. </view>
  23. <view class="card-info-text">
  24. <u-icon name="map"></u-icon>
  25. {{item.address}}
  26. </view>
  27. </view>
  28. </u-card>
  29. <u-divider v-if="isOver" bg-color="transparent">没有更多了</u-divider>
  30. </scroll-view>
  31. <u-top-tips ref="uTips"></u-top-tips>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. mapGetters
  37. } from 'vuex'
  38. const NET = require('@/utils/request')
  39. const API = require('@/config/api')
  40. export default {
  41. computed: {
  42. ...mapGetters([
  43. 'mainColor'
  44. ])
  45. },
  46. data() {
  47. return {
  48. filterText: '',
  49. venueId: '',
  50. triggered: false,
  51. isOver: false,
  52. pageIndex: 1,
  53. tableList: [],
  54. }
  55. },
  56. onLoad(options) {
  57. this.venueId = options.venueId
  58. this.getTableList()
  59. },
  60. onReady() {},
  61. methods: {
  62. // 设置过滤字段
  63. setFilterText(value) {
  64. this.onRefresh()
  65. },
  66. // 下拉刷新
  67. onRefresh() {
  68. this.triggered = true
  69. this.isOver = false
  70. this.pageIndex = 1
  71. this.tableList = []
  72. this.getTableList()
  73. },
  74. // 重置下拉刷新状态
  75. onRestore() {
  76. this.triggered = 'restore'
  77. this.triggered = false
  78. },
  79. // 懒加载
  80. handleLoadMore() {
  81. if (!this.isOver) {
  82. this.pageIndex++
  83. this.getTableList()
  84. }
  85. },
  86. // 获取列表数据
  87. getTableList() {
  88. NET.request(API.getClassList, {
  89. name: this.filterText,
  90. venueId: this.venueId,
  91. page: this.pageIndex,
  92. size: 10,
  93. }, 'POST').then(res => {
  94. this.triggered = false
  95. this.tableList = this.tableList.concat(res.data.row)
  96. this.isOver = res.data.row.length != 10
  97. }).catch(error => {
  98. this.triggered = false
  99. this.$refs.uTips.show({
  100. title: error.message,
  101. type: 'warning',
  102. })
  103. })
  104. },
  105. // 跳转场馆详情
  106. selectClass(item) {
  107. uni.setStorage({
  108. key: 'defaultClass',
  109. data: {
  110. classId: item.id,
  111. className: item.name,
  112. }
  113. });
  114. uni.navigateBack()
  115. },
  116. },
  117. }
  118. </script>
  119. <style>
  120. page {
  121. width: 100%;
  122. height: 100%;
  123. background-color: #f7f7f7;
  124. }
  125. </style>
  126. <style lang="scss" scoped>
  127. @import "@/static/css/themes.scss";
  128. .content {
  129. width: 100%;
  130. float: left;
  131. .filter-box {
  132. height: 48px;
  133. padding: 10px 15px;
  134. background-color: #FFFFFF;
  135. }
  136. .scroll-box {
  137. width: 100%;
  138. height: calc(100vh - 48px);
  139. box-sizing: border-box;
  140. padding-bottom: 10px;
  141. .card-box {
  142. .card-content {
  143. padding: 5px 15px;
  144. }
  145. .card-name {
  146. height: 20px;
  147. display: inline-block;
  148. font-weight: bold;
  149. font-size: 14px;
  150. line-height: 20px;
  151. }
  152. .card-info-text {
  153. color: #999999;
  154. margin-bottom: 5px;
  155. /deep/.u-icon {
  156. margin-right: 5px;
  157. font-size: 14px;
  158. color: #000000;
  159. }
  160. }
  161. }
  162. }
  163. }
  164. </style>