BodyWealthAlert.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 lang="scss">
  61. // antd 警示金及浅底(单页专有;vs $status-warning-2 #F59E0B / $status-warning-tint #FFFBEB 全局档)
  62. $c-antd-gold: #FAAD14;
  63. $c-antd-gold-tint: #FFFBE6;
  64. .body-wealth-alert {
  65. margin: 20rpx;
  66. padding: 24rpx;
  67. border-radius: 12rpx;
  68. border-left: 6rpx solid;
  69. background: $app-surface;
  70. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
  71. }
  72. .alert-normal {
  73. border-left-color: $status-success-3;
  74. background: $status-success-tint-3;
  75. }
  76. .alert-overdraw {
  77. border-left-color: $c-antd-gold;
  78. background: $c-antd-gold-tint;
  79. }
  80. .alert-penalty {
  81. border-left-color: $status-danger-2;
  82. background: $status-danger-tint-3;
  83. }
  84. .alert-header {
  85. display: flex;
  86. flex-direction: row;
  87. align-items: center;
  88. margin-bottom: 12rpx;
  89. }
  90. .alert-icon {
  91. font-size: 32rpx;
  92. margin-right: 12rpx;
  93. }
  94. .alert-title {
  95. font-size: 30rpx;
  96. font-weight: bold;
  97. color: $facade-text-strong;
  98. }
  99. .alert-body {
  100. margin-bottom: 12rpx;
  101. }
  102. .alert-message {
  103. font-size: 26rpx;
  104. color: $facade-text-body;
  105. line-height: 1.6;
  106. }
  107. .alert-footer {
  108. border-top: 1rpx solid rgba(0,0,0,0.1);
  109. padding-top: 12rpx;
  110. margin-top: 12rpx;
  111. }
  112. .alert-tip {
  113. font-size: 24rpx;
  114. color: $facade-text-muted;
  115. font-style: italic;
  116. }
  117. </style>