Browse Source

feat(self-check): 中间页展示自检趋势 AI 解读(P1-1)

iwt 2 months ago
parent
commit
26eaec6212
1 changed files with 70 additions and 2 deletions
  1. 70 2
      cfc-frontend/pages/family/self-check-entry.vue

+ 70 - 2
cfc-frontend/pages/family/self-check-entry.vue

@@ -50,6 +50,18 @@
         <text class="sce-status-text">已满 15 天,可再次自检</text>
       </view>
 
+      <!-- 趋势分析(P1-1) -->
+      <view class="sce-trend" v-if="trendLoaded">
+        <view class="sce-trend-header">
+          <text class="sce-trend-title">📈 自检趋势</text>
+          <text class="sce-trend-summary" v-if="trendSummary">{{ trendSummary }}</text>
+        </view>
+        <text class="sce-trend-insight" v-if="aiInsight">{{ aiInsight }}</text>
+        <view class="sce-trend-loading" v-if="trendLoading">
+          <text>AI 趋势分析中...</text>
+        </view>
+      </view>
+
       <!-- 按钮区域 -->
       <view class="sce-footer">
         <button v-if="canCheck && lastResult" class="sce-btn sce-btn-primary" @click="retake">
@@ -70,7 +82,7 @@
 </template>
 
 <script>
-import { getSelfCheckStatus, ignoreSelfCheck } from '@/utils/api'
+import { getSelfCheckStatus, ignoreSelfCheck, getSelfCheckTrendAnalysis } from '@/utils/api'
 import { parseDate } from '@/utils/format.js'
 
 export default {
@@ -79,7 +91,11 @@ export default {
       loading: true,
       lastResult: null,
       canCheck: false,
-      daysLeft: 0
+      daysLeft: 0,
+      trendLoaded: false,
+      trendLoading: false,
+      aiInsight: '',
+      trendSummary: ''
     }
   },
   computed: {
@@ -95,6 +111,7 @@ export default {
   },
   onLoad: function() {
     this.loadStatus()
+    this.loadTrend()
   },
   methods: {
     loadStatus: function() {
@@ -137,6 +154,21 @@ export default {
       if (!d) return ''
       var pad = function(n) { return n < 10 ? '0' + n : '' + n }
       return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate())
+    },
+    loadTrend: function() {
+      var self = this
+      this.trendLoading = true
+      getSelfCheckTrendAnalysis().then(function(res) {
+        self.trendLoading = false
+        self.trendLoaded = true
+        if (res.code === 200 && res.data) {
+          self.aiInsight = res.data.aiInsight || ''
+          self.trendSummary = res.data.trendSummary || ''
+        }
+      }).catch(function() {
+        self.trendLoading = false
+        self.trendLoaded = true
+      })
     }
   }
 }
@@ -306,4 +338,40 @@ export default {
   color: #999;
   font-weight: 400;
 }
+.sce-trend {
+  background: #fff;
+  border-radius: 24rpx;
+  padding: 30rpx 26rpx;
+  margin-bottom: 24rpx;
+  box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
+}
+.sce-trend-header {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  margin-bottom: 12rpx;
+}
+.sce-trend-title {
+  font-size: 30rpx;
+  font-weight: 600;
+  color: #333;
+}
+.sce-trend-summary {
+  font-size: 24rpx;
+  color: #F97316;
+  font-weight: 600;
+}
+.sce-trend-insight {
+  display: block;
+  font-size: 26rpx;
+  color: #555;
+  line-height: 1.6;
+}
+.sce-trend-loading {
+  padding: 10rpx 0;
+}
+.sce-trend-loading text {
+  font-size: 24rpx;
+  color: #999;
+}
 </style>