index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view class="box">
  3. <view class="top">
  4. <view class="left">
  5. <text class="name">荣誉积分</text>
  6. <text class="num">{{ integral.honorPoints || 0 }}</text>
  7. </view>
  8. <view class="right">
  9. <text class="name">消费积分</text>
  10. <text class="num">{{ integral.spendPoints || 0 }}</text>
  11. </view>
  12. </view>
  13. <view class="main">
  14. <view class="titleBox">
  15. <view class="ranking">排名</view>
  16. <view class="userName">姓名</view>
  17. <view class="userIntegral">积分</view>
  18. </view>
  19. <view class="titleBox item" v-for="(item, index) in list" :key="index">
  20. <view class="ranking">{{ item.num | userNum }}</view>
  21. <view class="userName">{{ item.name }}</view>
  22. <view class="userIntegral">{{ item.honorPoints }}分</view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import request from '../../api/integral';
  29. export default {
  30. data() {
  31. return {
  32. integral: {},
  33. list: []
  34. }
  35. },
  36. async mounted() {
  37. const integral = await request.getIntegral();
  38. this.integral = integral.data;
  39. const ranking = await request.getRanking();
  40. let num = 0;
  41. this.list = ranking.data.map(e => {
  42. num ++
  43. return { ...e, num }
  44. });
  45. },
  46. filters: {
  47. userNum(val) {
  48. if (val == 1) return '🥇';
  49. if (val == 2) return '🥈';
  50. if (val == 3) return '🥉';
  51. return val;
  52. }
  53. }
  54. }
  55. </script>
  56. <style>
  57. .top {
  58. width: 100%;
  59. height: 15vh;
  60. background-color: #cb0714;
  61. display: flex;
  62. }
  63. .left, .right {
  64. width: 50%;
  65. color: #fff;
  66. }
  67. .left .name, .right .name {
  68. width: 100%;
  69. text-align: center;
  70. font-size: 1.2em;
  71. display: block;
  72. }
  73. .left .num, .right .num {
  74. display: block;
  75. width: 100%;
  76. text-align: center;
  77. font-size: 1.5em;
  78. }
  79. .titleBox {
  80. display: flex;
  81. border-bottom: 1px solid #bfbfbf;
  82. background-color: #dddddd;
  83. }
  84. .ranking, .userName, .userIntegral {
  85. width: 32%;
  86. text-align: center;
  87. }
  88. .userName {
  89. border-left: 1px solid #bfbfbf;
  90. border-right: 1px solid #bfbfbf;
  91. }
  92. .item {
  93. background-color: #fff;
  94. line-height: 2.5em;
  95. }
  96. </style>