BodyWealthAlert.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view class="body-wealth-alert" v-if="visible" :class="statusClass">
  3. <view class="alert-header">
  4. <text class="alert-icon">{{ icon }}</text>
  5. <text class="alert-title">{{ title }}</text>
  6. </view>
  7. <view class="alert-body">
  8. <text class="alert-message">{{ message }}</text>
  9. </view>
  10. <view class="alert-footer" v-if="showTip">
  11. <text class="alert-tip">{{ tip }}</text>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. name: 'BodyWealthAlert',
  18. props: {
  19. status: {
  20. type: String,
  21. default: 'normal', // normal / overdraw / penalty
  22. validator: function(val) {
  23. return ['normal', 'overdraw', 'penalty'].indexOf(val) !== -1
  24. }
  25. },
  26. message: {
  27. type: String,
  28. default: ''
  29. },
  30. showTip: {
  31. type: Boolean,
  32. default: true
  33. }
  34. },
  35. computed: {
  36. visible() {
  37. return this.status !== 'normal'
  38. },
  39. statusClass() {
  40. return 'alert-' + this.status
  41. },
  42. icon() {
  43. if (this.status === 'overdraw') return '⚠️'
  44. if (this.status === 'penalty') return '🔒'
  45. return '✓'
  46. },
  47. title() {
  48. if (this.status === 'overdraw') return '健康透支警告'
  49. if (this.status === 'penalty') return '健康约束生效'
  50. return '健康状态正常'
  51. },
  52. tip() {
  53. if (this.status === 'overdraw') return '建议立即调整作息和饮食,恢复健康能量'
  54. if (this.status === 'penalty') return '健康能量不足将影响财富维度发展,请优先关注健康'
  55. return ''
  56. }
  57. }
  58. }
  59. </script>
  60. <style scoped>
  61. .body-wealth-alert {
  62. margin: 20rpx;
  63. padding: 24rpx;
  64. border-radius: 12rpx;
  65. border-left: 6rpx solid;
  66. background: #fff;
  67. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
  68. }
  69. .alert-normal {
  70. border-left-color: #52c41a;
  71. background: #f6ffed;
  72. }
  73. .alert-overdraw {
  74. border-left-color: #faad14;
  75. background: #fffbe6;
  76. }
  77. .alert-penalty {
  78. border-left-color: #ff4d4f;
  79. background: #fff1f0;
  80. }
  81. .alert-header {
  82. display: flex;
  83. flex-direction: row;
  84. align-items: center;
  85. margin-bottom: 12rpx;
  86. }
  87. .alert-icon {
  88. font-size: 32rpx;
  89. margin-right: 12rpx;
  90. }
  91. .alert-title {
  92. font-size: 30rpx;
  93. font-weight: bold;
  94. color: #333;
  95. }
  96. .alert-body {
  97. margin-bottom: 12rpx;
  98. }
  99. .alert-message {
  100. font-size: 26rpx;
  101. color: #666;
  102. line-height: 1.6;
  103. }
  104. .alert-footer {
  105. border-top: 1rpx solid rgba(0,0,0,0.1);
  106. padding-top: 12rpx;
  107. margin-top: 12rpx;
  108. }
  109. .alert-tip {
  110. font-size: 24rpx;
  111. color: #999;
  112. font-style: italic;
  113. }
  114. </style>