ranking.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <view class="">
  3. <navbar :config="config" backColor="#999999"></navbar>
  4. <view class="ranking-lable">
  5. <view :class="['ranking-lable-item' , activeRankingLable === 'thisMonth' ? 'active-ranking-lable' :'' ]"
  6. @click.stop="onRanking('thisMonth')" style="margin-right: 60rpx;">月度排行</view>
  7. <view :class="['ranking-lable-item' , activeRankingLable === 'thisYear' ? 'active-ranking-lable' :'' ]"
  8. style="margin-left: 60rpx;" @click.stop="onRanking('thisYear')">年度排行
  9. </view>
  10. </view>
  11. <view class="ranking-list-box">
  12. <view class="ranking-title">
  13. <text class="ranking-v title-rank">排名</text>
  14. <text class="ranking-v title-user zw-one-row">用户</text>
  15. <text class="ranking-v title-num zw-one-row">已完成数量</text>
  16. </view>
  17. <view class="ranking-item" v-for="(item , index) in RankingList">
  18. <view class="title-rank">
  19. <template v-if="index <= 2">
  20. <image :src="`../task/static/ranking-${index + 1}.png`" mode="aspectFit"></image>
  21. </template>
  22. <template v-else>
  23. {{index + 1}}
  24. </template>
  25. </view>
  26. <view class="title-user zw-one-row">
  27. <image :src="item.headPhoto || defaultPhoto" mode="aspectFit"></image>
  28. <text class="zw-one-row">{{ item.nickname }}</text>
  29. </view>
  30. <view class="title-num zw-one-row">
  31. {{ item.num }}
  32. </view>
  33. </view>
  34. <view class="empty-data" v-if="(!RankingList || RankingList.length===0) && loading ">
  35. <EmptyDate />
  36. </view>
  37. </view>
  38. <view class="my-ranking-box" v-if="myRanking">
  39. <view class="my-ranking">
  40. <view class="title-rank">
  41. <image src="./static/no-rank.png" mode="aspectFit"></image>
  42. </view>
  43. <view class="title-user zw-one-row">
  44. <image :src="myRanking.headPhoto || defaultPhoto" mode="aspectFit"></image>
  45. <text class="zw-one-row">{{ myRanking.nickname }}</text>
  46. </view>
  47. <view class="title-num zw-one-row">
  48. {{ myRanking.num }}
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import {
  56. getRankingList_Api,
  57. myRanking_Api
  58. } from '@/api/task.js'
  59. export default {
  60. data() {
  61. return {
  62. defaultPhoto: require("@/static/default-avatar.png"),
  63. config: {
  64. back: true,
  65. title: '排行榜',
  66. color: 'black',
  67. backgroundColor: [1, '#fff'],
  68. statusBarFontColor: 'black'
  69. },
  70. activeRankingLable: '',
  71. RankingList: [],
  72. myRanking: null,
  73. loading: false
  74. }
  75. },
  76. onLoad() {
  77. this.onRanking();
  78. },
  79. methods: {
  80. onRanking(type = 'thisMonth') {
  81. this.activeRankingLable = type;
  82. this.RankingList = [];
  83. this.myRanking = null;
  84. this.getRankingList()
  85. },
  86. getRankingList() {
  87. this.loading = false
  88. getRankingList_Api({
  89. limit: 50,
  90. mode: this.activeRankingLable
  91. }).then(res => {
  92. this.RankingList = res.data || [];
  93. if (this.RankingList && this.RankingList.length > 0) {
  94. this.getMyRanking()
  95. }
  96. }).finally(() => {
  97. this.loading = true
  98. })
  99. },
  100. getMyRanking() {
  101. myRanking_Api({
  102. limit: 50,
  103. mode: this.activeRankingLable
  104. }).then(res => {
  105. const data = res.data;
  106. if (data) {
  107. try {
  108. this.RankingList.forEach((el, index) => {
  109. if (el.id === data.id) {
  110. data.ranVal = index + 1;
  111. this.myRanking = null
  112. throw new Error()
  113. }
  114. })
  115. } catch (e) {
  116. //TODO handle the exception
  117. return
  118. }
  119. this.myRanking = data
  120. }
  121. // this.myRanking = res.data || null
  122. })
  123. }
  124. }
  125. }
  126. </script>
  127. <style>
  128. page {
  129. background-color: #F5F5F5;
  130. }
  131. </style>
  132. <style lang="scss" scoped>
  133. .ranking-lable {
  134. width: 100%;
  135. height: 90rpx;
  136. display: flex;
  137. justify-content: center;
  138. // background-color: red;
  139. .ranking-lable-item {
  140. height: 90rpx;
  141. line-height: 90rpx;
  142. font-size: 30rpx;
  143. font-family: PingFang SC, PingFang SC-Regular;
  144. font-weight: Regular;
  145. color: #1a1a1a;
  146. position: relative;
  147. &::before {
  148. content: '';
  149. position: absolute;
  150. left: 0;
  151. bottom: 0;
  152. right: 0;
  153. height: 4rpx;
  154. border-radius: 2rpx;
  155. }
  156. }
  157. .active-ranking-lable {
  158. font-family: PingFang SC, PingFang SC-Bold;
  159. font-weight: Bold;
  160. color: #3bb7ce;
  161. &::before {
  162. background-color: #3BB7CE;
  163. }
  164. }
  165. }
  166. .ranking-list-box {
  167. width: 100%;
  168. padding: 0 60rpx 100rpx 40rpx;
  169. background-color: #fff;
  170. border-radius: 40rpx 40rpx 0px 0px;
  171. .ranking-title {
  172. width: 100%;
  173. height: 88rpx;
  174. display: flex;
  175. justify-content: space-between;
  176. align-items: flex-end;
  177. .title-user {
  178. padding-left: 146rpx;
  179. }
  180. .ranking-v {
  181. font-size: 28rpx;
  182. // font-family: .PingFang SC, .PingFang SC-Light;
  183. font-weight: Light;
  184. color: #1a1a1a;
  185. }
  186. }
  187. .ranking-item {
  188. width: 100%;
  189. height: 133rpx;
  190. display: flex;
  191. justify-content: space-between;
  192. align-items: center;
  193. border-bottom: 1rpx solid #e6e6e6;
  194. .title-rank {
  195. text-align: center;
  196. font-size: 30rpx;
  197. font-family: PingFang SC, PingFang SC-Regular;
  198. font-weight: Regular;
  199. color: #1a1a1a;
  200. image {
  201. width: 75rpx;
  202. height: 75rpx;
  203. }
  204. }
  205. .title-num {
  206. font-size: 28rpx;
  207. font-family: PingFang SC, PingFang SC-Regular;
  208. font-weight: Regular;
  209. color: #3fbbd1;
  210. }
  211. }
  212. }
  213. .ranking-item,
  214. .my-ranking {
  215. .title-user {
  216. display: flex;
  217. align-items: center;
  218. image {
  219. width: 75rpx;
  220. height: 75rpx;
  221. flex-shrink: 0;
  222. }
  223. text {
  224. padding-left: 30rpx;
  225. font-size: 32rpx;
  226. font-family: PingFang SC, PingFang SC-Regular;
  227. font-weight: Regular;
  228. text-align: left;
  229. color: #1a1a1a;
  230. }
  231. }
  232. }
  233. .title-rank {
  234. width: 75rpx;
  235. flex-shrink: 0;
  236. }
  237. .title-user {
  238. width: calc(100% - 75rpx - 180rpx);
  239. padding: 0 20rpx;
  240. image {
  241. border-radius: 50%;
  242. }
  243. }
  244. .title-num {
  245. width: 180rpx;
  246. flex-shrink: 0;
  247. display: flex;
  248. align-items: center;
  249. justify-content: flex-end;
  250. font-size: 28rpx;
  251. font-family: PingFang SC, PingFang SC-Regular;
  252. font-weight: Regular;
  253. color: #3fbbd1;
  254. }
  255. .my-ranking-box {
  256. width: 100%;
  257. height: 158rpx;
  258. // background-color: #F5F5F5;
  259. .my-ranking {
  260. position: fixed;
  261. left: 0;
  262. bottom: 0;
  263. right: 0;
  264. background-color: #fff;
  265. height: 148rpx;
  266. display: flex;
  267. flex-direction: row;
  268. padding: 0 60rpx 0 25rpx;
  269. box-shadow: 0px 0px 0px 20rpx #F5F5F5;
  270. .title-rank {
  271. width: 90rpx;
  272. display: flex;
  273. flex-direction: column;
  274. justify-content: center;
  275. image {
  276. width: 90rpx;
  277. height: 37rpx;
  278. }
  279. .title-rank-icon {
  280. margin-left: 15rpx;
  281. width: 75rpx;
  282. height: 75rpx;
  283. }
  284. }
  285. }
  286. }
  287. </style>