renewList.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. current: 0,
  55. swiperCurrent: 0,
  56. }
  57. },
  58. onLoad() {
  59. this.getTableList(0)
  60. this.getTableList(1)
  61. },
  62. onReady() {},
  63. methods: {
  64. // tab页面切换
  65. tabsChange(index) {
  66. this.swiperCurrent = index;
  67. },
  68. // swiper滑动结束,分别设置tabs和swiper的状态
  69. animationfinish(e) {
  70. let current = e.detail.current;
  71. this.swiperCurrent = current;
  72. this.current = current;
  73. },
  74. // 下拉刷新
  75. onRefresh() {
  76. this.triggered = true
  77. this.tabList[this.current].isOver = false
  78. this.tabList[this.current].pageIndex = 1
  79. this.tabList[this.current].tableList = []
  80. this.getTableList(this.current, 'refresh')
  81. },
  82. // 重置下拉刷新状态
  83. onRestore() {
  84. this.triggered = 'restore'
  85. this.triggered = false
  86. },
  87. // 懒加载
  88. handleLoadMore() {
  89. if (!this.tabList[this.current].isOver) {
  90. this.tabList[this.current].pageIndex++
  91. this.getTableList(this.current)
  92. }
  93. },
  94. // 获取列表数据
  95. getTableList(index, refresh) {
  96. NET.request(API.getRenewList, {
  97. type: index,
  98. page: this.tabList[index].pageIndex,
  99. size: 10,
  100. }, 'POST').then(res => {
  101. this.triggered = false
  102. this.tabList[index].tableList = this.tabList[index].tableList.concat(res.data.row)
  103. this.tabList[index].isOver = res.data.row.length != 10
  104. }).catch(error => {
  105. this.triggered = false
  106. this.$refs.uTips.show({
  107. title: error.message,
  108. type: 'warning',
  109. })
  110. })
  111. },
  112. // 跳转学生详情
  113. goToStudent(site) {
  114. uni.navigateTo({
  115. url: '/pagesMain/studentInfo?type=2&id=' + site.id
  116. });
  117. }
  118. },
  119. }
  120. </script>
  121. <style>
  122. page {
  123. width: 100%;
  124. height: 100%;
  125. background-color: #f7f7f7;
  126. }
  127. </style>
  128. <style lang="scss" scoped>
  129. @import "@/static/css/themes.scss";
  130. .content {
  131. width: 100%;
  132. float: left;
  133. .swiper-box {
  134. height: calc(100vh - 34px);
  135. .swiper-item {
  136. height: calc(100vh - 34px);
  137. .scroll-box {
  138. width: 100%;
  139. height: calc(100vh - 34px);
  140. box-sizing: border-box;
  141. padding-bottom: 10px;
  142. .class-card {
  143. border-bottom: 1px solid #cccccc;
  144. .class-content {
  145. padding: 5px 15px;
  146. display: flex;
  147. align-items: center;
  148. .class-info-img {
  149. width: 50px;
  150. height: 50px;
  151. margin-right: 5px;
  152. display: flex;
  153. align-items: center;
  154. justify-content: center;
  155. }
  156. .class-info-text {
  157. line-height: 20px;
  158. font-size: 14px;
  159. flex: 1;
  160. }
  161. }
  162. }
  163. .class-card:last-child {
  164. border-bottom: none;
  165. }
  166. }
  167. }
  168. }
  169. }
  170. </style>