my-ranklist.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <uni-list class="list" :border="false">
  3. <uni-list-item v-for="(item,index) in rankRs" :key="index" :border="false"
  4. class="list-item uni-row" :class="item.isSelf ? 'list-item-isself' : ''">
  5. <template v-slot:body>
  6. <text class="item-rankNum"
  7. :class="getMedalClass(item.rankNum)">{{item.rankNum > 0 ? item.rankNum : '--'}}</text>
  8. <view class="item-detail uni-row">
  9. <text class="item-userName">{{ teamType >= 0 ? getTeamName(teamType, item.userName) : item.userName}}</text>
  10. <text class="item-totalTime">{{fmtTime(item.totalTime)}}</text>
  11. </view>
  12. </template>
  13. </uni-list-item>
  14. </uni-list>
  15. </template>
  16. <script>
  17. import tools from '/common/tools';
  18. import { teamName } from '/common/define';
  19. export default {
  20. name:"my-ranklist",
  21. props: {
  22. rankRs: {},
  23. teamType: {
  24. type: Number,
  25. default: -1
  26. }
  27. },
  28. data() {
  29. return {
  30. // item: {}
  31. };
  32. },
  33. methods: {
  34. getTeamName(teamType, teamIndex) {
  35. return teamName[teamType][teamIndex];
  36. },
  37. getMedalClass(rankNum) {
  38. if (rankNum == 0)
  39. return 'item-rankNum-other';
  40. if (rankNum <= 3)
  41. return 'item-rankNum-medal-' + rankNum;
  42. else if (rankNum <= 10)
  43. return 'item-rankNum-medal-other';
  44. else
  45. return 'item-rankNum-other';
  46. },
  47. fmtTime(time) {
  48. if (time > 0)
  49. return tools.convertSecondsToHMS(time, 1);
  50. else
  51. return '--';
  52. },
  53. // onItemClick(item) {
  54. // this.data.item = item
  55. // this.$emit('my-combo-list-click', this.data);
  56. // }
  57. }
  58. }
  59. </script>
  60. <style lang="scss" scoped>
  61. .list {
  62. width: 90%;
  63. height: 53vh;
  64. /* margin-top: 20rpx; */
  65. /* margin-top: 1vh; */
  66. overflow: scroll;
  67. }
  68. .list-item {
  69. width: 100%;
  70. height: 70rpx;
  71. justify-content: flex-start;
  72. }
  73. .list-item-isself {
  74. background-color: #ececea !important;
  75. border-radius: 10rpx;
  76. }
  77. .item-rankNum {
  78. width: 80rpx;
  79. height: 50rpx;
  80. text-align: center;
  81. margin-top: 6rpx;
  82. padding-right: 0.5rpx;
  83. margin-right: 20rpx;
  84. font-size: 26rpx;
  85. font-weight: bold;
  86. line-height: 50rpx;
  87. background-repeat: no-repeat;
  88. background-position-x: center;
  89. background-position-y: top;
  90. background-size: contain;
  91. }
  92. .item-detail {
  93. width: 82%;
  94. height: 60rpx;
  95. padding-left: 10rpx;
  96. padding-right: 10rpx;
  97. border-bottom: #ececea 5rpx solid;
  98. justify-content: space-between;
  99. }
  100. .item-rankNum-medal-1 {
  101. color: #bd640a;
  102. background-image: url("/static/default/medal_gold.png");
  103. }
  104. .item-rankNum-medal-2 {
  105. color: #68758c;
  106. background-image: url("/static/default/medal_silver.png");
  107. }
  108. .item-rankNum-medal-3 {
  109. color: #9b3b11;
  110. background-image: url("/static/default/medal_copper.png");
  111. }
  112. .item-rankNum-medal-other {
  113. color: #9a140a;
  114. background-image: url("/static/default/medal_other.png");
  115. }
  116. .item-rankNum-other {
  117. color: #9a140a;
  118. }
  119. .item-userName {
  120. font-size: 30rpx;
  121. }
  122. .item-totalTime {
  123. font-size: 26rpx;
  124. font-weight: 550;
  125. }
  126. </style>