classList.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. triggered: false,
  50. isOver: false,
  51. pageIndex: 1,
  52. tableList: [],
  53. }
  54. },
  55. onLoad() {
  56. this.getTableList()
  57. },
  58. onReady() {},
  59. methods: {
  60. // 设置过滤字段
  61. setFilterText(value) {
  62. this.onRefresh()
  63. },
  64. // 下拉刷新
  65. onRefresh() {
  66. this.triggered = true
  67. this.isOver = false
  68. this.pageIndex = 1
  69. this.tableList = []
  70. this.getTableList()
  71. },
  72. // 重置下拉刷新状态
  73. onRestore() {
  74. this.triggered = 'restore'
  75. this.triggered = false
  76. },
  77. // 懒加载
  78. handleLoadMore() {
  79. if (!this.isOver) {
  80. this.pageIndex++
  81. this.getTableList()
  82. }
  83. },
  84. // 获取列表数据
  85. getTableList() {
  86. NET.request(API.getClassList, {
  87. name: this.filterText,
  88. page: this.pageIndex,
  89. size: 10,
  90. }, 'POST').then(res => {
  91. this.triggered = false
  92. this.tableList = this.tableList.concat(res.data.row)
  93. this.isOver = res.data.row.length != 10
  94. }).catch(error => {
  95. this.triggered = false
  96. this.$refs.uTips.show({
  97. title: error.message,
  98. type: 'warning',
  99. })
  100. })
  101. },
  102. // 跳转场馆详情
  103. selectClass(item) {
  104. uni.setStorage({
  105. key: 'defaultClass',
  106. data: {
  107. classId: item.id,
  108. className: item.name,
  109. }
  110. });
  111. uni.navigateBack()
  112. },
  113. },
  114. }
  115. </script>
  116. <style>
  117. page {
  118. width: 100%;
  119. height: 100%;
  120. background-color: #f7f7f7;
  121. }
  122. </style>
  123. <style lang="scss" scoped>
  124. @import "@/static/css/themes.scss";
  125. .content {
  126. width: 100%;
  127. float: left;
  128. .filter-box {
  129. height: 48px;
  130. padding: 10px 15px;
  131. background-color: #FFFFFF;
  132. }
  133. .scroll-box {
  134. width: 100%;
  135. height: calc(100vh - 48px);
  136. box-sizing: border-box;
  137. padding-bottom: 10px;
  138. .card-box {
  139. .card-content {
  140. padding: 5px 15px;
  141. }
  142. .card-name {
  143. height: 20px;
  144. display: inline-block;
  145. font-weight: bold;
  146. font-size: 14px;
  147. line-height: 20px;
  148. }
  149. .card-info-text {
  150. color: #999999;
  151. margin-bottom: 5px;
  152. /deep/.u-icon {
  153. margin-right: 5px;
  154. font-size: 14px;
  155. color: #000000;
  156. }
  157. }
  158. }
  159. }
  160. }
  161. </style>