signList.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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}}</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: '5次未签到',
  45. isOver: false,
  46. pageIndex: 1,
  47. tableList: [],
  48. }, {
  49. name: '10次以上未签到',
  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. if (!this.triggered) {
  79. this.triggered = true
  80. this.tabList[this.current].isOver = false
  81. this.tabList[this.current].pageIndex = 1
  82. this.tabList[this.current].tableList = []
  83. this.getTableList(this.current, 'refresh')
  84. }
  85. },
  86. // 重置下拉刷新状态
  87. onRestore() {
  88. this.triggered = 'restore'
  89. this.triggered = false
  90. },
  91. // 懒加载
  92. handleLoadMore() {
  93. if (!this.tabList[this.current].isOver) {
  94. this.tabList[this.current].pageIndex++
  95. this.getTableList(this.current)
  96. }
  97. },
  98. // 获取列表数据
  99. getTableList(index, refresh) {
  100. NET.request(API.getSignList, {
  101. type: index,
  102. page: this.tabList[index].pageIndex,
  103. size: this.pageSize,
  104. }, 'POST').then(res => {
  105. this.triggered = false
  106. this.tabList[index].tableList = this.tabList[index].tableList.concat(res.data.row)
  107. this.tabList[index].isOver = res.data.row.length != this.pageSize
  108. }).catch(error => {
  109. this.triggered = false
  110. this.$refs.uTips.show({
  111. title: error.message,
  112. type: 'warning',
  113. })
  114. })
  115. },
  116. // 跳转学生详情
  117. goToStudent(site) {
  118. uni.navigateTo({
  119. url: '/pagesMain/studentInfo?type=3&id=' + site.id
  120. });
  121. }
  122. },
  123. }
  124. </script>
  125. <style>
  126. page {
  127. width: 100%;
  128. height: 100%;
  129. background-color: #f7f7f7;
  130. }
  131. </style>
  132. <style lang="scss" scoped>
  133. @import "@/static/css/themes.scss";
  134. .content {
  135. width: 100%;
  136. float: left;
  137. .swiper-box {
  138. height: calc(100vh - 34px);
  139. .swiper-item {
  140. height: calc(100vh - 34px);
  141. .scroll-box {
  142. width: 100%;
  143. height: calc(100vh - 34px);
  144. box-sizing: border-box;
  145. padding-bottom: 10px;
  146. .class-card {
  147. border-bottom: 1px solid #cccccc;
  148. .class-content {
  149. padding: 5px 15px;
  150. display: flex;
  151. align-items: center;
  152. .class-info-img {
  153. width: 50px;
  154. height: 50px;
  155. margin-right: 5px;
  156. display: flex;
  157. align-items: center;
  158. justify-content: center;
  159. }
  160. .class-info-text {
  161. line-height: 20px;
  162. font-size: 14px;
  163. flex: 1;
  164. }
  165. }
  166. }
  167. .class-card:last-child {
  168. border-bottom: none;
  169. }
  170. }
  171. }
  172. }
  173. }
  174. </style>