DetailItem.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view class="detail-item">
  3. <view class="item-left">
  4. <view class="item-left-top">
  5. <text>{{ monthDay }}</text>
  6. <text>{{ weekday }}</text>
  7. </view>
  8. <view class="item-left-bottom">
  9. <text>{{ detailData.orderCount }} 单</text>
  10. <text> · </text>
  11. <text>{{ detailData.online }} 小时</text>
  12. </view>
  13. </view>
  14. <view class="item-right">
  15. <view class="item-right-top">¥{{ detailData.total }}</view>
  16. <view class="item-right-bottom" :style="{ color: detailData.sign === '-' ? '#F56C6C' : '#00C18A' }">{{ detailData.sign }}{{ detailData.ratio }}%</view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import { formatToMonthDay, getWeekday } from '@/utils/dateUtil.js'
  22. export default {
  23. name: 'DetailItem',
  24. props: {
  25. detailData: {
  26. type: Object,
  27. default: () => {
  28. return {
  29. date: '2025-05-23',
  30. orderCount: 87,
  31. online: 8.5,
  32. total: 428.50,
  33. sign: '-',
  34. ratio: 12.5
  35. }
  36. }
  37. },
  38. },
  39. data() {
  40. return {}
  41. },
  42. computed: {
  43. monthDay() {
  44. const date = new Date(this.detailData.date)
  45. return formatToMonthDay(date)
  46. },
  47. weekday() {
  48. const date = new Date(this.detailData.date)
  49. return getWeekday(date)
  50. }
  51. },
  52. methods: {},
  53. }
  54. </script>
  55. <style lang="scss">
  56. .detail-item {
  57. padding: 12rpx 0;
  58. border-bottom: 1px solid #E4E7ED;
  59. display: flex;
  60. justify-content: space-between;
  61. .item-left {
  62. display: flex;
  63. flex-direction: column;
  64. align-items: flex-start;
  65. .item-left-top {
  66. font-size: 28rpx;
  67. line-height: 42rpx;
  68. color: #333333;
  69. font-weight: 500;
  70. }
  71. .item-left-bottom {
  72. font-size: 24rpx;
  73. line-height: 32rpx;
  74. color: #999999;
  75. }
  76. }
  77. .item-right {
  78. display: flex;
  79. flex-direction: column;
  80. align-items: flex-end;
  81. .item-right-top {
  82. font-weight: 700;
  83. color: #333333;
  84. font-size: 28rpx;
  85. line-height: 42rpx;
  86. }
  87. .item-right-bottom {
  88. font-weight: 500;
  89. font-size: 24rpx;
  90. line-height: 32rpx;
  91. }
  92. }
  93. }
  94. </style>