feat: 更新 AI 页面与个人资料菜单
- 修改 AI 页面标题为 "AI 建议" 和 "AI 总结" - 在个人资料页面添加 AI 建议和总结的导航项 - 优化 AI 页面结构,移除不必要的加载状态和元素 - 更新样式以提升用户体验
This commit is contained in:
+7
-1
@@ -21,7 +21,13 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/ai/index",
|
"path": "pages/ai/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "AI戒烟助手"
|
"navigationBarTitleText": "AI 建议"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/ai-summary/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "AI 总结"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,405 @@
|
|||||||
|
<template>
|
||||||
|
<view class="page">
|
||||||
|
<view class="status-bar" :style="{ height: statusBarHeight + 'px' }"></view>
|
||||||
|
<view class="container">
|
||||||
|
<view class="hero-card">
|
||||||
|
<text class="hero-label">AI 总结</text>
|
||||||
|
<text class="hero-title">按日期生成复盘</text>
|
||||||
|
<text class="hero-desc">选择任意历史日期,生成当日抽烟总结、关键发现和次日建议。</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="toolbar-card">
|
||||||
|
<picker mode="date" :value="selectedDate" :end="today" @change="handleDateChange">
|
||||||
|
<view class="date-picker">
|
||||||
|
<text class="date-picker-label">总结日期</text>
|
||||||
|
<text class="date-picker-value">{{ selectedDate }}</text>
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
<view class="primary-btn" @tap="handleGenerateSummary">
|
||||||
|
<text class="primary-btn-text">{{ summaryLoading ? '生成中...' : actionText }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-if="summaryLoading" class="summary-card loading-card">
|
||||||
|
<text class="loading-text">AI 正在分析 {{ selectedDate }} 的数据...</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-else-if="summaryData" class="summary-card">
|
||||||
|
<text class="summary-date">{{ summaryData.date }}</text>
|
||||||
|
<text class="summary-text">{{ parsedSummary.summary }}</text>
|
||||||
|
|
||||||
|
<view class="highlights-card" v-if="parsedSummary.highlights && parsedSummary.highlights.length">
|
||||||
|
<text class="block-title">关键发现</text>
|
||||||
|
<view class="highlight-item" v-for="(item, idx) in parsedSummary.highlights" :key="idx">
|
||||||
|
<text class="highlight-dot">·</text>
|
||||||
|
<text class="highlight-text">{{ item }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="suggestion-card" v-if="parsedSummary.suggestion">
|
||||||
|
<text class="block-title">明日建议</text>
|
||||||
|
<text class="suggestion-text">{{ parsedSummary.suggestion }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-else class="summary-card empty-card">
|
||||||
|
<text class="empty-title">{{ emptyTitle }}</text>
|
||||||
|
<text class="empty-desc">{{ emptyDesc }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
|
import * as api from '@/api'
|
||||||
|
import { useLogin } from '@/hooks/useLogin'
|
||||||
|
|
||||||
|
const { waitForLogin } = useLogin()
|
||||||
|
const rewardAdUnitId = 'adunit-36e13d77e185f757'
|
||||||
|
|
||||||
|
const statusBarHeight = ref(0)
|
||||||
|
const homeData = ref(null)
|
||||||
|
const selectedDate = ref(formatLocalDate())
|
||||||
|
const summaryLoading = ref(false)
|
||||||
|
const summaryData = ref(null)
|
||||||
|
const summaryState = ref('empty')
|
||||||
|
|
||||||
|
const today = computed(() => formatLocalDate())
|
||||||
|
const actionText = computed(() => (summaryData.value ? '刷新' : '生成'))
|
||||||
|
const parsedSummary = computed(() => parseSummaryContent(summaryData.value?.content))
|
||||||
|
const emptyTitle = computed(() => {
|
||||||
|
if (summaryState.value === 'locked') return '当前日期尚未解锁'
|
||||||
|
if (summaryState.value === 'no_data') return '当天还没有可总结的记录'
|
||||||
|
if (summaryState.value === 'unavailable') return 'AI 服务暂时不可用'
|
||||||
|
return '还没有生成总结'
|
||||||
|
})
|
||||||
|
const emptyDesc = computed(() => {
|
||||||
|
if (summaryState.value === 'locked') return '完成激励广告后可生成该日期的 AI 总结。'
|
||||||
|
if (summaryState.value === 'no_data') return '先确认当天是否有抽烟记录,再重新生成。'
|
||||||
|
if (summaryState.value === 'unavailable') return '稍后重试,或查看后端日志里的提示词和输入数据。'
|
||||||
|
return '选择日期后点击生成,系统会结合当天记录做总结。'
|
||||||
|
})
|
||||||
|
|
||||||
|
function formatLocalDate(date = new Date()) {
|
||||||
|
const y = date.getFullYear()
|
||||||
|
const m = String(date.getMonth() + 1).padStart(2, '0')
|
||||||
|
const d = String(date.getDate()).padStart(2, '0')
|
||||||
|
return `${y}-${m}-${d}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractJSONObject(text = '') {
|
||||||
|
const start = text.indexOf('{')
|
||||||
|
const end = text.lastIndexOf('}')
|
||||||
|
if (start === -1 || end === -1 || end <= start) return ''
|
||||||
|
return text.slice(start, end + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseSummaryContent(content = '') {
|
||||||
|
if (!content) return {}
|
||||||
|
const jsonText = extractJSONObject(content)
|
||||||
|
if (jsonText) {
|
||||||
|
try {
|
||||||
|
return JSON.parse(jsonText)
|
||||||
|
} catch (e) {
|
||||||
|
console.error('parseSummaryContent json error:', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
summary: content,
|
||||||
|
highlights: [],
|
||||||
|
suggestion: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchHomeData() {
|
||||||
|
const res = await api.getHome()
|
||||||
|
homeData.value = res.data || {}
|
||||||
|
if (selectedDate.value === today.value && homeData.value?.daily_summary?.status === 'available') {
|
||||||
|
summaryData.value = homeData.value.daily_summary
|
||||||
|
summaryState.value = 'available'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDateChange(event) {
|
||||||
|
selectedDate.value = event.detail.value
|
||||||
|
if (selectedDate.value === today.value && homeData.value?.daily_summary?.status === 'available') {
|
||||||
|
summaryData.value = homeData.value.daily_summary
|
||||||
|
summaryState.value = 'available'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
summaryData.value = null
|
||||||
|
summaryState.value = 'empty'
|
||||||
|
}
|
||||||
|
|
||||||
|
async function runRewardedUnlock(onUnlocked) {
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
try {
|
||||||
|
const videoAd = wx.createRewardedVideoAd({
|
||||||
|
adUnitId: rewardAdUnitId
|
||||||
|
})
|
||||||
|
videoAd.onClose(async (res) => {
|
||||||
|
if (res && res.isEnded) {
|
||||||
|
await onUnlocked()
|
||||||
|
} else {
|
||||||
|
uni.showToast({ title: '需要看完广告哦', icon: 'none' })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
videoAd.onError(async () => {
|
||||||
|
await onUnlocked()
|
||||||
|
})
|
||||||
|
await videoAd.show().catch(async () => {
|
||||||
|
await videoAd.load()
|
||||||
|
await videoAd.show()
|
||||||
|
})
|
||||||
|
return
|
||||||
|
} catch (e) {
|
||||||
|
await onUnlocked()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
// #ifndef MP-WEIXIN
|
||||||
|
await onUnlocked()
|
||||||
|
// #endif
|
||||||
|
}
|
||||||
|
|
||||||
|
async function unlockSummaryDate() {
|
||||||
|
try {
|
||||||
|
await api.unlockAiAdvice({ date: selectedDate.value })
|
||||||
|
} catch (e) {
|
||||||
|
console.error('unlockSummaryDate error:', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchSummaryByDate() {
|
||||||
|
summaryLoading.value = true
|
||||||
|
try {
|
||||||
|
const res = await api.getAIDailySummary({ date: selectedDate.value })
|
||||||
|
const data = res.data || {}
|
||||||
|
summaryData.value = {
|
||||||
|
date: data.date || selectedDate.value,
|
||||||
|
content: data.content || '',
|
||||||
|
model: data.model || '',
|
||||||
|
status: 'available'
|
||||||
|
}
|
||||||
|
summaryState.value = 'available'
|
||||||
|
if (selectedDate.value === today.value && homeData.value) {
|
||||||
|
homeData.value.daily_summary = summaryData.value
|
||||||
|
}
|
||||||
|
uni.showToast({ title: '总结已生成', icon: 'success' })
|
||||||
|
} catch (e) {
|
||||||
|
console.error('fetchSummaryByDate error:', e)
|
||||||
|
const msg = e?.data?.message || '生成失败,请稍后重试'
|
||||||
|
if (msg.includes('解锁')) {
|
||||||
|
summaryState.value = 'locked'
|
||||||
|
} else if (msg.includes('没有抽烟记录')) {
|
||||||
|
summaryState.value = 'no_data'
|
||||||
|
} else {
|
||||||
|
summaryState.value = 'unavailable'
|
||||||
|
}
|
||||||
|
summaryData.value = null
|
||||||
|
uni.showToast({ title: msg, icon: 'none' })
|
||||||
|
} finally {
|
||||||
|
summaryLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleGenerateSummary() {
|
||||||
|
if (summaryLoading.value) return
|
||||||
|
if (summaryData.value) {
|
||||||
|
await fetchSummaryByDate()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await runRewardedUnlock(async () => {
|
||||||
|
await unlockSummaryDate()
|
||||||
|
await fetchSummaryByDate()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onShow(async () => {
|
||||||
|
try {
|
||||||
|
const systemInfo = uni.getSystemInfoSync()
|
||||||
|
statusBarHeight.value = systemInfo.statusBarHeight || 0
|
||||||
|
await waitForLogin()
|
||||||
|
await fetchHomeData()
|
||||||
|
} catch (e) {
|
||||||
|
console.error('ai summary onShow error:', e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.page {
|
||||||
|
min-height: 100vh;
|
||||||
|
background: linear-gradient(to bottom, #D1FAE5 0%, #F0FDF4 45%, #FFFFFF 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-bar {
|
||||||
|
background: linear-gradient(to bottom, #D1FAE5, #E9FDF2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
padding: 24rpx 32rpx 80rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-card,
|
||||||
|
.toolbar-card,
|
||||||
|
.summary-card,
|
||||||
|
.highlights-card,
|
||||||
|
.suggestion-card {
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
border-radius: 28rpx;
|
||||||
|
border: 2rpx solid #D9FBE7;
|
||||||
|
box-shadow: 0 10rpx 24rpx rgba(16, 185, 129, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-card {
|
||||||
|
padding: 32rpx;
|
||||||
|
margin-bottom: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-label {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #059669;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-title {
|
||||||
|
font-size: 42rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #111827;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-desc {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #6B7280;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar-card {
|
||||||
|
padding: 24rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 20rpx;
|
||||||
|
margin-bottom: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-picker {
|
||||||
|
flex: 1;
|
||||||
|
padding: 18rpx 22rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
background: #F0FDF4;
|
||||||
|
border: 2rpx solid #D1FAE5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-picker-label {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #6B7280;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 6rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-picker-value {
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
|
||||||
|
.primary-btn {
|
||||||
|
padding: 14rpx 24rpx;
|
||||||
|
border-radius: 999rpx;
|
||||||
|
background: linear-gradient(135deg, #34D399, #10B981);
|
||||||
|
}
|
||||||
|
|
||||||
|
.primary-btn-text {
|
||||||
|
font-size: 22rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-card {
|
||||||
|
padding: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-card {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-text {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #6B7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-date {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #059669;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-text {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #111827;
|
||||||
|
line-height: 1.7;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlights-card,
|
||||||
|
.suggestion-card {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
padding: 22rpx;
|
||||||
|
background-color: #F9FFFB;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block-title {
|
||||||
|
font-size: 24rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #059669;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 8rpx;
|
||||||
|
margin-bottom: 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-item:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-dot {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #10B981;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-text,
|
||||||
|
.suggestion-text,
|
||||||
|
.empty-desc {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #374151;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-card {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-title {
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #111827;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 12rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
+282
-646
File diff suppressed because it is too large
Load Diff
+12
-519
@@ -41,43 +41,11 @@
|
|||||||
<text class="timer-label">距上次抽烟</text>
|
<text class="timer-label">距上次抽烟</text>
|
||||||
<text class="timer-value">{{ timerDisplay }}</text>
|
<text class="timer-value">{{ timerDisplay }}</text>
|
||||||
<view class="next-time" v-if="nextSmokeTimeText">
|
<view class="next-time" v-if="nextSmokeTimeText">
|
||||||
<text class="next-time-source" v-if="suggestionSource === 'ai'">AI</text>
|
|
||||||
<text class="next-time-text">✨ 下次建议: {{ nextSmokeTimeText }}</text>
|
<text class="next-time-text">✨ 下次建议: {{ nextSmokeTimeText }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="ai-btn-wrap" v-if="suggestionSource !== 'ai'">
|
|
||||||
<view class="ai-suggest-btn" @tap="handleAISuggest">
|
|
||||||
<text class="ai-suggest-icon">🤖</text>
|
|
||||||
<text class="ai-suggest-text">{{ aiLoading ? '生成中...' : 'AI 建议' }}</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- AI 今日计划卡片 -->
|
|
||||||
<view class="ai-plan-card" v-if="aiTimeNodes.length > 0">
|
|
||||||
<view class="ai-plan-header">
|
|
||||||
<text class="ai-plan-title">🤖 今日 AI 计划</text>
|
|
||||||
<view class="ai-plan-refresh" @tap="handleAISuggest">
|
|
||||||
<text class="ai-plan-refresh-text">{{ aiLoading ? '刷新中...' : '刷新' }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="ai-plan-timeline">
|
|
||||||
<view
|
|
||||||
class="ai-plan-node"
|
|
||||||
v-for="(node, idx) in aiTimeNodesWithStatus"
|
|
||||||
:key="idx"
|
|
||||||
:class="{ 'node-past': node.status === 'past', 'node-current': node.status === 'current', 'node-future': node.status === 'future' }"
|
|
||||||
>
|
|
||||||
<view class="node-dot"></view>
|
|
||||||
<text class="node-time">{{ node.time }}</text>
|
|
||||||
<view class="node-line" v-if="idx < aiTimeNodesWithStatus.length - 1"></view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="ai-plan-advice" v-if="aiAdvice">
|
|
||||||
<text class="ai-plan-advice-text">{{ aiAdvice }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="stats-row">
|
<view class="stats-row">
|
||||||
<view class="stat-card">
|
<view class="stat-card">
|
||||||
@@ -116,36 +84,6 @@
|
|||||||
<text>想抽忍住了</text>
|
<text>想抽忍住了</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 今日 AI 总结卡片 -->
|
|
||||||
<view class="ai-summary-card">
|
|
||||||
<view class="ai-summary-header">
|
|
||||||
<text class="ai-summary-title">🤖 今日 AI 总结</text>
|
|
||||||
<view class="ai-summary-action" @tap="handleDailySummary" v-if="dailySummaryData">
|
|
||||||
<text class="ai-summary-action-text">{{ summaryLoading ? '刷新中...' : '刷新' }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view v-if="summaryLoading" class="ai-summary-loading">
|
|
||||||
<text class="ai-summary-loading-text">AI 正在分析今日数据...</text>
|
|
||||||
</view>
|
|
||||||
<view v-else-if="dailySummaryData" class="ai-summary-body">
|
|
||||||
<text class="ai-summary-text">{{ parsedSummary.summary }}</text>
|
|
||||||
<view class="ai-summary-highlights" v-if="parsedSummary.highlights && parsedSummary.highlights.length">
|
|
||||||
<view class="ai-summary-highlight" v-for="(item, idx) in parsedSummary.highlights" :key="idx">
|
|
||||||
<text class="highlight-dot">·</text>
|
|
||||||
<text class="highlight-text">{{ item }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="ai-summary-suggestion" v-if="parsedSummary.suggestion">
|
|
||||||
<text class="suggestion-label">💡 明日建议</text>
|
|
||||||
<text class="suggestion-text">{{ parsedSummary.suggestion }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view v-else class="ai-summary-empty" @tap="handleDailySummary">
|
|
||||||
<text class="ai-summary-empty-icon">✨</text>
|
|
||||||
<text class="ai-summary-empty-text">点击生成今日 AI 总结</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 记录弹框组件 -->
|
<!-- 记录弹框组件 -->
|
||||||
@@ -159,7 +97,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||||
import { onShareAppMessage } from '@dcloudio/uni-app'
|
import { onShareAppMessage, onShow } from '@dcloudio/uni-app'
|
||||||
import { useProfileStore } from '@/stores/profile'
|
import { useProfileStore } from '@/stores/profile'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
import { useLogin } from '@/hooks/useLogin'
|
import { useLogin } from '@/hooks/useLogin'
|
||||||
@@ -175,8 +113,7 @@ const navBarHeight = ref(0)
|
|||||||
const showDialog = ref(false)
|
const showDialog = ref(false)
|
||||||
const dialogType = ref('smoke') // 'smoke' 或 'resisted'
|
const dialogType = ref('smoke') // 'smoke' 或 'resisted'
|
||||||
const homeData = ref(null)
|
const homeData = ref(null)
|
||||||
const aiLoading = ref(false)
|
const pageReady = ref(false)
|
||||||
const summaryLoading = ref(false)
|
|
||||||
|
|
||||||
let timerInterval = null
|
let timerInterval = null
|
||||||
const timerSeconds = ref(0)
|
const timerSeconds = ref(0)
|
||||||
@@ -285,51 +222,6 @@ const nextSmokeTimeText = computed(() => {
|
|||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const suggestionSource = computed(() => {
|
|
||||||
return homeTimer.value?.suggestion_source || 'default'
|
|
||||||
})
|
|
||||||
|
|
||||||
const aiTimeNodes = computed(() => {
|
|
||||||
return homeTimer.value?.ai_time_nodes || []
|
|
||||||
})
|
|
||||||
|
|
||||||
const aiAdvice = computed(() => {
|
|
||||||
return homeTimer.value?.ai_advice || ''
|
|
||||||
})
|
|
||||||
|
|
||||||
const aiTimeNodesWithStatus = computed(() => {
|
|
||||||
const now = new Date()
|
|
||||||
const nowMinutes = now.getHours() * 60 + now.getMinutes()
|
|
||||||
let foundCurrent = false
|
|
||||||
return aiTimeNodes.value.map(time => {
|
|
||||||
const [h, m] = time.split(':').map(Number)
|
|
||||||
const nodeMinutes = h * 60 + m
|
|
||||||
if (foundCurrent) return { time, status: 'future' }
|
|
||||||
if (nodeMinutes > nowMinutes) {
|
|
||||||
foundCurrent = true
|
|
||||||
return { time, status: 'current' }
|
|
||||||
}
|
|
||||||
return { time, status: 'past' }
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
const dialogTitle = computed(() => {
|
|
||||||
return dialogType.value === 'smoke' ? '记录抽烟' : '想抽忍住了'
|
|
||||||
})
|
|
||||||
|
|
||||||
const dailySummaryData = computed(() => {
|
|
||||||
return homeData.value?.daily_summary?.status === 'available' ? homeData.value.daily_summary : null
|
|
||||||
})
|
|
||||||
|
|
||||||
const parsedSummary = computed(() => {
|
|
||||||
if (!dailySummaryData.value?.content) return {}
|
|
||||||
try {
|
|
||||||
return JSON.parse(dailySummaryData.value.content)
|
|
||||||
} catch {
|
|
||||||
return { summary: dailySummaryData.value.content, highlights: [], suggestion: '' }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function startTimer() {
|
function startTimer() {
|
||||||
stopTimer()
|
stopTimer()
|
||||||
if (timerBaseSeconds.value < 0) {
|
if (timerBaseSeconds.value < 0) {
|
||||||
@@ -443,163 +335,24 @@ async function initPage() {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('initPage error:', e)
|
console.error('initPage error:', e)
|
||||||
} finally {
|
} finally {
|
||||||
|
pageReady.value = true
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeAiTip() {
|
|
||||||
showAiTip.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleAISuggest() {
|
|
||||||
if (aiLoading.value) return
|
|
||||||
|
|
||||||
// 如果已有 AI 数据(今天已解锁),直接刷新
|
|
||||||
if (suggestionSource.value === 'ai') {
|
|
||||||
await fetchAISuggestion()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 需要看广告解锁
|
|
||||||
// #ifdef MP-WEIXIN
|
|
||||||
try {
|
|
||||||
const videoAd = wx.createRewardedVideoAd({
|
|
||||||
adUnitId: 'adunit-fa0b2e5520a39e6a'
|
|
||||||
})
|
|
||||||
videoAd.onClose(async (res) => {
|
|
||||||
if (res && res.isEnded) {
|
|
||||||
await unlockAndFetchAI()
|
|
||||||
} else {
|
|
||||||
uni.showToast({ title: '需要看完广告哦', icon: 'none' })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
videoAd.onError(() => {
|
|
||||||
// 广告加载失败,直接尝试解锁(可能已是 VIP)
|
|
||||||
unlockAndFetchAI()
|
|
||||||
})
|
|
||||||
await videoAd.show().catch(async () => {
|
|
||||||
await videoAd.load()
|
|
||||||
await videoAd.show()
|
|
||||||
})
|
|
||||||
} catch (e) {
|
|
||||||
// 非微信环境或广告不可用,直接尝试
|
|
||||||
await unlockAndFetchAI()
|
|
||||||
}
|
|
||||||
// #endif
|
|
||||||
// #ifndef MP-WEIXIN
|
|
||||||
await unlockAndFetchAI()
|
|
||||||
// #endif
|
|
||||||
}
|
|
||||||
|
|
||||||
async function unlockAndFetchAI() {
|
|
||||||
try {
|
|
||||||
const today = new Date().toISOString().split('T')[0]
|
|
||||||
await api.unlockAiAdvice({ date: today })
|
|
||||||
} catch (e) {
|
|
||||||
console.error('unlock error:', e)
|
|
||||||
}
|
|
||||||
await fetchAISuggestion()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchAISuggestion() {
|
|
||||||
aiLoading.value = true
|
|
||||||
try {
|
|
||||||
const res = await api.getAINextSmokeTime()
|
|
||||||
const data = res.data || {}
|
|
||||||
// 更新 homeData 中的 timer 字段
|
|
||||||
if (homeData.value && homeData.value.timer) {
|
|
||||||
if (data.suggested_at) {
|
|
||||||
homeData.value.timer.next_suggested_at = data.suggested_at
|
|
||||||
homeData.value.timer.suggestion_source = 'ai'
|
|
||||||
const t = new Date(data.suggested_at)
|
|
||||||
if (!isNaN(t.getTime())) {
|
|
||||||
homeData.value.timer.next_suggested_clock = `${String(t.getHours()).padStart(2, '0')}:${String(t.getMinutes()).padStart(2, '0')}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (data.time_nodes) {
|
|
||||||
homeData.value.timer.ai_time_nodes = data.time_nodes
|
|
||||||
}
|
|
||||||
if (data.advice) {
|
|
||||||
homeData.value.timer.ai_advice = data.advice
|
|
||||||
}
|
|
||||||
}
|
|
||||||
uni.showToast({ title: 'AI 计划已生成', icon: 'success' })
|
|
||||||
} catch (e) {
|
|
||||||
console.error('fetchAISuggestion error:', e)
|
|
||||||
uni.showToast({ title: '生成失败,请稍后重试', icon: 'none' })
|
|
||||||
} finally {
|
|
||||||
aiLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleDailySummary() {
|
|
||||||
if (summaryLoading.value) return
|
|
||||||
|
|
||||||
// 如果已有总结数据,直接刷新(已解锁)
|
|
||||||
if (dailySummaryData.value) {
|
|
||||||
await fetchDailySummary()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 需要看广告解锁
|
|
||||||
// #ifdef MP-WEIXIN
|
|
||||||
try {
|
|
||||||
const videoAd = wx.createRewardedVideoAd({
|
|
||||||
adUnitId: 'adunit-fa0b2e5520a39e6a'
|
|
||||||
})
|
|
||||||
videoAd.onClose(async (res) => {
|
|
||||||
if (res && res.isEnded) {
|
|
||||||
const today = new Date().toISOString().split('T')[0]
|
|
||||||
try { await api.unlockAiAdvice({ date: today }) } catch (e) { console.error('unlock error:', e) }
|
|
||||||
await fetchDailySummary()
|
|
||||||
} else {
|
|
||||||
uni.showToast({ title: '需要看完广告哦', icon: 'none' })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
videoAd.onError(() => {
|
|
||||||
fetchDailySummary()
|
|
||||||
})
|
|
||||||
await videoAd.show().catch(async () => {
|
|
||||||
await videoAd.load()
|
|
||||||
await videoAd.show()
|
|
||||||
})
|
|
||||||
} catch (e) {
|
|
||||||
await fetchDailySummary()
|
|
||||||
}
|
|
||||||
// #endif
|
|
||||||
// #ifndef MP-WEIXIN
|
|
||||||
await fetchDailySummary()
|
|
||||||
// #endif
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchDailySummary() {
|
|
||||||
summaryLoading.value = true
|
|
||||||
try {
|
|
||||||
const today = new Date().toISOString().split('T')[0]
|
|
||||||
const res = await api.getAIDailySummary({ date: today })
|
|
||||||
const data = res.data || {}
|
|
||||||
if (homeData.value) {
|
|
||||||
homeData.value.daily_summary = {
|
|
||||||
date: data.date || today,
|
|
||||||
content: data.content || '',
|
|
||||||
model: data.model || '',
|
|
||||||
status: 'available'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
uni.showToast({ title: '总结已生成', icon: 'success' })
|
|
||||||
} catch (e) {
|
|
||||||
console.error('fetchDailySummary error:', e)
|
|
||||||
const msg = e?.data?.message || '生成失败,请稍后重试'
|
|
||||||
uni.showToast({ title: msg, icon: 'none' })
|
|
||||||
} finally {
|
|
||||||
summaryLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
initPage()
|
initPage()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onShow(async () => {
|
||||||
|
if (!pageReady.value) return
|
||||||
|
try {
|
||||||
|
await fetchHomeData()
|
||||||
|
} catch (e) {
|
||||||
|
console.error('onShow refreshHomeData error:', e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
stopTimer()
|
stopTimer()
|
||||||
})
|
})
|
||||||
@@ -816,48 +569,11 @@ onShareAppMessage(() => {
|
|||||||
border: 2rpx solid #D1FAE5;
|
border: 2rpx solid #D1FAE5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.next-time-source {
|
|
||||||
font-size: 20rpx;
|
|
||||||
color: #FFFFFF;
|
|
||||||
background: linear-gradient(135deg, #34D399, #10B981);
|
|
||||||
padding: 2rpx 12rpx;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
margin-right: 8rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.next-time-text {
|
.next-time-text {
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
color: #059669;
|
color: #059669;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ai-btn-wrap {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
margin-top: 16rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-suggest-btn {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8rpx;
|
|
||||||
background: linear-gradient(135deg, #34D399, #10B981);
|
|
||||||
color: #FFFFFF;
|
|
||||||
padding: 10rpx 28rpx;
|
|
||||||
border-radius: 32rpx;
|
|
||||||
font-size: 24rpx;
|
|
||||||
font-weight: 500;
|
|
||||||
box-shadow: 0 6rpx 16rpx rgba(16, 185, 129, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-suggest-icon {
|
|
||||||
font-size: 24rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-suggest-text {
|
|
||||||
font-size: 24rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stats-row {
|
.stats-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 24rpx;
|
gap: 24rpx;
|
||||||
@@ -946,110 +662,6 @@ onShareAppMessage(() => {
|
|||||||
.stat-progress-red { background-color: #EF4444; }
|
.stat-progress-red { background-color: #EF4444; }
|
||||||
.stat-progress-green { background-color: #10B981; }
|
.stat-progress-green { background-color: #10B981; }
|
||||||
|
|
||||||
.ai-plan-card {
|
|
||||||
background-color: #FFFFFF;
|
|
||||||
border-radius: 24rpx;
|
|
||||||
padding: 28rpx;
|
|
||||||
margin-bottom: 24rpx;
|
|
||||||
border: 2rpx solid #D9FBE7;
|
|
||||||
box-shadow: 0 10rpx 22rpx rgba(16, 185, 129, 0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-plan-header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 24rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-plan-title {
|
|
||||||
font-size: 28rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #111827;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-plan-refresh {
|
|
||||||
padding: 6rpx 20rpx;
|
|
||||||
border-radius: 24rpx;
|
|
||||||
background-color: #ECFDF5;
|
|
||||||
border: 2rpx solid #D1FAE5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-plan-refresh-text {
|
|
||||||
font-size: 22rpx;
|
|
||||||
color: #059669;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-plan-timeline {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: 0 8rpx;
|
|
||||||
margin-bottom: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-plan-node {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
position: relative;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.node-dot {
|
|
||||||
width: 20rpx;
|
|
||||||
height: 20rpx;
|
|
||||||
border-radius: 50%;
|
|
||||||
background-color: #D1FAE5;
|
|
||||||
margin-bottom: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.node-past .node-dot {
|
|
||||||
background-color: #9CA3AF;
|
|
||||||
}
|
|
||||||
|
|
||||||
.node-current .node-dot {
|
|
||||||
background-color: #10B981;
|
|
||||||
box-shadow: 0 0 12rpx rgba(16, 185, 129, 0.5);
|
|
||||||
width: 24rpx;
|
|
||||||
height: 24rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.node-future .node-dot {
|
|
||||||
background-color: #D1FAE5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.node-time {
|
|
||||||
font-size: 22rpx;
|
|
||||||
color: #9CA3AF;
|
|
||||||
}
|
|
||||||
|
|
||||||
.node-past .node-time {
|
|
||||||
color: #9CA3AF;
|
|
||||||
text-decoration: line-through;
|
|
||||||
}
|
|
||||||
|
|
||||||
.node-current .node-time {
|
|
||||||
color: #059669;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.node-future .node-time {
|
|
||||||
color: #6B7280;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-plan-advice {
|
|
||||||
background-color: #F0FDF4;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
padding: 16rpx 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-plan-advice-text {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #374151;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-buttons {
|
.action-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 24rpx;
|
gap: 24rpx;
|
||||||
@@ -1084,123 +696,4 @@ onShareAppMessage(() => {
|
|||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ai-summary-card {
|
|
||||||
background-color: #FFFFFF;
|
|
||||||
border-radius: 24rpx;
|
|
||||||
padding: 28rpx;
|
|
||||||
margin-top: 24rpx;
|
|
||||||
border: 2rpx solid #D9FBE7;
|
|
||||||
box-shadow: 0 10rpx 22rpx rgba(16, 185, 129, 0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-summary-header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-summary-title {
|
|
||||||
font-size: 28rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #111827;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-summary-action {
|
|
||||||
padding: 6rpx 20rpx;
|
|
||||||
border-radius: 24rpx;
|
|
||||||
background-color: #ECFDF5;
|
|
||||||
border: 2rpx solid #D1FAE5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-summary-action-text {
|
|
||||||
font-size: 22rpx;
|
|
||||||
color: #059669;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-summary-loading {
|
|
||||||
padding: 40rpx 0;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-summary-loading-text {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #9CA3AF;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-summary-body {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 16rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-summary-text {
|
|
||||||
font-size: 26rpx;
|
|
||||||
color: #374151;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-summary-highlights {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-summary-highlight {
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
gap: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-dot {
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #10B981;
|
|
||||||
font-weight: 700;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-text {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #4B5563;
|
|
||||||
line-height: 1.5;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-summary-suggestion {
|
|
||||||
background-color: #F0FDF4;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
padding: 16rpx 20rpx;
|
|
||||||
margin-top: 4rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.suggestion-label {
|
|
||||||
font-size: 24rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #059669;
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 6rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.suggestion-text {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #374151;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-summary-empty {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 12rpx;
|
|
||||||
padding: 32rpx 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-summary-empty-icon {
|
|
||||||
font-size: 32rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-summary-empty-text {
|
|
||||||
font-size: 26rpx;
|
|
||||||
color: #9CA3AF;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
+46
-44
@@ -7,6 +7,24 @@
|
|||||||
|
|
||||||
<view class="section">
|
<view class="section">
|
||||||
<view class="menu-list">
|
<view class="menu-list">
|
||||||
|
<view class="menu-item" @tap="goAISuggest">
|
||||||
|
<view class="menu-icon menu-icon-green">🤖</view>
|
||||||
|
<view class="menu-content">
|
||||||
|
<text class="menu-label">AI 建议</text>
|
||||||
|
<text class="menu-desc">查看今日 AI 控烟节奏与建议节点</text>
|
||||||
|
</view>
|
||||||
|
<text class="menu-arrow">›</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="menu-item" @tap="goAISummary">
|
||||||
|
<view class="menu-icon menu-icon-green">📝</view>
|
||||||
|
<view class="menu-content">
|
||||||
|
<text class="menu-label">AI 总结</text>
|
||||||
|
<text class="menu-desc">按日期生成抽烟总结和明日建议</text>
|
||||||
|
</view>
|
||||||
|
<text class="menu-arrow">›</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="menu-item">
|
<view class="menu-item">
|
||||||
<view class="menu-icon menu-icon-green">🔗</view>
|
<view class="menu-icon menu-icon-green">🔗</view>
|
||||||
<view class="menu-content">
|
<view class="menu-content">
|
||||||
@@ -24,7 +42,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="menu-item" @tap="goOnboarding">
|
<view class="menu-item" @tap="goOnboarding">
|
||||||
<view class="menu-icon menu-icon-green">📝</view>
|
<view class="menu-icon menu-icon-green">📋</view>
|
||||||
<view class="menu-content">
|
<view class="menu-content">
|
||||||
<text class="menu-label">重新填写问卷</text>
|
<text class="menu-label">重新填写问卷</text>
|
||||||
<text class="menu-desc">修改吸烟基线与个人信息</text>
|
<text class="menu-desc">修改吸烟基线与个人信息</text>
|
||||||
@@ -53,18 +71,14 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="logout-btn" @tap="logout">
|
|
||||||
<text class="logout-text">退出登录</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<text class="version">版本 1.0.0</text>
|
<text class="version">版本 1.0.0</text>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onShareAppMessage } from '@dcloudio/uni-app'
|
import { onShareAppMessage, onShow } from '@dcloudio/uni-app'
|
||||||
import { createShare } from '@/api'
|
import * as api from '@/api'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
import { useLogin } from '@/hooks/useLogin'
|
import { useLogin } from '@/hooks/useLogin'
|
||||||
|
|
||||||
@@ -108,7 +122,7 @@ async function prepareShareToken(showToast = false) {
|
|||||||
if (shareLoading.value) return
|
if (shareLoading.value) return
|
||||||
shareLoading.value = true
|
shareLoading.value = true
|
||||||
try {
|
try {
|
||||||
const res = await createShare({ days: 7 })
|
const res = await api.createShare({ days: 7 })
|
||||||
shareToken.value = res.data?.share_token || ''
|
shareToken.value = res.data?.share_token || ''
|
||||||
shareExpireAt.value = res.data?.expire_at || ''
|
shareExpireAt.value = res.data?.expire_at || ''
|
||||||
if (showToast) {
|
if (showToast) {
|
||||||
@@ -138,6 +152,14 @@ function previewSharePage() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function goAISuggest() {
|
||||||
|
uni.navigateTo({ url: '/pages/ai/index' })
|
||||||
|
}
|
||||||
|
|
||||||
|
function goAISummary() {
|
||||||
|
uni.navigateTo({ url: '/pages/ai-summary/index' })
|
||||||
|
}
|
||||||
|
|
||||||
function goOnboarding() {
|
function goOnboarding() {
|
||||||
uni.navigateTo({ url: '/pages/onboarding/index' })
|
uni.navigateTo({ url: '/pages/onboarding/index' })
|
||||||
}
|
}
|
||||||
@@ -168,19 +190,6 @@ function copyInfo() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function logout() {
|
|
||||||
uni.showModal({
|
|
||||||
title: '确认退出',
|
|
||||||
content: '确定要退出登录吗?',
|
|
||||||
success: (res) => {
|
|
||||||
if (res.confirm) {
|
|
||||||
userStore.logout()
|
|
||||||
uni.reLaunch({ url: '/pages/index/index' })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
onShareAppMessage(() => {
|
onShareAppMessage(() => {
|
||||||
return {
|
return {
|
||||||
title: `${userName.value}的戒烟记录(仅查看)`,
|
title: `${userName.value}的戒烟记录(仅查看)`,
|
||||||
@@ -188,7 +197,7 @@ onShareAppMessage(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onShow(async () => {
|
||||||
await waitForLogin()
|
await waitForLogin()
|
||||||
await prepareShareToken(false)
|
await prepareShareToken(false)
|
||||||
})
|
})
|
||||||
@@ -225,7 +234,9 @@ onMounted(async () => {
|
|||||||
color: #111827;
|
color: #111827;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section { margin-bottom: 24rpx; }
|
.section {
|
||||||
|
margin-bottom: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.menu-list {
|
.menu-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -254,8 +265,13 @@ onMounted(async () => {
|
|||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-icon-green { background-color: #DCFCE7; }
|
.menu-icon-green {
|
||||||
.menu-icon-gray { background-color: #F3F4F6; }
|
background-color: #DCFCE7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-icon-gray {
|
||||||
|
background-color: #F3F4F6;
|
||||||
|
}
|
||||||
|
|
||||||
.menu-content {
|
.menu-content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@@ -304,33 +320,19 @@ onMounted(async () => {
|
|||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 999rpx;
|
border-radius: 999rpx;
|
||||||
color: #ffffff;
|
color: #FFFFFF;
|
||||||
background: #10b981;
|
background: #10B981;
|
||||||
}
|
}
|
||||||
|
|
||||||
.share-btn[disabled] {
|
.share-btn[disabled] {
|
||||||
background: #9ca3af;
|
background: #9CA3AF;
|
||||||
color: #ffffff;
|
color: #FFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
.share-btn::after {
|
.share-btn::after {
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logout-btn {
|
|
||||||
text-align: center;
|
|
||||||
padding: 28rpx;
|
|
||||||
margin-top: 40rpx;
|
|
||||||
background-color: #FFFFFF;
|
|
||||||
border-radius: 24rpx;
|
|
||||||
border: 2rpx solid #FEE2E2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logout-text {
|
|
||||||
color: #EF4444;
|
|
||||||
font-size: 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.version {
|
.version {
|
||||||
display: block;
|
display: block;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|||||||
Reference in New Issue
Block a user