rank.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <view class="cu-modal bottom-modal" :class="{'show': visible}">
  3. <view class="mask" @click="close"></view>
  4. <view class="cu-dialog wrapper">
  5. <view class="paddingY25 flex-align-center relative">
  6. <view class="font6 bold color-1">实时榜单</view>
  7. <image :src="resource.icon_x" class="x" @click="close" />
  8. </view>
  9. <view>
  10. <scroll-view style="height: 350px" scroll-y v-if="tableData && tableData.length > 0">
  11. <view v-for="(item, index) in tableData" :key="index" class="cell flex-align" style="margin-bottom: 10px">
  12. <view class="index bold color-1">{{index + 1}}</view>
  13. <image v-if="index === 0" class="rank_flag translateY" :src="resource.prince_rank_1" />
  14. <image v-if="index === 1" class="rank_flag translateY" :src="resource.prince_rank_2" />
  15. <image v-if="index === 2" class="rank_flag translateY" :src="resource.prince_rank_3" />
  16. <image :src="item.avatar" style="width: 52rpx;height:52rpx;border-radius: 26rpx" />
  17. <view class="color-1 font2 marginL12 flex1">{{item.nickname}}</view>
  18. <view class="flex-shrink0 num color-theme">走到 {{item.quantity}}</view>
  19. </view>
  20. </scroll-view>
  21. <empty v-if="!tableData || tableData.length === 0" :top="100" />
  22. <view v-if="myData" class="cell my flex-align">
  23. <image v-if="myData.index === 0" class="rank_flag translateY" :src="resource.prince_rank_1" />
  24. <image v-else-if="myData.index === 1" class="rank_flag translateY" :src="resource.prince_rank_2" />
  25. <image v-else-if="myData.index === 2" class="rank_flag translateY" :src="resource.prince_rank_3" />
  26. <view v-if="myData.index < 50" class="index bold color-white">{{myData.index + 1}}</view>
  27. <view v-else class="index color-white">暂无排名</view>
  28. <image :src="myData.avatar" style="width: 52rpx;height:52rpx;border-radius: 26rpx" />
  29. <view class="color-white font2 marginL12 flex1">{{myData.nickname}}</view>
  30. <view class="flex-shrink0 num color-theme">走到 {{myData.quantity || 0}}</view>
  31. </view>
  32. </view>
  33. </view>
  34. <people ref="people"/>
  35. </view>
  36. </template>
  37. <script>
  38. import resource from '@/utils/resource'
  39. import empty from '@/components/empty'
  40. export default {
  41. components: { empty },
  42. data() {
  43. return {
  44. tableData: null,
  45. resource,
  46. visible: false,
  47. myData: null
  48. }
  49. },
  50. methods: {
  51. show() {
  52. this.$parent.$parent.lock = true
  53. this.visible = true
  54. this.refresh()
  55. },
  56. close() {
  57. this.$parent.$parent.lock = false
  58. this.visible = false
  59. this.tableData = null
  60. this.myData = null
  61. },
  62. refresh() {
  63. this.loadData()
  64. },
  65. async loadData() {
  66. const res = await this.$service.weal.richRank()
  67. if (res) {
  68. this.tableData = res.billboardList
  69. if (res.myBillboard) {
  70. let my = res.myBillboard
  71. let flag = 50
  72. for (let i = 0; i < this.tableData.length; i++) {
  73. if (my.userId === this.tableData[i].userId) {
  74. flag = i
  75. break
  76. }
  77. }
  78. my.index = flag
  79. this.myData = my
  80. }
  81. }
  82. }
  83. }
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. .mask {
  88. position: absolute;
  89. left: 0;
  90. right: 0;
  91. top: 0;
  92. bottom: 0;
  93. }
  94. .wrapper {
  95. padding: 0 28rpx 64rpx;
  96. background: #fff;
  97. border-radius: 15px 15px 2px 2px !important;
  98. .x {
  99. position: absolute;
  100. right: 28rpx;
  101. top: 50%;
  102. margin-top: -16rpx;
  103. width: 32rpx;
  104. height: 32rpx;
  105. }
  106. .cell {
  107. position: relative;
  108. height: 48px;
  109. background: rgba($color: #8f4bf1, $alpha: 0.1);
  110. border-radius: 4px;
  111. padding-left: 13px;
  112. padding-right: 25px;
  113. .index {
  114. width: 70px;
  115. }
  116. .num {
  117. font-size: 12px;
  118. }
  119. &.my {
  120. background: #8f4bf1;
  121. .num {
  122. color: #fff;
  123. }
  124. }
  125. .rank_flag {
  126. width: 21px;
  127. height: 20px;
  128. position: absolute;
  129. left: 35px;
  130. }
  131. }
  132. }
  133. </style>