|
|
@@ -163,6 +163,7 @@
|
|
|
<script>
|
|
|
import MpHtml from '@/components/mp-html/mp-html.vue'
|
|
|
import { parseDate } from '../../utils/format.js'
|
|
|
+import { getFamilyFortune } from '../../utils/api.js'
|
|
|
/**
|
|
|
* FamilyDashboard — 家庭天盘详情页
|
|
|
* 包含:运势数据、能量趋势、历史周报、月度日历等
|
|
|
@@ -275,106 +276,45 @@ export default {
|
|
|
methods: {
|
|
|
// 加载今日运势数据
|
|
|
loadTodayFortune() {
|
|
|
- // TODO: 对接后端 /api/mind/fortune 接口
|
|
|
- // 这里使用默认占位数据
|
|
|
- this.familyFortune = {
|
|
|
- dominantElement: '火',
|
|
|
- luckyDirection: '南',
|
|
|
- fortuneLevel: '大吉',
|
|
|
- fortuneLevelText: '大吉',
|
|
|
- fortuneDescription: '今日热情洋溢,宜沟通表达',
|
|
|
- moodScore: 85,
|
|
|
- moodEmoji: '😄',
|
|
|
- moodText: '喜悦',
|
|
|
- dailyTip: '把握今日良机,多与家人互动',
|
|
|
- weeklyTip: '本周建议:多陪伴家人,适度运动'
|
|
|
- }
|
|
|
+ var self = this
|
|
|
+ getFamilyFortune().then(function(res) {
|
|
|
+ if (res.code === 200 && res.data) {
|
|
|
+ self.familyFortune = {
|
|
|
+ dominantElement: res.data.dominantElement || '木',
|
|
|
+ luckyDirection: res.data.luckyDirection || '东',
|
|
|
+ fortuneLevel: res.data.fortuneLevel || '平',
|
|
|
+ fortuneLevelText: res.data.fortuneLevelText || res.data.fortuneLevel || '平',
|
|
|
+ fortuneDescription: res.data.fortuneDescription || '',
|
|
|
+ moodScore: res.data.moodScore || 65,
|
|
|
+ moodEmoji: res.data.moodEmoji || '😊',
|
|
|
+ moodText: res.data.moodText || '平静',
|
|
|
+ dailyTip: res.data.dailyTip || '',
|
|
|
+ weeklyTip: res.data.weeklyTip || ''
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).catch(function(e) {
|
|
|
+ console.error('加载今日运势失败', e)
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
// 加载本周运势数据
|
|
|
+ // TODO: 后端实现 /api/mind/fortune/week 后对接
|
|
|
loadWeekFortuneData() {
|
|
|
- // TODO: 对接后端 /api/mind/fortune/week 接口
|
|
|
- const mockData = []
|
|
|
- const today = new Date()
|
|
|
- for (let i = 0; i < 7; i++) {
|
|
|
- const date = new Date(today)
|
|
|
- date.setDate(date.getDate() - (today.getDay() - i))
|
|
|
-
|
|
|
- const levels = ['大吉', '吉', '平', '凶', '大凶']
|
|
|
- const levelIndex = Math.floor(Math.random() * 5)
|
|
|
- const elements = ['木', '火', '土', '金', '水']
|
|
|
-
|
|
|
- mockData.push({
|
|
|
- date: this.formatDate(date),
|
|
|
- fortuneLevel: levels[levelIndex],
|
|
|
- fortuneLevelText: levels[levelIndex],
|
|
|
- fortuneScore: 50 + (levelIndex < 2 ? (3 - levelIndex) * 15 : (levelIndex > 2 ? (levelIndex - 2) * -20 : 0)),
|
|
|
- dominantElement: elements[Math.floor(Math.random() * 5)]
|
|
|
- })
|
|
|
- }
|
|
|
- this.weekFortunes = mockData
|
|
|
+ // 暂无后端接口,保持空数组(不展示随机假数据)
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
// 加载本月运势数据
|
|
|
+ // TODO: 后端实现 /api/mind/fortune/month 后对接
|
|
|
loadMonthlyFortuneData() {
|
|
|
- // TODO: 对接后端 /api/mind/fortune/month 接口
|
|
|
- const mockData = []
|
|
|
- const today = new Date()
|
|
|
- const daysInMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0).getDate()
|
|
|
-
|
|
|
- for (let i = 1; i <= daysInMonth; i++) {
|
|
|
- const date = new Date(today.getFullYear(), today.getMonth(), i)
|
|
|
- const dateStr = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(i).padStart(2, '0')}`
|
|
|
-
|
|
|
- const levels = ['大吉', '吉', '平', '凶', '大凶']
|
|
|
- const levelIndex = Math.floor(Math.random() * 5)
|
|
|
-
|
|
|
- mockData.push({
|
|
|
- fortuneDate: dateStr,
|
|
|
- fortuneLevel: levels[levelIndex],
|
|
|
- fortuneLevelText: levels[levelIndex],
|
|
|
- luckyDirection: ['东', '南', '西', '北', '中'][Math.floor(Math.random() * 5)] + '方',
|
|
|
- dominantElement: ['木', '火', '土', '金', '水'][Math.floor(Math.random() * 5)]
|
|
|
- })
|
|
|
- }
|
|
|
- this.monthFortunes = mockData
|
|
|
+ // 暂无后端接口,保持空数组(不展示随机假数据)
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
// 加载历史周报
|
|
|
+ // TODO: 后端实现 /api/mind/fortune/reports 后对接
|
|
|
loadWeeklyReports() {
|
|
|
- // TODO: 对接后端 /api/mind/fortune/reports 接口
|
|
|
- const mockReports = []
|
|
|
- for (let i = 1; i <= 8; i++) {
|
|
|
- mockReports.push({
|
|
|
- weekNumber: i,
|
|
|
- startDate: `2026-06-${String(28 - i * 7).padStart(2, '0')}`,
|
|
|
- endDate: `2026-07-${String(4 - i).padStart(2, '0')}`,
|
|
|
- content: this.generateMockReportContent(i)
|
|
|
- })
|
|
|
- }
|
|
|
- this.weeklyReports = mockReports
|
|
|
- },
|
|
|
-
|
|
|
- // 生成模拟周报内容
|
|
|
- generateMockReportContent(weekNumber) {
|
|
|
- const elements = ['木', '火', '土', '金', '水']
|
|
|
- const element = elements[weekNumber % 5]
|
|
|
- return `<div style="font-family: sans-serif; line-height: 1.6; color: #333;">
|
|
|
- <h2 style="color: #FF6B9D; text-align: center;">家庭运势周报 - 第${weekNumber}周</h2>
|
|
|
- <p style="text-indent: 2em;">本周主导五行:<span style="color: ${this.elementColors[element]};">${element}</span>,
|
|
|
- 意味着家庭整体运势偏向${{ 木: '成长与和谐', 火: '热情与活力', 土: '稳定与健康', 金: '收获与进步', 水: '智慧与灵活' }[element]}。</p>
|
|
|
- <h3 style="color: #666;">运势概况</h3>
|
|
|
- <p style="text-indent: 2em;">本周吉位平均位于 <strong>${['东', '南', '西', '北'][weekNumber % 4]}方</strong>,建议多在此方位进行重要活动。
|
|
|
- 运势整体呈现先抑后扬之势,周二、周四较为低迷,周五后逐步好转。</p>
|
|
|
- <h3 style="color: #666;">心理状态</h3>
|
|
|
- <p style="text-indent: 2em;">家庭成员情绪指数平均${70 + weekNumber}分,整体状态${weekNumber > 4 ? '良好' : '一般'}。
|
|
|
- ${weekNumber > 4 ? '建议保持现有和谐氛围' : '需注意情绪调节,避免矛盾升级'}。</p>
|
|
|
- <h3 style="color: #666;">宜忌提示</h3>
|
|
|
- <p style="text-indent: 2em;"><strong>宜:</strong>${{ 木: '植树种花、交友聚会', 火: '聚餐联谊、旅行观光', 土: '健康管理、家居整理', 金: '投资理财、学习进修', 水: '阅读思考、社交活动' }[element]}</p>
|
|
|
- <p style="text-indent: 2em;margin-top: -10px;"><strong>忌:</strong>${{ 木: '冲动举动、过度开支', 火: '过度消耗、睡眠不足', 土: '情绪压抑、忽视健康', 金: '过于拘谨、忽视情感', 水: '沉迷游戏、忽略家人' }[element]}</p>
|
|
|
- </div>`
|
|
|
+ // 暂无后端接口,保持空数组(不展示随机假数据)
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
// 初始化罗盘 Canvas
|
|
|
initCompassCanvas() {
|
|
|
const query = uni.createSelectorQuery().in(this)
|