ratioRank.vue 7.4 KB

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