更新
This commit is contained in:
@@ -47,21 +47,7 @@
|
||||
|
||||
<view class="st-main">
|
||||
<!-- 1. 录入今日血糖 -->
|
||||
<view class="st-cta" @click="openInputForm()">
|
||||
<TongjiIcon name="plus" size="md" color="#FFFFFF" />
|
||||
<text>录入今日血糖</text>
|
||||
</view>
|
||||
|
||||
<view class="st-game-entry" @click="goGamePage">
|
||||
<view class="st-game-entry-icon">
|
||||
<TongjiIcon name="activity" size="md" color="#006c49" />
|
||||
</view>
|
||||
<view class="st-game-entry-body">
|
||||
<text class="st-game-entry-title">糖分突袭</text>
|
||||
<text class="st-game-entry-sub">消除棋盘食物,边玩边学控糖</text>
|
||||
</view>
|
||||
<TongjiIcon name="chevron-right" size="sm" color="#64748b" />
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 2. 血糖趋势 -->
|
||||
<view v-if="diagnosisId" class="st-chart-card">
|
||||
@@ -134,6 +120,21 @@
|
||||
</cover-view>
|
||||
</cover-view>
|
||||
</view>
|
||||
<view class="st-cta" @click="openInputForm()">
|
||||
<TongjiIcon name="plus" size="md" color="#FFFFFF" />
|
||||
<text>录入今日血糖</text>
|
||||
</view>
|
||||
|
||||
<view class="st-game-entry" @click="goGamePage">
|
||||
<view class="st-game-entry-icon">
|
||||
<TongjiIcon name="activity" size="md" color="#006c49" />
|
||||
</view>
|
||||
<view class="st-game-entry-body">
|
||||
<text class="st-game-entry-title">糖分突袭</text>
|
||||
<text class="st-game-entry-sub">消除棋盘食物,边玩边学控糖</text>
|
||||
</view>
|
||||
<TongjiIcon name="chevron-right" size="sm" color="#64748b" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 3. 最新测量 & 概览 -->
|
||||
@@ -237,12 +238,21 @@
|
||||
class="st-float-input"
|
||||
type="text"
|
||||
:value="dietAiAskText"
|
||||
placeholder="输入食物名称或健康疑问,咨询 AI..."
|
||||
placeholder="长按麦克风说话,或输入文字咨询 AI..."
|
||||
placeholder-class="st-float-placeholder"
|
||||
confirm-type="send"
|
||||
@input="onDietAiAskInput"
|
||||
@confirm="askDietAiFood"
|
||||
/>
|
||||
<view
|
||||
class="st-float-mic"
|
||||
:class="{ listening: sttListening || sttHolding, disabled: dietAiAsking || !sttSupported }"
|
||||
@touchstart.stop.prevent="onDietAiSpeechStart"
|
||||
@touchend.stop.prevent="onDietAiSpeechEnd"
|
||||
@touchcancel.stop.prevent="onDietAiSpeechEnd"
|
||||
>
|
||||
<TongjiIcon name="mic" size="sm" :color="(sttListening || sttHolding) ? '#ffffff' : '#006c49'" />
|
||||
</view>
|
||||
<view
|
||||
class="st-float-send"
|
||||
:class="{ disabled: dietAiAsking }"
|
||||
@@ -251,6 +261,9 @@
|
||||
<TongjiIcon name="send" size="sm" color="#ffffff" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="sttHolding && !dietAiAsking" class="st-float-hold-hint">
|
||||
<text>{{ sttListening ? '松手结束' : '准备录音…' }}</text>
|
||||
</view>
|
||||
<view v-if="dietAiAsking || dietAiAskResult.advice" class="st-float-result">
|
||||
<view v-if="dietAiAskResult.level_label" class="st-float-badge">
|
||||
<text>{{ dietAiAskResult.level_label }}</text>
|
||||
@@ -419,6 +432,7 @@ import { onLoad, onShow, onHide, onUnload, onPullDownRefresh, onShareAppMessage
|
||||
import SugarTreeGraphic from '../components/SugarTreeGraphic.vue'
|
||||
import TongjiIcon from '../components/TongjiIcon.vue'
|
||||
import { useDietAi } from '../composables/useDietAi.js'
|
||||
import { useSpeechToText } from '../composables/useSpeechToText.js'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
@@ -487,6 +501,30 @@ const {
|
||||
openDietForm
|
||||
} = useDietAi(proxy, { diagnosisId, showUserToast, formatUserMessage })
|
||||
|
||||
const {
|
||||
sttListening,
|
||||
sttHolding,
|
||||
sttSupported,
|
||||
beginHoldSpeech,
|
||||
endHoldSpeech,
|
||||
stopSpeechToText
|
||||
} = useSpeechToText({
|
||||
onResult(text) {
|
||||
const prev = String(dietAiAskText.value || '').trim()
|
||||
dietAiAskText.value = prev ? `${prev} ${text}` : text
|
||||
},
|
||||
showToast: (msg) => showUserToast(msg)
|
||||
})
|
||||
|
||||
function onDietAiSpeechStart() {
|
||||
if (dietAiAsking.value) return
|
||||
beginHoldSpeech()
|
||||
}
|
||||
|
||||
function onDietAiSpeechEnd() {
|
||||
endHoldSpeech()
|
||||
}
|
||||
|
||||
/** AI 饮食建议依据:近7天 / 近30天 血糖统计 */
|
||||
const dietAnalysisList = computed(() => {
|
||||
const list = dietAiRecommend.value && Array.isArray(dietAiRecommend.value.analysis)
|
||||
@@ -2495,10 +2533,12 @@ onPullDownRefresh(async () => {
|
||||
|
||||
onHide(() => {
|
||||
ttsStop()
|
||||
stopSpeechToText()
|
||||
})
|
||||
|
||||
onUnload(() => {
|
||||
ttsStop()
|
||||
stopSpeechToText()
|
||||
})
|
||||
|
||||
// ============ 邀请观看(家人分享页)============
|
||||
|
||||
Reference in New Issue
Block a user