BodyWealthAlert.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view class="body-wealth-alert" v-if="visible" :class="statusClass" :style="{ '--font-scale': fontScale }">
  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. import fontScaleMixin from '@/mixins/font-scale.js'
  17. export default {
  18. mixins: [fontScaleMixin],
  19. name: 'BodyWealthAlert',
  20. props: {
  21. status: {
  22. type: String,
  23. default: 'normal', // normal / overdraw / penalty
  24. validator: function(val) {
  25. return ['normal', 'overdraw', 'penalty'].indexOf(val) !== -1
  26. }
  27. },
  28. message: {
  29. type: String,
  30. default: ''
  31. },
  32. showTip: {
  33. type: Boolean,
  34. default: true
  35. }
  36. },
  37. computed: {
  38. visible() {
  39. return this.status !== 'normal'
  40. },
  41. statusClass() {
  42. return 'alert-' + this.status
  43. },
  44. icon() {
  45. if (this.status === 'overdraw') return '⚠️'
  46. if (this.status === 'penalty') return '🔒'
  47. return '✓'
  48. },
  49. title() {
  50. if (this.status === 'overdraw') return '健康透支警告'
  51. if (this.status === 'penalty') return '健康约束生效'
  52. return '健康状态正常'
  53. },
  54. tip() {
  55. if (this.status === 'overdraw') return '建议立即调整作息和饮食,恢复健康能量'
  56. if (this.status === 'penalty') return '健康能量不足将影响财富维度发展,请优先关注健康'
  57. return ''
  58. }
  59. }
  60. }
  61. </script>
  62. <style scoped lang="scss">
  63. // antd 警示金及浅底(单页专有;vs $status-warning-2 $dim-wealth / $status-warning-tint $dim-wealth-tint 全局档)
  64. $c-antd-gold: #FAAD14;
  65. $c-antd-gold-tint: #FFFBE6;
  66. .body-wealth-alert {
  67. margin: 20rpx;
  68. padding: 24rpx;
  69. border-radius: 16rpx;
  70. border-left: 6rpx solid;
  71. background: $app-surface;
  72. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
  73. }
  74. .alert-normal {
  75. border-left-color: $status-success-3;
  76. background: $status-success-tint-3;
  77. }
  78. .alert-overdraw {
  79. border-left-color: $c-antd-gold;
  80. background: $c-antd-gold-tint;
  81. }
  82. .alert-penalty {
  83. border-left-color: $status-danger-2;
  84. background: $status-danger-tint-3;
  85. }
  86. .alert-header {
  87. display: flex;
  88. flex-direction: row;
  89. align-items: center;
  90. margin-bottom: 12rpx;
  91. }
  92. .alert-icon {
  93. font-size: calc(32rpx * var(--font-scale, 1));
  94. margin-right: 12rpx;
  95. }
  96. .alert-title {
  97. font-size: calc(30rpx * var(--font-scale, 1));
  98. font-weight: bold;
  99. color: $facade-text-strong;
  100. }
  101. .alert-body {
  102. margin-bottom: 12rpx;
  103. }
  104. .alert-message {
  105. font-size: calc(26rpx * var(--font-scale, 1));
  106. color: $facade-text-body;
  107. line-height: 1.6;
  108. }
  109. .alert-footer {
  110. border-top: 1rpx solid rgba(0,0,0,0.1);
  111. padding-top: 12rpx;
  112. margin-top: 12rpx;
  113. }
  114. .alert-tip {
  115. font-size: calc(24rpx * var(--font-scale, 1));
  116. color: $facade-text-muted;
  117. font-style: italic;
  118. }
  119. </style>