ratioRank.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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 (type != 1) {
  127. this.triggered = true
  128. }
  129. this.tabList[this.current].isOver = false
  130. this.tabList[this.current].pageIndex = 1
  131. this.tabList[this.current].tableList = []
  132. this.getTableList(this.current)
  133. this.getRank(this.current)
  134. },
  135. // 重置下拉刷新状态
  136. onRestore() {
  137. this.triggered = 'restore'
  138. this.triggered = false
  139. },
  140. // 懒加载
  141. handleLoadMore() {
  142. if (!this.tabList[this.current].isOver) {
  143. this.tabList[this.current].pageIndex++
  144. this.getTableList(this.current)
  145. }
  146. },
  147. // 获取列表数据
  148. getTableList(index) {
  149. NET.request(index == 0 ? API.getRenewRankingList : API.getSignRankingList, {
  150. date: this.tabList[index].year + '-' + this.tabList[index].month,
  151. page: this.tabList[index].pageIndex,
  152. size: 20,
  153. }, 'POST').then(res => {
  154. this.triggered = false
  155. this.tabList[index].tableList = this.tabList[index].tableList.concat(res.data.row)
  156. this.tabList[index].isOver = res.data.row.length != 20
  157. }).catch(error => {
  158. this.triggered = false
  159. this.$refs.uTips.show({
  160. title: error.message,
  161. type: 'warning',
  162. })
  163. })
  164. },
  165. // 获取比率
  166. getRank(index) {
  167. NET.request(index == 0 ? API.getRenewPercent : API.getSignPercent, {
  168. date: this.tabList[index].year + '-' + this.tabList[index].month,
  169. }, 'POST').then(res => {
  170. this.tabList[index].percent = parseFloat(res.data.percent)
  171. this.tabList[index].signCount = JSON.stringify(res.data.signCount)
  172. }).catch(error => {
  173. this.$refs.uTips.show({
  174. title: error.message,
  175. type: 'warning',
  176. })
  177. })
  178. }
  179. },
  180. }
  181. </script>
  182. <style>
  183. page {
  184. width: 100%;
  185. height: 100%;
  186. background-color: #f7f7f7;
  187. }
  188. </style>
  189. <style lang="scss" scoped>
  190. @import "@/static/css/themes.scss";
  191. .content {
  192. width: 100%;
  193. float: left;
  194. .swiper-box {
  195. height: calc(100vh - 34px);
  196. .swiper-item {
  197. height: calc(100vh - 34px);
  198. .scroll-box {
  199. width: 100%;
  200. height: calc(100vh - 34px);
  201. .filter-date-box {
  202. height: 48px;
  203. display: flex;
  204. justify-content: space-between;
  205. align-items: center;
  206. padding: 10px 15px;
  207. background-color: #FFFFFF;
  208. .filter-date {
  209. text-align: center;
  210. font-size: 16px;
  211. font-weight: bold;
  212. line-height: 28px;
  213. flex: 1;
  214. }
  215. }
  216. .rank-box {
  217. height: 30px;
  218. display: flex;
  219. justify-content: space-between;
  220. align-items: center;
  221. padding: 0 15px;
  222. background-color: #FFFFFF;
  223. u-line-progress {
  224. flex: 1;
  225. }
  226. .rank-text {
  227. padding-left: 10px;
  228. font-size: 11px;
  229. color: $mainColor;
  230. }
  231. }
  232. .class-card {
  233. border-bottom: 1px solid #cccccc;
  234. .class-content {
  235. padding: 5px 15px;
  236. display: flex;
  237. align-items: center;
  238. .info-sort {
  239. width: 34px;
  240. display: flex;
  241. align-items: center;
  242. justify-content: center;
  243. margin-right: 5px;
  244. }
  245. .class-info-img {
  246. width: 50px;
  247. height: 50px;
  248. margin-right: 5px;
  249. display: flex;
  250. align-items: center;
  251. justify-content: center;
  252. }
  253. .class-info-text {
  254. line-height: 20px;
  255. font-size: 14px;
  256. flex: 1;
  257. }
  258. }
  259. }
  260. .class-card:last-child {
  261. border-bottom: none;
  262. }
  263. }
  264. }
  265. }
  266. u-divider {
  267. padding: 10px 0;
  268. display: flex;
  269. }
  270. }
  271. </style>