classList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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="index" 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.classStartHours}}&nbsp;&nbsp;{{site.residue}}课时
  19. </view>
  20. <view class="card-info-text">
  21. <u-icon name="map"></u-icon>
  22. {{site.address}}
  23. </view>
  24. </view>
  25. </u-card>
  26. <u-divider v-if="item.isOver" bg-color="transparent">没有更多了</u-divider>
  27. </scroll-view>
  28. </swiper-item>
  29. </swiper>
  30. <u-icon name="plus-circle-fill" :color="mainColor" size="96" class="fix-add-icon" @click="goToAddClassForm()"></u-icon>
  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. triggered: false,
  49. tabList: [{
  50. name: '全部',
  51. status: 3,
  52. isOver: false,
  53. pageIndex: 1,
  54. tableList: [{
  55. "address": "请假到等",
  56. "className": "",
  57. "name": "请假签到等",
  58. "residue": 8,
  59. "classStartDate": "2020-01-01",
  60. "classStartHours": "19:20"
  61. },
  62. {
  63. "address": "请假到等",
  64. "className": "",
  65. "name": "请假签到等",
  66. "residue": 8,
  67. "classStartDate": "2020-01-01",
  68. "classStartHours": "19:20"
  69. },
  70. ],
  71. }, {
  72. name: '已开班',
  73. status: 1,
  74. isOver: false,
  75. pageIndex: 1,
  76. tableList: [],
  77. }, {
  78. name: '未开班',
  79. status: 0,
  80. isOver: false,
  81. pageIndex: 1,
  82. tableList: [],
  83. }, {
  84. name: '审核中',
  85. status: 2,
  86. isOver: false,
  87. pageIndex: 1,
  88. tableList: [],
  89. }],
  90. current: 0,
  91. swiperCurrent: 0,
  92. }
  93. },
  94. onShow() {
  95. this.tabList.forEach((site, index) => {
  96. site.isOver = false
  97. site.pageIndex = 1
  98. // site.tableList = []
  99. this.getTableList(index)
  100. })
  101. },
  102. methods: {
  103. // tab页面切换
  104. tabsChange(index) {
  105. this.swiperCurrent = index;
  106. },
  107. // swiper-item左右移动,通知tabs的滑块跟随移动
  108. transition(e) {
  109. let dx = e.detail.dx;
  110. this.$refs.uTabs.setDx(dx);
  111. },
  112. // swiper滑动结束,分别设置tabs和swiper的状态
  113. animationfinish(e) {
  114. let current = e.detail.current;
  115. this.$refs.uTabs.setFinishCurrent(current);
  116. this.swiperCurrent = current;
  117. this.current = current;
  118. },
  119. // 下拉刷新
  120. onRefresh() {
  121. this.triggered = true
  122. this.tabList[this.current].isOver = false
  123. this.tabList[this.current].pageIndex = 1
  124. this.tabList[this.current].tableList = []
  125. this.getTableList(this.current, 'refresh')
  126. },
  127. // 重置下拉刷新状态
  128. onRestore() {
  129. this.triggered = 'restore'
  130. this.triggered = false
  131. },
  132. // 懒加载
  133. handleLoadMore() {
  134. if (!this.tabList[this.current].isOver) {
  135. this.tabList[this.current].pageIndex++
  136. this.getTableList(this.current)
  137. }
  138. },
  139. // 获取列表数据
  140. getTableList(index, refresh) {
  141. NET.request(API.getClassList, {
  142. status: this.tabList[index].status,
  143. page: this.tabList[index].pageIndex,
  144. size: 10,
  145. }, 'POST').then(res => {
  146. this.triggered = false
  147. this.tabList[index].tableList = this.tabList[index].tableList.concat(res.data.row)
  148. this.tabList[index].isOver = res.data.row.length != 10
  149. }).catch(error => {
  150. this.triggered = false
  151. this.$refs.uTips.show({
  152. title: error.data.msg,
  153. type: 'warning',
  154. })
  155. })
  156. },
  157. // 跳转新增班级表单
  158. goToAddClassForm() {
  159. uni.navigateTo({
  160. url: '/pagesClass/addClassForm'
  161. });
  162. },
  163. // 跳转班级详情
  164. goToClassDetail(site) {
  165. uni.navigateTo({
  166. url: '/pagesClass/classDetail?id=' + site.id
  167. });
  168. }
  169. },
  170. }
  171. </script>
  172. <style>
  173. page {
  174. width: 100%;
  175. height: 100%;
  176. background-color: #f7f7f7;
  177. }
  178. </style>
  179. <style lang="scss" scoped>
  180. @import "@/static/css/themes.scss";
  181. .content {
  182. width: 100%;
  183. float: left;
  184. position: relative;
  185. .swiper-box {
  186. height: calc(100vh - 34px);
  187. .swiper-item {
  188. height: calc(100vh - 34px);
  189. .scroll-box {
  190. width: 100%;
  191. height: calc(100vh - 34px);
  192. .card-box {
  193. .card-content {
  194. padding: 5px 15px;
  195. }
  196. .card-name {
  197. height: 20px;
  198. display: inline-block;
  199. font-weight: bold;
  200. font-size: 14px;
  201. line-height: 20px;
  202. }
  203. .card-info-text {
  204. color: #999999;
  205. margin-bottom: 5px;
  206. /deep/.u-icon {
  207. margin-right: 5px;
  208. font-size: 14px;
  209. color: #000000;
  210. }
  211. }
  212. }
  213. }
  214. }
  215. }
  216. .fix-add-icon {
  217. position: fixed;
  218. bottom: 15px;
  219. right: 15px;
  220. }
  221. }
  222. </style>