StatsText.vue 1.7 KB

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