DailySummary.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <view class="daily-summary" v-if="feedback">
  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. export default {
  16. props: {
  17. childId: { type: Number, default: null }
  18. },
  19. data: function() {
  20. return {
  21. feedback: null,
  22. dismissed: false
  23. }
  24. },
  25. created: function() {
  26. this.loadFeedback()
  27. },
  28. methods: {
  29. loadFeedback: function() {
  30. if (!this.childId) return
  31. var self = this
  32. api.getTodayFeedback({ childId: self.childId }).then(function(res) {
  33. if (res.data && res.data.feedback) {
  34. self.feedback = res.data.feedback
  35. }
  36. }).catch(function() {
  37. // silent fail
  38. })
  39. },
  40. dismiss: function() {
  41. if (this.feedback && this.feedback.id) {
  42. api.markFeedbackRead({ id: this.feedback.id })
  43. }
  44. this.feedback = null
  45. this.$emit('dismiss')
  46. }
  47. },
  48. watch: {
  49. childId: function() {
  50. this.feedback = null
  51. this.loadFeedback()
  52. }
  53. }
  54. }
  55. </script>
  56. <style scoped>
  57. .daily-summary {
  58. background: linear-gradient(135deg, #EBF5FF, #E0F2FE);
  59. border-radius: 20rpx;
  60. padding: 20rpx 24rpx;
  61. margin: 20rpx 20rpx 0 20rpx;
  62. border: 1rpx solid #BAE6FD;
  63. position: relative;
  64. }
  65. .ds-header {
  66. display: flex;
  67. justify-content: space-between;
  68. align-items: center;
  69. margin-bottom: 8rpx;
  70. }
  71. .ds-label { font-size: 24rpx; font-weight: 600; color: #0369A1; }
  72. .ds-dismiss {
  73. font-size: 36rpx;
  74. color: #999;
  75. padding: 0 8rpx;
  76. line-height: 1;
  77. }
  78. .ds-dismiss:active { color: #666; }
  79. .ds-content { font-size: 28rpx; color: #333; line-height: 1.6; }
  80. .ds-footer { margin-top: 8rpx; }
  81. .ds-source { font-size: 20rpx; color: #94A3B8; }
  82. </style>