ranking.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <view class="">
  3. <nav-bar title="排行榜" goBack />
  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="`./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 || $defaultHadPhoto" 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 || $defaultHadPhoto" 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. config: {
  63. back: true,
  64. title: '排行榜',
  65. color: 'black',
  66. backgroundColor: [1, '#fff'],
  67. statusBarFontColor: 'black'
  68. },
  69. activeRankingLable: '',
  70. RankingList: [],
  71. myRanking: null,
  72. loading: false
  73. }
  74. },
  75. onLoad() {
  76. this.onRanking();
  77. },
  78. methods: {
  79. onRanking(type = 'thisMonth') {
  80. this.activeRankingLable = type;
  81. this.RankingList = [];
  82. this.myRanking = null;
  83. this.getRankingList()
  84. },
  85. getRankingList() {
  86. this.loading = false
  87. getRankingList_Api({
  88. limit: 50,
  89. mode: this.activeRankingLable
  90. }).then(res => {
  91. this.RankingList = res.data || [];
  92. if (this.RankingList && this.RankingList.length > 0) {
  93. this.getMyRanking()
  94. }
  95. }).finally(() => {
  96. this.loading = true
  97. })
  98. },
  99. getMyRanking() {
  100. myRanking_Api({
  101. limit: 50,
  102. mode: this.activeRankingLable
  103. }).then(res => {
  104. const data = res.data;
  105. if (data) {
  106. try {
  107. this.RankingList.forEach((el, index) => {
  108. if (el.id === data.id) {
  109. data.ranVal = index + 1;
  110. this.myRanking = null
  111. throw new Error()
  112. }
  113. })
  114. } catch (e) {
  115. //TODO handle the exception
  116. return
  117. }
  118. this.myRanking = data
  119. }
  120. // this.myRanking = res.data || null
  121. })
  122. }
  123. }
  124. }
  125. </script>
  126. <style>
  127. page {
  128. background-color: #F5F5F5;
  129. }
  130. </style>
  131. <style lang="scss" scoped>
  132. .ranking-lable {
  133. width: 100%;
  134. height: 90rpx;
  135. display: flex;
  136. justify-content: center;
  137. // background-color: red;
  138. .ranking-lable-item {
  139. height: 90rpx;
  140. line-height: 90rpx;
  141. font-size: 30rpx;
  142. font-family: PingFang SC, PingFang SC-Regular;
  143. font-weight: Regular;
  144. color: #1a1a1a;
  145. position: relative;
  146. &::before {
  147. content: '';
  148. position: absolute;
  149. left: 0;
  150. bottom: 0;
  151. right: 0;
  152. height: 4rpx;
  153. border-radius: 2rpx;
  154. }
  155. }
  156. .active-ranking-lable {
  157. font-family: PingFang SC, PingFang SC-Bold;
  158. font-weight: Bold;
  159. color: #3bb7ce;
  160. &::before {
  161. background-color: #3BB7CE;
  162. }
  163. }
  164. }
  165. .ranking-list-box {
  166. width: 100%;
  167. padding: 0 60rpx 100rpx 40rpx;
  168. background-color: #fff;
  169. border-radius: 40rpx 40rpx 0px 0px;
  170. .ranking-title {
  171. width: 100%;
  172. height: 88rpx;
  173. display: flex;
  174. justify-content: space-between;
  175. align-items: flex-end;
  176. .title-user {
  177. padding-left: 146rpx;
  178. }
  179. .ranking-v {
  180. font-size: 28rpx;
  181. // font-family: .PingFang SC, .PingFang SC-Light;
  182. font-weight: Light;
  183. color: #1a1a1a;
  184. }
  185. }
  186. .ranking-item {
  187. width: 100%;
  188. height: 133rpx;
  189. display: flex;
  190. justify-content: space-between;
  191. align-items: center;
  192. border-bottom: 1rpx solid #e6e6e6;
  193. .title-rank {
  194. text-align: center;
  195. font-size: 30rpx;
  196. font-family: PingFang SC, PingFang SC-Regular;
  197. font-weight: Regular;
  198. color: #1a1a1a;
  199. image {
  200. width: 75rpx;
  201. height: 75rpx;
  202. }
  203. }
  204. .title-num {
  205. font-size: 28rpx;
  206. font-family: PingFang SC, PingFang SC-Regular;
  207. font-weight: Regular;
  208. color: #3fbbd1;
  209. }
  210. }
  211. }
  212. .ranking-item,
  213. .my-ranking {
  214. .title-user {
  215. display: flex;
  216. align-items: center;
  217. image {
  218. width: 75rpx;
  219. height: 75rpx;
  220. flex-shrink: 0;
  221. }
  222. text {
  223. padding-left: 30rpx;
  224. font-size: 32rpx;
  225. font-family: PingFang SC, PingFang SC-Regular;
  226. font-weight: Regular;
  227. text-align: left;
  228. color: #1a1a1a;
  229. }
  230. }
  231. }
  232. .title-rank {
  233. width: 75rpx;
  234. flex-shrink: 0;
  235. }
  236. .title-user {
  237. width: calc(100% - 75rpx - 180rpx);
  238. padding: 0 20rpx;
  239. image {
  240. border-radius: 50%;
  241. }
  242. }
  243. .title-num {
  244. width: 180rpx;
  245. flex-shrink: 0;
  246. display: flex;
  247. align-items: center;
  248. justify-content: flex-end;
  249. font-size: 28rpx;
  250. font-family: PingFang SC, PingFang SC-Regular;
  251. font-weight: Regular;
  252. color: #3fbbd1;
  253. }
  254. .my-ranking-box {
  255. width: 100%;
  256. height: 158rpx;
  257. // background-color: #F5F5F5;
  258. .my-ranking {
  259. position: fixed;
  260. left: 0;
  261. bottom: 0;
  262. right: 0;
  263. background-color: #fff;
  264. height: 148rpx;
  265. display: flex;
  266. flex-direction: row;
  267. padding: 0 60rpx 0 25rpx;
  268. box-shadow: 0px 0px 0px 20rpx #F5F5F5;
  269. .title-rank {
  270. width: 90rpx;
  271. display: flex;
  272. flex-direction: column;
  273. justify-content: center;
  274. image {
  275. width: 90rpx;
  276. height: 37rpx;
  277. }
  278. .title-rank-icon {
  279. margin-left: 15rpx;
  280. width: 75rpx;
  281. height: 75rpx;
  282. }
  283. }
  284. }
  285. }
  286. </style>