木邻有你前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

329 lines
7.1 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
  1. <template>
  2. <view class="ranking-page">
  3. <view class="back-button" @click="goBack">
  4. <uv-icon name="arrow-left" color="#ffffff" size="20"></uv-icon>
  5. </view>
  6. <!-- 排行榜背景 -->
  7. <view class="ranking-background">
  8. <image src="/subPages/static/rank_bg.png" class="bg-image" mode="aspectFill"></image>
  9. <!-- 返回按钮 -->
  10. <!-- 前三名定位布局 -->
  11. <view class="top-three">
  12. <!-- 第二名 -->
  13. <view class="rank-item rank-second">
  14. <image src="/subPages/static/second.png" class="rank-badge"></image>
  15. <image :src="topThree[1].headImage || '/static/默认头像.png'" class="avatar"></image>
  16. <view class="name">{{ topThree[1].nickName }}</view>
  17. <view class="score">{{ topThree[1].score }}积分</view>
  18. </view>
  19. <!-- 第一名 -->
  20. <view class="rank-item rank-first">
  21. <image src="/subPages/static/first.png" class="rank-badge"></image>
  22. <image :src="topThree[0].headImage || '/static/默认头像.png'" class="avatar"></image>
  23. <view class="name">{{ topThree[0].nickName }}</view>
  24. <view class="score">{{ topThree[0].score }}积分</view>
  25. </view>
  26. <!-- 第三名 -->
  27. <view class="rank-item rank-third">
  28. <image src="/subPages/static/third.png" class="rank-badge"></image>
  29. <image :src="topThree[2].headImage || '/static/默认头像.png'" class="avatar"></image>
  30. <view class="name">{{ topThree[2].nickName }}</view>
  31. <view class="score">{{ topThree[2].score }}积分</view>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- 我的排名 -->
  36. <view class="my-ranking" v-if="myRanking.rank">
  37. <view class="my-rank-number">{{ myRanking.rank }}</view>
  38. <view class="my-rank-label">我的排名</view>
  39. <image :src="myRanking.headImage" class="my-avatar"></image>
  40. <view class="my-name">{{ myRanking.nickName }}</view>
  41. <view class="my-score">{{ myRanking.score }}积分</view>
  42. </view>
  43. <!-- 排行榜列表 -->
  44. <view class="ranking-list">
  45. <view class="list-item" v-for="(item, index) in rankingList" :key="index">
  46. <view class="rank-number">{{ item.rank }}</view>
  47. <image :src="item.headImage || '/static/默认头像.png'" class="list-avatar"></image>
  48. <view class="user-info">
  49. <view class="user-name">{{ item.nickName }}</view>
  50. </view>
  51. <view class="user-score">{{ item.score }}积分</view>
  52. </view>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import MixinList from '@/mixins/list.js'
  58. export default {
  59. mixins: [MixinList],
  60. name: 'Ranking',
  61. data() {
  62. return {
  63. pageSize: 12,
  64. mixinListApi: 'score.queryScoreRank',
  65. mixinListConfig: {
  66. extraDataPath: 'result.myScore',
  67. responsePath: 'result.scoreList.records'
  68. }
  69. }
  70. },
  71. computed: {
  72. myRanking() {
  73. return this.extraData
  74. },
  75. rankingList() {
  76. return this.list.slice(3)
  77. },
  78. topThree() {
  79. return this.list.slice(0, 3)
  80. },
  81. },
  82. methods: {
  83. mixinSetParams() {
  84. const params = {
  85. pageNo: this.pageNo,
  86. pageSize: this.pageSize
  87. }
  88. if (uni.getStorageSync('token')){
  89. params['token'] = uni.getStorageSync('token')
  90. }
  91. return params
  92. },
  93. goBack() {
  94. uni.navigateBack();
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. // @import '@/uni.scss';
  101. .ranking-page {
  102. min-height: 100vh;
  103. background-color: #f5f5f5;
  104. }
  105. .back-button {
  106. position: fixed;
  107. top: 70rpx;
  108. left: 40rpx;
  109. width: 70rpx;
  110. height: 70rpx;
  111. // background-color: rgba(0, 0, 0, 0.3);
  112. // border-radius: 50%;
  113. display: flex;
  114. align-items: center;
  115. justify-content: center;
  116. z-index: 10;
  117. &:active {
  118. background-color: rgba(0, 0, 0, 0.5);
  119. }
  120. }
  121. .ranking-background {
  122. position: relative;
  123. width: 100%;
  124. height: 600rpx;
  125. .bg-image {
  126. width: 100%;
  127. height: 100%;
  128. }
  129. .back-button {
  130. position: absolute;
  131. top: 60rpx;
  132. left: 30rpx;
  133. width: 60rpx;
  134. height: 60rpx;
  135. // background-color: rgba(0, 0, 0, 0.3);
  136. // border-radius: 50%;
  137. display: flex;
  138. align-items: center;
  139. justify-content: center;
  140. z-index: 10;
  141. &:active {
  142. background-color: rgba(0, 0, 0, 0.5);
  143. }
  144. }
  145. .top-three {
  146. position: absolute;
  147. top: 0;
  148. left: 0;
  149. width: 100%;
  150. height: 100%;
  151. display: flex;
  152. align-items: flex-end;
  153. justify-content: center;
  154. padding-bottom: 80rpx;
  155. .rank-item {
  156. position: relative;
  157. display: flex;
  158. flex-direction: column;
  159. align-items: center;
  160. margin: 0 40rpx;
  161. .rank-badge {
  162. width: 60rpx;
  163. height: 60rpx;
  164. margin-bottom: 10rpx;
  165. }
  166. .avatar {
  167. width: 80rpx;
  168. height: 80rpx;
  169. border-radius: 50%;
  170. margin-bottom: 10rpx;
  171. border: 4rpx solid #fff;
  172. }
  173. .name {
  174. font-size: 24rpx;
  175. color: #fff;
  176. margin-bottom: 5rpx;
  177. font-weight: bold;
  178. }
  179. .score {
  180. font-size: 20rpx;
  181. color: #1488DB;
  182. opacity: 0.9;
  183. }
  184. }
  185. .rank-first {
  186. transform: translateY(-80rpx);
  187. .avatar {
  188. width: 100rpx;
  189. height: 100rpx;
  190. }
  191. .rank-badge {
  192. width: 80rpx;
  193. height: 80rpx;
  194. }
  195. }
  196. .rank-second {
  197. order: -1;
  198. transform: translateY(-40rpx);
  199. }
  200. .rank-third {
  201. order: 1;
  202. transform: translateY(-40rpx);
  203. }
  204. }
  205. }
  206. .my-ranking {
  207. background: #e1f2ff;
  208. border-radius: 12rpx;
  209. margin: 20rpx 30rpx 20rpx 30rpx;
  210. padding: 30rpx;
  211. display: flex;
  212. align-items: center;
  213. // box-shadow: 0 4rpx 12rpx rgba(20, 136, 219, 0.3);
  214. position: relative;
  215. z-index: 5;
  216. .my-rank-number {
  217. font-size: 48rpx;
  218. font-weight: bold;
  219. color: #000;
  220. margin-right: 15rpx;
  221. }
  222. .my-rank-label {
  223. font-size: 24rpx;
  224. color: #1488DB;
  225. opacity: 0.9;
  226. margin-right: 20rpx;
  227. }
  228. .my-avatar {
  229. width: 60rpx;
  230. height: 60rpx;
  231. border-radius: 50%;
  232. // border: 3rpx solid #fff;
  233. margin-right: 15rpx;
  234. }
  235. .my-name {
  236. font-size: 28rpx;
  237. color: #000;
  238. font-weight: 500;
  239. margin-right: 20rpx;
  240. }
  241. .my-score {
  242. font-size: 28rpx;
  243. color: #1488DB;
  244. // font-weight: bold;
  245. }
  246. }
  247. .ranking-list {
  248. padding: 40rpx 30rpx 140rpx;
  249. background-color: #fff;
  250. margin-top: -40rpx;
  251. border-radius: 40rpx 40rpx 0 0;
  252. .list-item {
  253. display: flex;
  254. align-items: center;
  255. padding: 30rpx 0;
  256. border-bottom: 1rpx solid #f0f0f0;
  257. &:last-child {
  258. border-bottom: none;
  259. }
  260. .rank-number {
  261. width: 60rpx;
  262. font-size: 32rpx;
  263. font-weight: bold;
  264. color: #333;
  265. text-align: center;
  266. }
  267. .list-avatar {
  268. width: 80rpx;
  269. height: 80rpx;
  270. border-radius: 50%;
  271. margin: 0 30rpx;
  272. }
  273. .user-info {
  274. flex: 1;
  275. .user-name {
  276. font-size: 28rpx;
  277. color: #333;
  278. font-weight: 500;
  279. }
  280. }
  281. .user-score {
  282. font-size: 28rpx;
  283. color: $uni-color-primary;
  284. // font-weight: bold;
  285. }
  286. }
  287. }
  288. </style>