HealthAlertBanner.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="alert-banner" v-if="alerts && alerts.length > 0">
  3. <view
  4. class="alert-item"
  5. v-for="alert in visibleAlerts"
  6. :key="alert.id"
  7. :class="'alert-severity-' + alert.severity">
  8. <view class="alert-icon">
  9. <text v-if="alert.severity === 'high'">🔴</text>
  10. <text v-else-if="alert.severity === 'medium'">🟡</text>
  11. <text v-else>🟢</text>
  12. </view>
  13. <view class="alert-body">
  14. <text class="alert-text">{{ alert.alertText }}</text>
  15. <text class="alert-suggestion" v-if="alert.actionSuggestion">
  16. {{ alert.actionSuggestion }}
  17. </text>
  18. </view>
  19. <text class="alert-dismiss" @click="dismiss(alert)">×</text>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. props: {
  26. alerts: { type: Array, default: function() { return [] } }
  27. },
  28. computed: {
  29. visibleAlerts: function() {
  30. return this.alerts.slice(0, 2)
  31. }
  32. },
  33. methods: {
  34. dismiss: function(alert) {
  35. this.$emit('dismiss', alert.id)
  36. }
  37. }
  38. }
  39. </script>
  40. <style scoped>
  41. .alert-banner {
  42. margin: 0 20rpx 16rpx 20rpx;
  43. display: flex;
  44. flex-direction: column;
  45. gap: 8rpx;
  46. }
  47. .alert-item {
  48. display: flex;
  49. align-items: flex-start;
  50. gap: 12rpx;
  51. padding: 16rpx;
  52. border-radius: 16rpx;
  53. position: relative;
  54. }
  55. .alert-severity-high {
  56. background: #FEF2F2;
  57. border: 1rpx solid #FECACA;
  58. }
  59. .alert-severity-medium {
  60. background: #FFFBEB;
  61. border: 1rpx solid #FDE68A;
  62. }
  63. .alert-severity-low {
  64. background: #F0F9FF;
  65. border: 1rpx solid #BAE6FD;
  66. }
  67. .alert-icon { font-size: 36rpx; flex-shrink: 0; padding-top: 2rpx; }
  68. .alert-body { flex: 1; min-width: 0; }
  69. .alert-text { font-size: 26rpx; font-weight: 600; color: #1E293B; line-height: 1.4; }
  70. .alert-suggestion {
  71. display: block;
  72. font-size: 22rpx;
  73. color: #64748B;
  74. margin-top: 4rpx;
  75. line-height: 1.4;
  76. }
  77. .alert-dismiss {
  78. font-size: 36rpx;
  79. color: #94A3B8;
  80. padding: 0 8rpx;
  81. line-height: 1;
  82. flex-shrink: 0;
  83. }
  84. .alert-dismiss:active { color: #64748B; }
  85. </style>