renewList.vue 4.5 KB

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