StatsText.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view
  3. :class="[
  4. 'main-stats-text',
  5. title ? '' : 'no-title'
  6. ]"
  7. >
  8. <text class="title">{{ title }}</text>
  9. <view class="stats">
  10. <view
  11. v-for="(item, i) in data"
  12. :key="i"
  13. class="item"
  14. :style="{ width: item.long ? 'calc(100%)' : width }"
  15. @click="item.onClick"
  16. >
  17. <text class="number">{{ item.value }}</text>
  18. <text class="sub-title">{{ item.title }}</text>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script setup lang="ts">
  24. import type { PropType } from 'vue';
  25. defineProps({
  26. title: {
  27. type: String,
  28. default: ''
  29. },
  30. data : {
  31. type: Object as PropType<{
  32. title: string,
  33. value: string,
  34. long?: boolean,
  35. onClick?: () => void
  36. }[]>,
  37. default: () => ([])
  38. } ,
  39. width: {
  40. type: [Number, String],
  41. default: ''
  42. },
  43. })
  44. </script>
  45. <style lang="scss">
  46. @use "sass:map";
  47. @use "@/common/scss/define/colors.scss" as *;
  48. $color-primary: map.get($colors, "primary");
  49. $color-text: map.get($colors, "text");
  50. .main-stats-text {
  51. position: relative;
  52. display: flex;
  53. flex-direction: column;
  54. .title {
  55. font-size: 30rpx;
  56. margin: 10rpx 0;
  57. color: $color-primary;
  58. text-align: center;
  59. }
  60. .stats {
  61. display: flex;
  62. flex-direction: row;
  63. align-items: center;
  64. justify-content: space-around;
  65. flex-wrap: wrap;
  66. color: $color-text;
  67. .item {
  68. display: flex;
  69. flex-direction: column;
  70. text-align: center;
  71. margin: 10rpx 0;
  72. .sub-title {
  73. font-size: 24rpx;
  74. }
  75. .number {
  76. font-size: 50rpx;
  77. font-weight: bold;
  78. }
  79. }
  80. }
  81. &.no-title {
  82. .stats .item {
  83. width: calc(30% - 60rpx);
  84. flex-direction: column-reverse;
  85. .sub-title {
  86. font-size: 30rpx;
  87. color: $color-primary;
  88. margin-bottom: 10rpx;
  89. }
  90. }
  91. }
  92. }
  93. </style>