rank.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view class="sub-base-container">
  3. <view class="gradient-reflection" data-text="好友排行榜">好友排行榜</view>
  4. <view class="rank-card">
  5. <view class="tabs">
  6. <view :class="['tab-item',{active:active === item.speciesId}]" v-for="(item,index) in tabsList"
  7. :key="index" @click="handleTab(item)">{{item.name}}</view>
  8. </view>
  9. <scroll-view
  10. class="rank-list"
  11. v-if="rankList.length"
  12. scroll-y="true"
  13. @scrolltolower="loadMore"
  14. :style="{height: 'calc(100vh - 500rpx)'}"
  15. >
  16. <view :class="['rank-item',{bg:(index + 1) <=3}]" v-for="(item,index) in rankList" :key="index">
  17. <view class="rank-info">
  18. <text :class="['num',`num-${(index + 1)}`]">{{item.ranking}}</text>
  19. <up-image class="avatar" :fade="false" :src="item.icon" width="92rpx" height="92rpx"
  20. shape="circle"></up-image>
  21. <view class="info">
  22. <view class="name">
  23. <text>{{item.treeName || item.nickname.slice(0, 3) + "荔"}}</text>
  24. <view :class="['level',{levelBlue:item.level.id >3}]">
  25. V{{item.level.id}}.{{item.level.name}}</view>
  26. </view>
  27. <text class="nickname ellipsis-l1">昵称:{{item.nickname}}</text>
  28. </view>
  29. </view>
  30. <view class="button" @click="handlePage">去看看</view>
  31. </view>
  32. <!-- 加载更多提示 -->
  33. <view class="loading-more" v-if="loading">
  34. <text>下拉加载数据</text>
  35. </view>
  36. <view class="no-more" v-if="!hasMore && rankList.length > 0">
  37. <text>没有更多数据了</text>
  38. </view>
  39. </scroll-view>
  40. <up-empty v-else mode="data" marginTop="50">
  41. </up-empty>
  42. </view>
  43. </view>
  44. </template>
  45. <script setup>
  46. import {
  47. ref
  48. } from "vue"
  49. import TREE from '@/api/tree.js'
  50. import {
  51. onLoad
  52. } from '@dcloudio/uni-app'
  53. onLoad(() => {
  54. getCategoryList()
  55. getRankingList()
  56. })
  57. const handlePage = () =>{
  58. uni.navigateTo({
  59. url: `/pages/tabBar/tree/subPages/friendTree?`
  60. });
  61. }
  62. const active = ref(null)
  63. const tabsList = ref([])
  64. const handleTab = (item) => {
  65. active.value = item.speciesId
  66. // 切换tab时重置分页
  67. currentPage.value = 1
  68. rankList.value = []
  69. hasMore.value = true
  70. getRankingList()
  71. }
  72. const getCategoryList = () => {
  73. TREE.categoryList().then(res => {
  74. tabsList.value = res.data || []
  75. tabsList.value.unshift({
  76. name: '总榜',
  77. speciesId: null
  78. })
  79. })
  80. }
  81. const rankList = ref([])
  82. const currentPage = ref(1)
  83. const loading = ref(false)
  84. const hasMore = ref(true)
  85. const getRankingList = () => {
  86. if (loading.value || !hasMore.value) return
  87. loading.value = true
  88. const params = {
  89. speciesId: active.value,
  90. page: currentPage.value,
  91. limit: 10
  92. }
  93. TREE.rankingList(params).then(res => {
  94. const newData = res.data || []
  95. if (currentPage.value === 1) {
  96. rankList.value = newData
  97. } else {
  98. rankList.value = [...rankList.value, ...newData]
  99. }
  100. // 判断是否还有更多数据
  101. hasMore.value = newData.length === 10
  102. loading.value = false
  103. }).catch(() => {
  104. loading.value = false
  105. })
  106. }
  107. const loadMore = () => {
  108. if (hasMore.value && !loading.value) {
  109. currentPage.value++
  110. getRankingList()
  111. }
  112. }
  113. </script>
  114. <style lang="scss" scoped>
  115. @import "@/static/style/mixin.scss";
  116. .sub-base-container {
  117. @include ossBg("subTreePage/rank-bg.png");
  118. .gradient-reflection {
  119. width: 100%;
  120. position: relative;
  121. font-size: 86rpx;
  122. color: #fff;
  123. font-family: "PangMenZhengDao";
  124. text-align: center;
  125. }
  126. .gradient-reflection::after {
  127. content: attr(data-text);
  128. position: absolute;
  129. top: 75%;
  130. left: calc(50% - 430rpx / 2);
  131. transform: scaleY(-1);
  132. background: rgba(255, 255, 255, 0.5);
  133. -webkit-background-clip: text;
  134. background-clip: text;
  135. color: transparent;
  136. opacity: 0.5;
  137. }
  138. .rank-card {
  139. margin-top: 90rpx;
  140. background: rgba(255, 255, 255, 0.74);
  141. border-radius: 20rpx 20rpx 0 0;
  142. padding: 20rpx;
  143. .tabs {
  144. display: flex;
  145. .tab-item {
  146. flex: 1;
  147. text-align: center;
  148. color: rgba(0, 0, 0, 0.5);
  149. font-size: 28rpx;
  150. padding: 10rpx 0;
  151. &.active {
  152. border-radius: 50rpx;
  153. color: #000;
  154. background: #fff;
  155. }
  156. }
  157. }
  158. .rank-list {
  159. .rank-item {
  160. display: flex;
  161. align-items: center;
  162. justify-content: space-between;
  163. padding: 14rpx 20rpx;
  164. border-radius: 10rpx;
  165. margin-top: 20rpx;
  166. &.bg {
  167. background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.6), transparent);
  168. }
  169. .rank-info {
  170. display: flex;
  171. align-items: center;
  172. font-size: 24rpx;
  173. .num {
  174. margin-right: 28rpx;
  175. color: #724E02;
  176. font-family: 'SweiSpringCJKtc';
  177. &-1 {
  178. background: linear-gradient(to bottom, #724E02 0%, #F3C11D 100%);
  179. -webkit-background-clip: text;
  180. background-clip: text;
  181. color: transparent;
  182. font-size: 52rpx;
  183. font-family: 'SMILEYSANS';
  184. }
  185. &-2 {
  186. background: linear-gradient(to bottom, #898989 0%, #fff 100%);
  187. -webkit-background-clip: text;
  188. background-clip: text;
  189. color: transparent;
  190. font-size: 52rpx;
  191. font-family: 'SMILEYSANS';
  192. }
  193. &-3 {
  194. background: linear-gradient(to bottom, #F2BF16 0%, #FF8400 100%);
  195. -webkit-background-clip: text;
  196. background-clip: text;
  197. color: transparent;
  198. font-size: 52rpx;
  199. font-family: 'SMILEYSANS';
  200. }
  201. }
  202. .info {
  203. margin-left: 10rpx;
  204. .name {
  205. font-size: 28rpx;
  206. font-weight: 500;
  207. display: flex;
  208. align-items: center;
  209. margin-bottom: 4rpx;
  210. }
  211. .level {
  212. background: rgba(81, 81, 81, 0.1);
  213. color: #444444;
  214. border-radius: 4rpx;
  215. font-size: 24rpx;
  216. padding: 4rpx 10rpx;
  217. margin-left: 20rpx;
  218. &.levelBlue {
  219. background: #fff;
  220. color: #2199F8;
  221. }
  222. }
  223. .nickname {
  224. max-width: 320rpx;
  225. color: rgba(0, 0, 0, 0.5);
  226. }
  227. }
  228. }
  229. .button {
  230. font-size: 24rpx;
  231. padding: 10rpx 20rpx;
  232. border-radius: 50rpx;
  233. border: 2rpx solid rgba(0, 0, 0, 0.3);
  234. background: #fff;
  235. }
  236. }
  237. .loading-more, .no-more {
  238. text-align: center;
  239. padding: 20rpx 0;
  240. color: rgba(0, 0, 0, 0.5);
  241. font-size: 24rpx;
  242. }
  243. }
  244. }
  245. }
  246. </style>