Explorar el Código

feat(frontend): report-confirm 新增报告快速分析浮层(支持 draftId)

iwt hace 6 días
padre
commit
d59d745fd1
Se han modificado 1 ficheros con 82 adiciones y 0 borrados
  1. 82 0
      cfc-frontend/pages/health/report-confirm.vue

+ 82 - 0
cfc-frontend/pages/health/report-confirm.vue

@@ -342,6 +342,42 @@
       </view>
     </view>
 
+    <!-- 报告快速分析入口(解析完成、非解析中) -->
+    <view class="quick-analyze-fab" v-if="!parsing && draftId" @tap="openQuickAnalyze">
+      <text class="quick-analyze-fab-icon">🎯</text>
+      <text class="quick-analyze-fab-text">快速分析</text>
+    </view>
+
+    <!-- 快速分析浮层 -->
+    <view class="quick-analyze-overlay" v-if="quickAnalyze.show" @tap="closeQuickAnalyze"></view>
+    <view class="quick-analyze-panel" v-if="quickAnalyze.show">
+      <view class="quick-analyze-header">
+        <text class="quick-analyze-title">报告快速分析</text>
+        <text class="quick-analyze-close" @tap="closeQuickAnalyze">✕</text>
+      </view>
+      <view class="quick-analyze-hint" v-if="quickAnalyze.usedToday">免费版今日次数已用完,升级会员解锁更多分析</view>
+      <scroll-view class="quick-analyze-messages" scroll-y>
+        <view class="quick-analyze-message" v-for="(msg, qidx) in quickAnalyze.messages" :key="qidx" :class="'msg-' + msg.role">
+          <text class="quick-analyze-msg-text">{{ msg.content }}</text>
+        </view>
+        <view class="quick-analyze-loading" v-if="quickAnalyze.sending">
+          <text class="quick-analyze-loading-text">AI 正在分析中...</text>
+        </view>
+      </scroll-view>
+      <view class="quick-analyze-chips" v-if="quickAnalyze.messages.length === 0">
+        <view class="quick-analyze-chip" v-for="(q, qi) in quickQuestions" :key="qi" @tap="sendQuickQuestion(q)">
+          <text class="quick-analyze-chip-text">{{ q }}</text>
+        </view>
+      </view>
+      <view class="quick-analyze-input-bar">
+        <input class="quick-analyze-input" v-model="quickAnalyze.inputText" placeholder="输入你想问的问题..."
+          :disabled="quickAnalyze.sending || quickAnalyze.usedToday" confirm-type="send" @confirm="sendQuickAnalyze" />
+        <view class="quick-analyze-send" :class="{ 'send-disabled': quickAnalyze.sending || quickAnalyze.usedToday }" @tap="sendQuickAnalyze">
+          <text class="quick-analyze-send-text">发送</text>
+        </view>
+      </view>
+    </view>
+
     <view class="bottom-spacer"></view>
   </view>
 </template>
@@ -589,6 +625,52 @@ export default {
     }
   },
   methods: {
+    // ===== 报告快速分析 =====
+    openQuickAnalyze: function() {
+      this.quickAnalyze.show = true
+      var self = this
+      getMyMembership().then(function(res) {
+        var level = res.data && res.data.memberLevel
+        if (level && level !== 'FREE') {
+          self.quickAnalyze.usedToday = false
+        }
+      }).catch(function() {})
+    },
+    closeQuickAnalyze: function() {
+      this.quickAnalyze.show = false
+    },
+    sendQuickQuestion: function(q) {
+      if (q && q.trim()) {
+        this.quickAnalyze.inputText = q
+        this.sendQuickAnalyze()
+      }
+    },
+    sendQuickAnalyze: function() {
+      var self = this
+      var text = (this.quickAnalyze.inputText || '').trim()
+      if (!text || this.quickAnalyze.sending) return
+      this.quickAnalyze.messages.push({ role: 'user', content: text })
+      this.quickAnalyze.inputText = ''
+      this.quickAnalyze.sending = true
+      reportQuickAnalyze(text, null, this.quickAnalyze.conversationId, this.draftId).then(function(res) {
+        if (res.code === 200 && res.data) {
+          self.quickAnalyze.messages.push({ role: 'ai', content: res.data.answer || '(无回答)' })
+          if (res.data.conversationId) {
+            self.quickAnalyze.conversationId = res.data.conversationId
+          }
+        } else {
+          var msg = res.message || '分析失败'
+          if (msg.indexOf('每日仅限') !== -1) {
+            self.quickAnalyze.usedToday = true
+          }
+          self.quickAnalyze.messages.push({ role: 'ai', content: msg })
+        }
+      }).catch(function() {
+        self.quickAnalyze.messages.push({ role: 'ai', content: 'AI 服务暂不可用,请稍后重试' })
+      }).finally(function() {
+        self.quickAnalyze.sending = false
+      })
+    },
     // 仅 draftId 模式:调用后端按草稿解析,成功后自动填充页面
     parseByDraftId() {
       var self = this