DailySummary.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view class="daily-summary" v-if="feedback" :style="{ '--font-scale': fontScale }">
  3. <view class="ds-header">
  4. <text class="ds-label">💬 健康小语</text>
  5. <text class="ds-dismiss" @click="dismiss">×</text>
  6. </view>
  7. <text class="ds-content">{{ feedback.content }}</text>
  8. <view class="ds-footer">
  9. <text class="ds-source">{{ feedback.source === 'ai_generated' ? 'AI生成' : '暖心提醒' }}</text>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. import api from '@/utils/api.js'
  15. import fontScaleMixin from '@/mixins/font-scale.js'
  16. export default {
  17. mixins: [fontScaleMixin],
  18. props: {
  19. memberId: { type: Number, default: null }
  20. },
  21. data: function() {
  22. return {
  23. feedback: null,
  24. dismissed: false
  25. }
  26. },
  27. created: function() {
  28. this.loadFeedback()
  29. },
  30. methods: {
  31. loadFeedback: function() {
  32. if (!this.memberId) return
  33. var self = this
  34. api.getTodayFeedback({ memberId: self.memberId }).then(function(res) {
  35. if (res.data && res.data.feedback) {
  36. self.feedback = res.data.feedback
  37. }
  38. }).catch(function() {
  39. // silent fail
  40. })
  41. },
  42. dismiss: function() {
  43. if (this.feedback && this.feedback.id) {
  44. api.markFeedbackRead({ id: this.feedback.id })
  45. }
  46. this.feedback = null
  47. this.$emit('dismiss')
  48. }
  49. },
  50. watch: {
  51. memberId: function() {
  52. this.feedback = null
  53. this.loadFeedback()
  54. }
  55. }
  56. }
  57. </script>
  58. <style scoped lang="scss">
  59. .daily-summary {
  60. background: linear-gradient(135deg, #EBF5FF, $tint-sky-tint);
  61. border-radius: 24rpx;
  62. padding: 20rpx 24rpx;
  63. margin: 20rpx 20rpx 0 20rpx;
  64. border: 1rpx solid $tint-sky-line;
  65. position: relative;
  66. }
  67. .ds-header {
  68. display: flex;
  69. justify-content: space-between;
  70. align-items: center;
  71. margin-bottom: 8rpx;
  72. }
  73. .ds-label { font-size: calc(24rpx * var(--font-scale, 1)); font-weight: 600; color: #0369A1; }
  74. .ds-dismiss {
  75. font-size: calc(36rpx * var(--font-scale, 1));
  76. color: $facade-text-muted;
  77. padding: 0 8rpx;
  78. line-height: 1;
  79. }
  80. .ds-dismiss:active { color: $facade-text-body; }
  81. .ds-content { font-size: calc(28rpx * var(--font-scale, 1)); color: $facade-text-strong; line-height: 1.6; }
  82. .ds-footer { margin-top: 8rpx; }
  83. .ds-source { font-size: calc(20rpx * var(--font-scale, 1)); color: $app-text-subtle; }
  84. </style>