classList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view class="content">
  3. <u-tabs-swiper ref="uTabs" :active-color="mainColor" :list="tabList" :current="current" @change="tabsChange"
  4. :is-scroll="false"></u-tabs-swiper>
  5. <swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" class="swiper-box">
  6. <swiper-item class="swiper-item" v-for="(item, index1) in tabList" :key="index1">
  7. <scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" :refresher-enabled="true"
  8. :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white" @refresherrefresh="onRefresh"
  9. @refresherrestore="onRestore">
  10. <u-card :head-border-bottom="false" :foot-border-top="false" padding="0px" margin="10px" borderRadius="40" v-for="(site, index2) in item.tableList"
  11. :key="index2" class="card-box" @click="goToClassDetail(site)">
  12. <view class="card-content" slot="head" style="padding-top: 10px;">
  13. <view class="card-name">{{site.name}}</view>
  14. </view>
  15. <view class="card-content" slot="body">
  16. <view class="card-info-text">
  17. <u-icon name="clock"></u-icon>
  18. {{site.classStartDate}}&nbsp;~&nbsp;{{site.classEndDate}}
  19. </view>
  20. <view class="card-info-text" v-for="(time, index3) in site.classExtrasList" :key="index3">
  21. <u-icon name="calendar" style="visibility: hidden;"></u-icon>
  22. <text>{{time.week}}&nbsp;{{time.startTime}}-{{time.endTime}}</text>
  23. </view>
  24. <view class="card-info-text">
  25. <u-icon name="map"></u-icon>
  26. {{site.address}}
  27. </view>
  28. </view>
  29. </u-card>
  30. <u-divider v-if="item.isOver" bg-color="transparent">没有更多了</u-divider>
  31. </scroll-view>
  32. </swiper-item>
  33. </swiper>
  34. <u-icon name="plus-circle-fill" :color="mainColor" size="96" class="fix-add-icon" @click="goToAddClassForm()"></u-icon>
  35. <u-top-tips ref="uTips"></u-top-tips>
  36. </view>
  37. </template>
  38. <script>
  39. import {
  40. mapGetters
  41. } from 'vuex'
  42. const NET = require('@/utils/request')
  43. const API = require('@/config/api')
  44. export default {
  45. computed: {
  46. ...mapGetters([
  47. 'mainColor',
  48. ])
  49. },
  50. data() {
  51. return {
  52. triggered: false,
  53. tabList: [{
  54. name: '全部',
  55. status: 3,
  56. isOver: false,
  57. pageIndex: 1,
  58. tableList: [],
  59. }, {
  60. name: '已开班',
  61. status: 1,
  62. isOver: false,
  63. pageIndex: 1,
  64. tableList: [],
  65. }, {
  66. name: '未开班',
  67. status: 0,
  68. isOver: false,
  69. pageIndex: 1,
  70. tableList: [],
  71. }, {
  72. name: '审核中',
  73. status: 2,
  74. isOver: false,
  75. pageIndex: 1,
  76. tableList: [],
  77. }],
  78. current: 0,
  79. swiperCurrent: 0,
  80. }
  81. },
  82. onShow() {
  83. this.tabList.forEach((site, index) => {
  84. site.isOver = false
  85. site.pageIndex = 1
  86. site.tableList = []
  87. this.getTableList(index)
  88. })
  89. },
  90. methods: {
  91. // tab页面切换
  92. tabsChange(index) {
  93. this.swiperCurrent = index;
  94. },
  95. // swiper-item左右移动,通知tabs的滑块跟随移动
  96. transition(e) {
  97. let dx = e.detail.dx;
  98. this.$refs.uTabs.setDx(dx);
  99. },
  100. // swiper滑动结束,分别设置tabs和swiper的状态
  101. animationfinish(e) {
  102. let current = e.detail.current;
  103. this.$refs.uTabs.setFinishCurrent(current);
  104. this.swiperCurrent = current;
  105. this.current = current;
  106. },
  107. // 下拉刷新
  108. onRefresh() {
  109. if (!this.triggered) {
  110. this.triggered = true
  111. this.tabList[this.current].isOver = false
  112. this.tabList[this.current].pageIndex = 1
  113. this.tabList[this.current].tableList = []
  114. this.getTableList(this.current, 'refresh')
  115. }
  116. },
  117. // 重置下拉刷新状态
  118. onRestore() {
  119. this.triggered = 'restore'
  120. this.triggered = false
  121. },
  122. // 懒加载
  123. handleLoadMore() {
  124. if (!this.tabList[this.current].isOver) {
  125. this.tabList[this.current].pageIndex++
  126. this.getTableList(this.current)
  127. }
  128. },
  129. // 获取列表数据
  130. getTableList(index, refresh) {
  131. NET.request(API.getClassList, {
  132. status: this.tabList[index].status,
  133. page: this.tabList[index].pageIndex,
  134. size: 10,
  135. }, 'POST').then(res => {
  136. this.triggered = false
  137. this.tabList[index].tableList = this.tabList[index].tableList.concat(res.data.row)
  138. this.tabList[index].isOver = res.data.row.length != 10
  139. }).catch(error => {
  140. this.triggered = false
  141. this.$refs.uTips.show({
  142. title: error.message,
  143. type: 'warning',
  144. })
  145. })
  146. },
  147. // 跳转新增班级表单
  148. goToAddClassForm() {
  149. uni.navigateTo({
  150. url: '/pagesClass/addClassForm'
  151. });
  152. },
  153. // 跳转班级详情
  154. goToClassDetail(site) {
  155. uni.navigateTo({
  156. url: '/pagesClass/classDetail?id=' + site.id
  157. });
  158. }
  159. },
  160. }
  161. </script>
  162. <style>
  163. page {
  164. width: 100%;
  165. height: 100%;
  166. background-color: #f7f7f7;
  167. }
  168. </style>
  169. <style lang="scss" scoped>
  170. @import "@/static/css/themes.scss";
  171. .content {
  172. width: 100%;
  173. float: left;
  174. position: relative;
  175. .swiper-box {
  176. height: calc(100vh - 34px);
  177. .swiper-item {
  178. height: calc(100vh - 34px);
  179. .scroll-box {
  180. width: 100%;
  181. height: calc(100vh - 34px);
  182. .card-box {
  183. .card-content {
  184. padding: 5px 15px;
  185. }
  186. .card-name {
  187. height: 20px;
  188. display: inline-block;
  189. font-weight: bold;
  190. font-size: 14px;
  191. line-height: 20px;
  192. }
  193. .card-info-text {
  194. color: #999999;
  195. margin-bottom: 5px;
  196. /deep/.u-icon {
  197. margin-right: 5px;
  198. font-size: 14px;
  199. color: #000000;
  200. }
  201. }
  202. }
  203. }
  204. }
  205. }
  206. .fix-add-icon {
  207. position: fixed;
  208. bottom: 15px;
  209. right: 15px;
  210. }
  211. }
  212. </style>