uni-stat-panel.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view class="uni-stat--sum-x mb-m">
  3. <view v-for="(item, index) in items" :key="index" class="uni-stat--sum-item"
  4. :class="[item.value === '今天' ? 'uni-stat--sum-item-width' : '']">
  5. <!-- #ifdef MP -->
  6. <view class="uni-stat--sum-item-title">
  7. {{item.title ? item.title : ''}}
  8. </view>
  9. <!-- #endif -->
  10. <!-- #ifndef MP -->
  11. <uni-tooltip>
  12. <view class="uni-stat--sum-item-title">
  13. {{item.title ? item.title : ''}}
  14. <uni-icons v-if="item.title" class="ml-s" type="help" color="#666" />
  15. </view>
  16. <template v-if="item.tooltip" v-slot:content>
  17. <view class="uni-stat-tooltip-s">
  18. {{item.tooltip}}
  19. </view>
  20. </template>
  21. </uni-tooltip>
  22. <!-- #endif -->
  23. <view class="uni-stat--sum-item-value">{{item.value ? item.value : 0}}</view>
  24. <view v-if="contrast" class="uni-stat--sum-item-contrast">{{item.contrast ? item.contrast : 0}}</view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. name: "uni-stat-panel",
  31. data() {
  32. return {
  33. };
  34. },
  35. props: {
  36. items: {
  37. type: Array,
  38. default: () => {
  39. return []
  40. }
  41. },
  42. contrast: {
  43. type: Boolean,
  44. default: false
  45. }
  46. }
  47. }
  48. </script>
  49. <style lang="scss">
  50. .uni-stat-tooltip-s {
  51. width: 160px;
  52. white-space: normal;
  53. }
  54. .uni-stat--sum {
  55. &-x {
  56. display: flex;
  57. justify-content: space-evenly;
  58. flex-wrap: wrap;
  59. border-radius: 4px;
  60. padding: 15px;
  61. box-shadow: -1px -1px 5px 0 rgba(0, 0, 0, 0.1);
  62. }
  63. &-item {
  64. white-space: nowrap;
  65. text-align: center;
  66. margin: 10px 18px;
  67. &-width {
  68. width: 100px
  69. }
  70. }
  71. &-item-title {
  72. display: flex;
  73. align-items: center;
  74. justify-content: center;
  75. min-height: 17px;
  76. font-size: 12px;
  77. color: #666;
  78. }
  79. &-item-value {
  80. font-size: 24px;
  81. line-height: 48px;
  82. font-weight: 700;
  83. color: #333;
  84. }
  85. &-item-contrast {
  86. font-size: 14px;
  87. color: #666;
  88. }
  89. }
  90. /* #ifndef APP-NVUE */
  91. @media screen and (max-width: 500px) {
  92. .uni-stat--sum-x {
  93. padding: 15px 0;
  94. justify-content: space-between;
  95. flex-wrap: unset;
  96. overflow-x: auto !important;
  97. }
  98. ::-webkit-scrollbar {
  99. display: none;
  100. }
  101. }
  102. /* #endif */
  103. </style>