ratioRank.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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. <view class="filter-date-box">
  10. <u-icon name="arrow-left" color="#999999" size="48" @click="previousMonth()"></u-icon>
  11. <text class="filter-date">{{item.year}}年{{item.month}}月</text>
  12. <u-icon name="arrow-right" color="#999999" size="48" @click="nextMonth()"></u-icon>
  13. </view>
  14. <view class="rank-box">
  15. <u-line-progress :active-color="mainColor" :percent="item.percent" height="40"></u-line-progress>
  16. <text class="rank-text" v-if="index1 == 1">签到人次:{{item.signCount}}</text>
  17. </view>
  18. <u-card :head-border-bottom="false" :foot-border-top="false" padding="0px" margin="0" borderRadius="0" v-for="(site, index2) in item.tableList"
  19. :key="index2" class="class-card" @click="goToStudent(site)">
  20. <view class="class-content" slot="body">
  21. <view class="class-info-sort">{{index2}}</view>
  22. <view class="class-info-text">{{site.name}}&nbsp;&nbsp;{{index1 == 1 ? site.residue + '课时' :''}}</view>
  23. <view class="class-info-img">
  24. <u-avatar :src="site.url" size="100"></u-avatar>
  25. </view>
  26. </view>
  27. </u-card>
  28. <u-divider v-if="item.isOver" bg-color="transparent">没有更多了</u-divider>
  29. </scroll-view>
  30. </swiper-item>
  31. </swiper>
  32. <u-top-tips ref="uTips"></u-top-tips>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. mapGetters
  38. } from 'vuex'
  39. const NET = require('@/utils/request')
  40. const API = require('@/config/api')
  41. export default {
  42. computed: {
  43. ...mapGetters([
  44. 'mainColor',
  45. 'handleCustomStyle',
  46. 'handleDefaultCustomStyle',
  47. ])
  48. },
  49. data() {
  50. return {
  51. triggered: false,
  52. tabList: [{
  53. name: '续费率',
  54. isOver: false,
  55. pageIndex: 1,
  56. year: '',
  57. month: '',
  58. percent: 20,
  59. signCount: '',
  60. tableList: [
  61. {
  62. "name": "续费率",
  63. "url": ""
  64. },
  65. {
  66. "name": "续费率",
  67. "url": ""
  68. },
  69. {
  70. "name": "续费率",
  71. "url": ""
  72. },
  73. {
  74. "name": "续费率",
  75. "url": ""
  76. },
  77. {
  78. "name": "续费率",
  79. "url": ""
  80. },
  81. {
  82. "name": "续费率",
  83. "url": ""
  84. },
  85. {
  86. "name": "续费率",
  87. "url": ""
  88. },
  89. {
  90. "name": "续费率",
  91. "url": ""
  92. },
  93. ],
  94. }, {
  95. name: '签到率',
  96. isOver: false,
  97. pageIndex: 1,
  98. year: '',
  99. month: '',
  100. percent: '',
  101. signCount: '',
  102. tableList: [],
  103. }],
  104. current: 0,
  105. swiperCurrent: 0,
  106. }
  107. },
  108. onLoad() {
  109. this.tabList.forEach(site => {
  110. site.year = new Date().getFullYear()
  111. site.month = new Date().getMonth() + 1
  112. })
  113. this.getTableList(0)
  114. this.getTableList(1)
  115. this.getRank(0)
  116. this.getRank(1)
  117. },
  118. onReady() {},
  119. methods: {
  120. // tab页面切换
  121. tabsChange(index) {
  122. this.swiperCurrent = index;
  123. },
  124. // swiper滑动结束,分别设置tabs和swiper的状态
  125. animationfinish(e) {
  126. let current = e.detail.current;
  127. this.swiperCurrent = current;
  128. this.current = current;
  129. },
  130. // 上一个月
  131. previousMonth() {
  132. if (this.tabList[this.current].month == 1) {
  133. this.tabList[this.current].year--
  134. this.tabList[this.current].month = 12
  135. } else {
  136. this.tabList[this.current].month--
  137. }
  138. this.onRefresh(1)
  139. },
  140. // 下一个月
  141. nextMonth() {
  142. if (this.tabList[this.current].month == 12) {
  143. this.tabList[this.current].year++
  144. this.tabList[this.current].month = 1
  145. } else {
  146. this.tabList[this.current].month++
  147. }
  148. this.onRefresh(1)
  149. },
  150. // 下拉刷新
  151. onRefresh(type) {
  152. if (type != 1) {
  153. this.triggered = true
  154. }
  155. this.tabList[this.current].isOver = false
  156. this.tabList[this.current].pageIndex = 1
  157. this.tabList[this.current].tableList = []
  158. this.getTableList(this.current)
  159. this.getRank(this.current)
  160. },
  161. // 重置下拉刷新状态
  162. onRestore() {
  163. this.triggered = 'restore'
  164. this.triggered = false
  165. },
  166. // 懒加载
  167. handleLoadMore() {
  168. if (!this.tabList[this.current].isOver) {
  169. this.tabList[this.current].pageIndex++
  170. this.getTableList(this.current)
  171. }
  172. },
  173. // 获取列表数据
  174. getTableList(index) {
  175. NET.request(index == 0 ? API.getRenewRankingList : API.getSignRankingList, {
  176. date: this.tabList[index].year + '-' + this.tabList[index].month,
  177. page: this.tabList[index].pageIndex,
  178. size: 20,
  179. }, 'POST').then(res => {
  180. this.triggered = false
  181. this.tabList[index].tableList = this.tabList[index].tableList.concat(res.data.list)
  182. this.tabList[index].isOver = res.data.list.length != 20
  183. }).catch(error => {
  184. this.triggered = false
  185. this.$refs.uTips.show({
  186. title: error.data.msg,
  187. type: 'warning',
  188. })
  189. })
  190. },
  191. // 获取比率
  192. getRank(index) {
  193. NET.request(index == 0 ? API.getRenewPercent : API.getSignPercent, {
  194. date: this.tabList[index].year + '-' + this.tabList[index].month,
  195. }, 'POST').then(res => {
  196. this.tabList[index].percent = res.data.percent
  197. this.tabList[index].signCount = res.data.signCount
  198. }).catch(error => {
  199. this.$refs.uTips.show({
  200. title: error.data.msg,
  201. type: 'warning',
  202. })
  203. })
  204. }
  205. },
  206. }
  207. </script>
  208. <style>
  209. page {
  210. width: 100%;
  211. height: 100%;
  212. background-color: #f7f7f7;
  213. }
  214. </style>
  215. <style lang="scss" scoped>
  216. @import "@/static/css/themes.scss";
  217. .content {
  218. width: 100%;
  219. float: left;
  220. .swiper-box {
  221. height: calc(100vh - 34px);
  222. .swiper-item {
  223. height: calc(100vh - 34px);
  224. .scroll-box {
  225. width: 100%;
  226. height: calc(100vh - 34px);
  227. .filter-date-box {
  228. height: 48px;
  229. display: flex;
  230. justify-content: space-between;
  231. align-items: center;
  232. padding: 10px 15px;
  233. .filter-date {
  234. text-align: center;
  235. font-size: 16px;
  236. font-weight: bold;
  237. line-height: 28px;
  238. flex: 1;
  239. }
  240. }
  241. .rank-box {
  242. height: 30px;
  243. display: flex;
  244. justify-content: space-between;
  245. align-items: center;
  246. padding: 0 15px;
  247. u-line-progress {
  248. flex: 1;
  249. }
  250. .rank-text{
  251. padding-left: 10px;
  252. font-size: 11px;
  253. color: $mainColor;
  254. }
  255. }
  256. .class-card {
  257. border-bottom: 1px solid #cccccc;
  258. .class-content {
  259. padding: 5px 15px;
  260. display: flex;
  261. align-items: center;
  262. .class-info-sort {
  263. width: 50px;
  264. }
  265. .class-info-img {
  266. width: 50px;
  267. height: 50px;
  268. margin-right: 5px;
  269. display: flex;
  270. align-items: center;
  271. justify-content: center;
  272. }
  273. .class-info-text {
  274. line-height: 20px;
  275. font-size: 14px;
  276. flex: 1;
  277. }
  278. }
  279. }
  280. .class-card:last-child {
  281. border-bottom: none;
  282. }
  283. }
  284. }
  285. }
  286. }
  287. </style>