index.vue 6.1 KB

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