index.vue 6.1 KB

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