index.vue 5.9 KB

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