renewList.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="content">
  3. <u-subsection mode="subsection" :active-color="mainColor" :list="tabList" :current="current" @change="tabsChange"></u-subsection>
  4. <swiper :current="swiperCurrent" @animationfinish="animationfinish" class="swiper-box">
  5. <swiper-item class="swiper-item" v-for="(item, index1) in tabList" :key="index1">
  6. <scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" :refresher-enabled="true"
  7. :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white" @refresherrefresh="onRefresh"
  8. @refresherrestore="onRestore">
  9. <u-card :head-border-bottom="false" :foot-border-top="false" padding="0px" margin="0" borderRadius="0" v-for="(site, index2) in item.tableList"
  10. :key="index2" class="class-card" @click="goToStudent(site)">
  11. <view class="class-content" slot="body">
  12. <view class="class-info-img">
  13. <u-avatar :src="site.url" size="100"></u-avatar>
  14. </view>
  15. <view class="class-info-text">{{site.name}}&nbsp;&nbsp;{{index1 == 1 ? site.residue + '课时' :''}}</view>
  16. <u-icon name="arrow-right" color="#aaaaaa" size="36"></u-icon>
  17. </view>
  18. </u-card>
  19. <u-divider v-if="item.isOver" bg-color="transparent">没有更多了</u-divider>
  20. </scroll-view>
  21. </swiper-item>
  22. </swiper>
  23. <u-top-tips ref="uTips"></u-top-tips>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. mapGetters
  29. } from 'vuex'
  30. const NET = require('@/utils/request')
  31. const API = require('@/config/api')
  32. export default {
  33. computed: {
  34. ...mapGetters([
  35. 'mainColor',
  36. 'handleCustomStyle',
  37. 'handleDefaultCustomStyle',
  38. ])
  39. },
  40. data() {
  41. return {
  42. triggered: false,
  43. tabList: [{
  44. name: '到期提醒',
  45. isOver: false,
  46. pageIndex: 1,
  47. tableList: [],
  48. }, {
  49. name: '到期余课',
  50. isOver: false,
  51. pageIndex: 1,
  52. tableList: [],
  53. }],
  54. // 请求数据size
  55. pageSize: 12,
  56. current: 0,
  57. swiperCurrent: 0,
  58. }
  59. },
  60. onLoad() {
  61. this.getTableList(0)
  62. this.getTableList(1)
  63. },
  64. onReady() {},
  65. methods: {
  66. // tab页面切换
  67. tabsChange(index) {
  68. this.swiperCurrent = index;
  69. },
  70. // swiper滑动结束,分别设置tabs和swiper的状态
  71. animationfinish(e) {
  72. let current = e.detail.current;
  73. this.swiperCurrent = current;
  74. this.current = current;
  75. },
  76. // 下拉刷新
  77. onRefresh() {
  78. console.log('下拉刷新');
  79. if (!this.triggered) {
  80. this.triggered = true
  81. this.tabList[this.current].isOver = false
  82. this.tabList[this.current].pageIndex = 1
  83. this.tabList[this.current].tableList = []
  84. this.getTableList(this.current, 'refresh')
  85. }
  86. },
  87. // 重置下拉刷新状态
  88. onRestore() {
  89. console.log('重置下拉刷新状态');
  90. this.triggered = 'restore'
  91. this.triggered = false
  92. },
  93. // 懒加载
  94. handleLoadMore() {
  95. console.log('懒加载');
  96. if (!this.tabList[this.current].isOver) {
  97. this.tabList[this.current].pageIndex++
  98. this.getTableList(this.current)
  99. }
  100. },
  101. // 获取列表数据
  102. getTableList(index, refresh) {
  103. NET.request(API.getRenewList, {
  104. type: index,
  105. page: this.tabList[index].pageIndex,
  106. size: this.pageSize,
  107. }, 'POST').then(res => {
  108. this.triggered = false
  109. this.tabList[index].tableList = this.tabList[index].tableList.concat(res.data.row)
  110. this.tabList[index].isOver = res.data.row.length != this.pageSize
  111. }).catch(error => {
  112. this.triggered = false
  113. this.$refs.uTips.show({
  114. title: error.message,
  115. type: 'warning',
  116. })
  117. })
  118. },
  119. // 跳转学生详情
  120. goToStudent(site) {
  121. uni.navigateTo({
  122. url: '/pagesMain/studentInfo?type=2&id=' + site.id
  123. });
  124. }
  125. },
  126. }
  127. </script>
  128. <style>
  129. page {
  130. width: 100%;
  131. height: 100%;
  132. background-color: #f7f7f7;
  133. }
  134. </style>
  135. <style lang="scss" scoped>
  136. @import "@/static/css/themes.scss";
  137. .content {
  138. width: 100%;
  139. float: left;
  140. .swiper-box {
  141. height: calc(100vh - 34px);
  142. .swiper-item {
  143. height: calc(100vh - 34px);
  144. .scroll-box {
  145. width: 100%;
  146. height: calc(100vh - 34px);
  147. box-sizing: border-box;
  148. padding-bottom: 10px;
  149. .class-card {
  150. border-bottom: 1px solid #cccccc;
  151. .class-content {
  152. padding: 5px 15px;
  153. display: flex;
  154. align-items: center;
  155. .class-info-img {
  156. width: 50px;
  157. height: 50px;
  158. margin-right: 5px;
  159. display: flex;
  160. align-items: center;
  161. justify-content: center;
  162. }
  163. .class-info-text {
  164. line-height: 20px;
  165. font-size: 14px;
  166. flex: 1;
  167. }
  168. }
  169. }
  170. .class-card:last-child {
  171. border-bottom: none;
  172. }
  173. }
  174. }
  175. }
  176. }
  177. </style>