index.vue 6.0 KB

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