国外MOSE官网
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.

236 lines
5.1 KiB

4 days ago
  1. <template>
  2. <view class="volunteer-ranking">
  3. <view class="ranking-header">
  4. <image class="ranking-title-img" src="/static/积分排行榜.png" mode="aspectFit"></image>
  5. <view class="more" @click="goToRankingList">
  6. <text class="more-text">更多</text>
  7. <uv-icon name="arrow-right" color="#999" size="12"></uv-icon>
  8. </view>
  9. </view>
  10. <view class="ranking-scroll-container">
  11. <scroll-view class="ranking-list" scroll-x show-scrollbar="false" enhanced="true" enable-flex="true" scroll-with-animation="true" @scroll="onScrollChange">
  12. <view class="ranking-content">
  13. <view class="ranking-item" v-for="(item, index) in rankingList" :key="index" @click="viewVolunteerDetail(item)">
  14. <view class="avatar-container">
  15. <view class="avatar-with-border">
  16. <image :src="item.avatar" class="avatar-image" mode="aspectFill"></image>
  17. </view>
  18. </view>
  19. <view class="points-container">
  20. <image class="points-icon" src="/static/积分图标.png" mode="aspectFit"></image>
  21. <text class="volunteer-points">{{item.points}}</text>
  22. </view>
  23. <text class="volunteer-name">{{item.name}}</text>
  24. </view>
  25. </view>
  26. </scroll-view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. name: 'VolunteerRanking',
  33. data() {
  34. return {
  35. rankingList: [
  36. {
  37. id: 1,
  38. name: '甜甜',
  39. avatar: '/static/默认头像.png',
  40. points: 7854
  41. },
  42. {
  43. id: 2,
  44. name: '懒洋洋',
  45. avatar: '/static/默认头像.png',
  46. points: 6514
  47. },
  48. {
  49. id: 3,
  50. name: '这很南平',
  51. avatar: '/static/默认头像.png',
  52. points: 4454
  53. },
  54. {
  55. id: 4,
  56. name: '附近用户',
  57. avatar: '/static/默认头像.png',
  58. points: 3354
  59. },
  60. {
  61. id: 5,
  62. name: '故事',
  63. avatar: '/static/默认头像.png',
  64. points: 2154
  65. }
  66. ],
  67. currentScrollIndex: 0
  68. }
  69. },
  70. methods: {
  71. goToRankingList() {
  72. // 跳转到排行榜详情页
  73. uni.navigateTo({
  74. url: '/subPages/index/ranking'
  75. })
  76. },
  77. viewVolunteerDetail(volunteer) {
  78. // 查看志愿者详情
  79. uni.navigateTo({
  80. url: `/subPages/index/volunteer-detail?id=${volunteer.id}`
  81. })
  82. },
  83. onScrollChange(e) {
  84. // 根据滚动位置更新指示器
  85. const scrollLeft = e.detail.scrollLeft;
  86. const scrollWidth = e.detail.scrollWidth;
  87. const clientWidth = e.detail.scrollWidth / this.rankingList.length * 3;
  88. // 计算当前滚动索引(每3个为一组)
  89. if (scrollLeft < clientWidth / 3) {
  90. this.currentScrollIndex = 0;
  91. } else if (scrollLeft < clientWidth * 2 / 3) {
  92. this.currentScrollIndex = 1;
  93. } else {
  94. this.currentScrollIndex = 2;
  95. }
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .volunteer-ranking {
  102. background-color: #fff;
  103. margin: 20rpx;
  104. border-radius: 10rpx;
  105. padding: 20rpx;
  106. .ranking-header {
  107. display: flex;
  108. justify-content: space-between;
  109. align-items: center;
  110. margin-bottom: 20rpx;
  111. .ranking-title-img {
  112. height: 60rpx;
  113. width: 200rpx;
  114. }
  115. .more {
  116. display: flex;
  117. align-items: center;
  118. .more-text {
  119. font-size: 24rpx;
  120. color: $uni-text-color-grey;
  121. margin-right: 4rpx;
  122. }
  123. }
  124. }
  125. .ranking-scroll-container {
  126. position: relative;
  127. width: 100%;
  128. }
  129. .ranking-list {
  130. white-space: nowrap;
  131. padding: 15rpx 0;
  132. width: 100%;
  133. overflow-x: auto;
  134. -webkit-overflow-scrolling: touch;
  135. .ranking-content {
  136. display: flex;
  137. padding: 0 20rpx;
  138. min-width: max-content;
  139. }
  140. .ranking-item {
  141. display: inline-flex;
  142. flex-direction: column;
  143. align-items: center;
  144. margin-right: 40rpx;
  145. flex-shrink: 0;
  146. min-width: 100rpx;
  147. transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  148. &:hover, &:active {
  149. transform: scale(1.08);
  150. }
  151. &:last-child {
  152. margin-right: 20rpx;
  153. }
  154. .avatar-container {
  155. position: relative;
  156. width: 100rpx;
  157. height: 100rpx;
  158. display: flex;
  159. justify-content: center;
  160. align-items: center;
  161. .avatar-with-border {
  162. width: 100rpx;
  163. height: 100rpx;
  164. border: 4rpx solid #218CDD;
  165. border-radius: 50%;
  166. box-shadow: 0 4rpx 12rpx rgba(33, 140, 221, 0.2);
  167. transition: all 0.3s ease;
  168. overflow: hidden;
  169. display: flex;
  170. align-items: center;
  171. justify-content: center;
  172. .avatar-image {
  173. width: 100%;
  174. height: 100%;
  175. border-radius: 50%;
  176. }
  177. }
  178. }
  179. .points-container {
  180. display: flex;
  181. align-items: center;
  182. justify-content: center;
  183. margin-top: 8rpx;
  184. background-color: #218CDD;
  185. border-radius: 20rpx;
  186. padding: 4rpx 12rpx;
  187. box-shadow: 0 2rpx 8rpx rgba(33, 140, 221, 0.3);
  188. .points-icon {
  189. width: 20rpx;
  190. height: 20rpx;
  191. margin-right: 4rpx;
  192. filter: brightness(0) invert(1);
  193. }
  194. .volunteer-points {
  195. font-size: 20rpx;
  196. color: #fff;
  197. font-weight: bold;
  198. margin: 0;
  199. }
  200. }
  201. .volunteer-name {
  202. font-size: 24rpx;
  203. color: $uni-text-color;
  204. margin-top: 10rpx;
  205. max-width: 100rpx;
  206. white-space: nowrap;
  207. overflow: hidden;
  208. text-overflow: ellipsis;
  209. font-weight: 500;
  210. }
  211. }
  212. }
  213. }
  214. </style>