GrowCard.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div class="grow-card">
  3. <div class="grow-card-header">
  4. <div class="grow-card__info">
  5. <p class="grow-card__title">
  6. {{ info.title }}
  7. </p>
  8. <CountTo prefix="$" :startVal="1" :endVal="info.price" />
  9. </div>
  10. <img :src="info.icon" />
  11. </div>
  12. <div class="grow-card-footer" :class="{ 'is-up': info.up }">
  13. <Statistic :value="info.percent">
  14. <template #prefix>
  15. <img :src="info.up ? riseSvg : downSvg" />
  16. </template>
  17. </Statistic>
  18. <span class="grow-card__mom">{{ info.mom }}</span>
  19. </div>
  20. </div>
  21. </template>
  22. <script lang="ts">
  23. import { defineComponent, PropType } from 'vue';
  24. import { Statistic } from 'ant-design-vue';
  25. import { CountTo } from '/@/components/CountTo/index';
  26. import riseSvg from '/@/assets/svg/dashboard/analysis-rise.svg';
  27. import downSvg from '/@/assets/svg/dashboard/analysis-down.svg';
  28. import { GrowCardItem } from '../types';
  29. export default defineComponent({
  30. components: { Statistic, CountTo },
  31. props: {
  32. info: {
  33. type: Object as PropType<GrowCardItem>,
  34. default: null,
  35. },
  36. },
  37. setup() {
  38. return {
  39. riseSvg,
  40. downSvg,
  41. };
  42. },
  43. });
  44. </script>
  45. <style lang="less">
  46. .grow-card {
  47. display: flex;
  48. width: calc(100% - 12px);
  49. height: 158px;
  50. padding: 16px 16px 12px 16px;
  51. // margin: 0 12px 12px 12px;
  52. cursor: pointer;
  53. background: @white;
  54. border-radius: 4px;
  55. box-shadow: 6px 6px 54px 0 rgba(0, 0, 0, 0.05);
  56. flex-direction: column;
  57. &:hover {
  58. box-shadow: 6px 6px 54px 0 rgba(0, 0, 0, 0.1);
  59. }
  60. &-header {
  61. display: flex;
  62. width: 100%;
  63. justify-content: space-between;
  64. }
  65. &__title {
  66. font-family: PingFangSC-Regular;
  67. font-size: 16px;
  68. letter-spacing: 0;
  69. color: @text-color-base;
  70. opacity: 0.7;
  71. }
  72. &__info {
  73. span {
  74. font-family: NeoSans;
  75. font-size: 26px;
  76. line-height: 38px;
  77. }
  78. }
  79. &-footer {
  80. display: flex;
  81. width: 100%;
  82. margin-top: 24px;
  83. align-items: center;
  84. .ant-statistic-content-value {
  85. color: @error-color;
  86. }
  87. .ant-statistic-content-prefix svg {
  88. width: 0.98rem !important;
  89. height: 0.98rem !important;
  90. }
  91. &.is-up {
  92. .ant-statistic-content-value {
  93. color: @success-color;
  94. }
  95. }
  96. }
  97. &__mom {
  98. display: inline-block;
  99. padding-left: 10px;
  100. font-family: PingFangSC-Regular;
  101. font-size: 12px;
  102. line-height: 22px;
  103. letter-spacing: 0;
  104. color: #606060;
  105. }
  106. }
  107. </style>