HealthTimeline.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view class="timeline" v-if="events && events.length > 0">
  3. <view class="timeline-title">📖 我的健康故事</view>
  4. <view class="timeline-list">
  5. <view class="timeline-item" v-for="(evt, idx) in events" :key="evt.id">
  6. <view class="timeline-dot" :class="'dot-' + (idx % 5)"></view>
  7. <view class="timeline-line" v-if="idx < events.length - 1"></view>
  8. <view class="timeline-content">
  9. <text class="timeline-text">{{ evt.eventText }}</text>
  10. <text class="timeline-date">{{ formatDate(evt.eventDate) }}</text>
  11. </view>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. props: {
  19. events: { type: Array, default: function() { return [] } }
  20. },
  21. methods: {
  22. formatDate: function(dateStr) {
  23. if (!dateStr) return ''
  24. return dateStr.slice(0, 10)
  25. }
  26. }
  27. }
  28. </script>
  29. <style scoped>
  30. .timeline {
  31. padding: 0 20rpx;
  32. margin-bottom: 32rpx;
  33. }
  34. .timeline-title {
  35. font-size: 28rpx;
  36. font-weight: 700;
  37. color: #1E293B;
  38. margin-bottom: 16rpx;
  39. }
  40. .timeline-list { position: relative; padding-left: 20rpx; }
  41. .timeline-item {
  42. display: flex;
  43. align-items: flex-start;
  44. gap: 16rpx;
  45. position: relative;
  46. padding-bottom: 24rpx;
  47. }
  48. .timeline-dot {
  49. width: 20rpx;
  50. height: 20rpx;
  51. border-radius: 50%;
  52. flex-shrink: 0;
  53. margin-top: 6rpx;
  54. z-index: 1;
  55. }
  56. .dot-0 { background: #10B981; }
  57. .dot-1 { background: #F59E0B; }
  58. .dot-2 { background: #6366F1; }
  59. .dot-3 { background: #F97316; }
  60. .dot-4 { background: #FF6B9D; }
  61. .timeline-line {
  62. position: absolute;
  63. left: 9rpx;
  64. top: 26rpx;
  65. bottom: 0;
  66. width: 2rpx;
  67. background: #E2E8F0;
  68. }
  69. .timeline-content { flex: 1; min-width: 0; }
  70. .timeline-text {
  71. font-size: 26rpx;
  72. color: #334155;
  73. line-height: 1.5;
  74. }
  75. .timeline-date {
  76. font-size: 20rpx;
  77. color: #94A3B8;
  78. margin-top: 4rpx;
  79. display: block;
  80. }
  81. </style>