emotion-trend.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  1. <template>
  2. <view class="trend-container">
  3. <!-- 统计概览卡片 -->
  4. <view class="stats-overview">
  5. <view class="stat-item">
  6. <text class="stat-value">{{ stats.totalCheckins || 0 }}</text>
  7. <text class="stat-label">总打卡</text>
  8. </view>
  9. <view class="stat-item">
  10. <text class="stat-value">{{ stats.currentStreak || 0 }}</text>
  11. <text class="stat-label">连续天数</text>
  12. </view>
  13. <view class="stat-item">
  14. <text class="stat-value">{{ stats.thisMonthCheckins || 0 }}</text>
  15. <text class="stat-label">本月打卡</text>
  16. </view>
  17. <view class="stat-item">
  18. <text class="stat-value">{{ stats.totalEnergy || 0 }}</text>
  19. <text class="stat-label">心能量</text>
  20. </view>
  21. </view>
  22. <!-- 周期切换 -->
  23. <view class="period-tabs">
  24. <view
  25. :class="['period-tab', period === 'week' ? 'period-active' : '']"
  26. @click="switchPeriod('week')">
  27. <text>周</text>
  28. </view>
  29. <view
  30. :class="['period-tab', period === 'month' ? 'period-active' : '']"
  31. @click="switchPeriod('month')">
  32. <text>月</text>
  33. </view>
  34. </view>
  35. <!-- Phase 1.2: 情绪风险告警 -->
  36. <PsychCrisisBanner v-if="hasChildId" :memberId="currentChildId" source="checkin" />
  37. <!-- ===== Phase 1.1: 情绪评分折线图 ===== -->
  38. <view class="chart-card" v-if="moodTrendData.length > 0">
  39. <text class="card-title">情绪评分趋势</text>
  40. <text class="card-subtitle" v-if="trend && trend.moodScoreAvg">周均分: {{ trend.moodScoreAvg }}</text>
  41. <canvas class="line-chart-canvas" canvas-id="moodTrendCanvas" @ready="drawMoodTrend"></canvas>
  42. </view>
  43. <!-- ===== Phase 1.1: 效价-激活度散点图 ===== -->
  44. <view class="chart-card" v-if="scatterData.length > 0">
  45. <text class="card-title">情绪空间分布</text>
  46. <text class="card-subtitle">每个点代表一次打卡</text>
  47. <canvas class="scatter-canvas" canvas-id="scatterCanvas" @ready="drawScatter"></canvas>
  48. </view>
  49. <!-- ===== 情绪日历(升级为热力版) ===== -->
  50. <view class="calendar-card">
  51. <text class="card-title">情绪日历</text>
  52. <view class="calendar-grid">
  53. <view class="calendar-weekday" v-for="wd in weekdays" :key="wd">
  54. <text>{{ wd }}</text>
  55. </view>
  56. <view
  57. v-for="(day, idx) in calendarDays"
  58. :key="idx"
  59. :class="['calendar-day', day.isToday ? 'is-today' : '', day.moodScore ? 'has-data' : '']"
  60. :style="day.bgStyle"
  61. @click="day.moodScore && showDayDetail(day)">
  62. <text class="day-num">{{ day.dayNum }}</text>
  63. <text v-if="day.weather" class="day-emoji-small">{{ weatherEmoji(day.weather) }}</text>
  64. <text v-if="day.moodScore" class="day-score">{{ day.moodScore }}</text>
  65. </view>
  66. </view>
  67. <!-- 热力图例 -->
  68. <view class="heatmap-legend">
  69. <text class="legend-label">低</text>
  70. <view class="legend-bar">
  71. <view class="legend-step" style="background:#FFE0E0"></view>
  72. <view class="legend-step" style="background:#FFB0B0"></view>
  73. <view class="legend-step" style="background:#FFD9A0"></view>
  74. <view class="legend-step" style="background:#C8E6C9"></view>
  75. <view class="legend-step" style="background:#81C784"></view>
  76. </view>
  77. <text class="legend-label">高</text>
  78. </view>
  79. </view>
  80. <!-- 情绪分布 -->
  81. <view class="distribution-card">
  82. <text class="card-title">情绪分布</text>
  83. <view class="distribution-list">
  84. <view class="dist-item" v-for="dist in distributionData" :key="dist.weather">
  85. <text class="dist-emoji">{{ dist.icon }}</text>
  86. <text class="dist-label">{{ dist.label }}</text>
  87. <view class="dist-bar-track">
  88. <view class="dist-bar-fill" :style="{ width: dist.percent + '%', background: dist.color }"></view>
  89. </view>
  90. <text class="dist-count">{{ dist.count }}次</text>
  91. </view>
  92. </view>
  93. </view>
  94. <!-- 按天详情(含情绪精细数据) -->
  95. <view class="daily-list-card" v-if="dailyData.length > 0">
  96. <text class="card-title">每日记录</text>
  97. <view class="daily-item" v-for="(day, idx) in dailyData" :key="idx" @click="viewDayCheckin(day)">
  98. <text class="daily-date">{{ formatDate(day.date) }}</text>
  99. <text class="daily-emoji">{{ weatherEmoji(day.weather) }}</text>
  100. <text class="daily-weather">{{ weatherLabel(day.weather) }}</text>
  101. <!-- Phase 1.1 精细数据标签 -->
  102. <view class="daily-tags" v-if="day.moodScore">
  103. <text class="daily-tag score-tag">{{ day.moodScore }}分</text>
  104. <text class="daily-tag type-tag" v-if="day.emotionType">{{ emotionTypeLabel(day.emotionType) }}</text>
  105. <text class="daily-tag arousal-tag" v-if="day.arousalLevel">激活{{ day.arousalLevel }}</text>
  106. </view>
  107. </view>
  108. </view>
  109. <view class="empty-state" v-if="!stats || stats.totalCheckins === 0">
  110. <text class="empty-icon">&#x1F4AD;</text>
  111. <text class="empty-text">还没有情绪打卡记录</text>
  112. <button class="empty-btn" @click="goCheckin">去打卡</button>
  113. </view>
  114. </view>
  115. </template>
  116. <script>
  117. import config from '../../config'
  118. import PsychCrisisBanner from '../../components/PsychCrisisBanner.vue'
  119. import { parseDate } from '../../utils/format.js'
  120. export default {
  121. components: { PsychCrisisBanner },
  122. data() {
  123. return {
  124. currentChildId: null,
  125. period: 'week',
  126. stats: null,
  127. trend: null,
  128. weekdays: ['日', '一', '二', '三', '四', '五', '六'],
  129. weatherConfig: {
  130. sunny: { icon: '\u2600\uFE0F', label: '心情很好', color: '#FFB347' },
  131. cloudy: { icon: '\u26C5', label: '一般般', color: '#A0A0A0' },
  132. rainy: { icon: '\uD83C\uDF27\uFE0F', label: '有点难过', color: '#6B9BD2' },
  133. stormy: { icon: '\u26A1', label: '很烦躁', color: '#8B5CF6' },
  134. rainbow: { icon: '\uD83C\uDF08', label: '特别开心', color: '#FF6B9D' }
  135. },
  136. // Plutchik 情绪中文映射
  137. emotionTypeLabels: {
  138. 'joy': '开心', 'trust': '信任', 'fear': '恐惧', 'surprise': '惊讶',
  139. 'sadness': '悲伤', 'disgust': '厌恶', 'anger': '愤怒', 'anticipation': '期待'
  140. },
  141. // 散点/折线图数据
  142. scatterData: [],
  143. moodTrendData: [],
  144. // Canvas 上下文
  145. scatterCtx: null,
  146. trendCtx: null
  147. }
  148. },
  149. computed: {
  150. hasChildId() {
  151. return !!this.currentChildId
  152. },
  153. calendarDays() {
  154. const days = []
  155. const now = new Date()
  156. const year = now.getFullYear()
  157. const month = now.getMonth()
  158. const firstDay = new Date(year, month, 1).getDay()
  159. const daysInMonth = new Date(year, month + 1, 0).getDate()
  160. const today = now.getDate()
  161. // Build data map from dailyData
  162. const dataMap = {}
  163. if (this.trend && this.trend.dailyData) {
  164. for (const d of this.trend.dailyData) {
  165. if (d.date) {
  166. const dateObj = parseDate(d.date)
  167. if (!dateObj) continue
  168. dataMap[dateObj.getDate()] = d
  169. }
  170. }
  171. }
  172. // Empty leading cells
  173. for (let i = 0; i < firstDay; i++) {
  174. days.push({ dayNum: '', weather: null, moodScore: null, isToday: false, bgStyle: '' })
  175. }
  176. for (let d = 1; d <= daysInMonth; d++) {
  177. const data = dataMap[d]
  178. var bgStyle = ''
  179. if (data && data.moodScore) {
  180. // Heatmap intensity: moodScore 1-10 mapped to color
  181. var score = data.moodScore
  182. var r, g, b
  183. if (score <= 3) {
  184. // 1-3: red tint
  185. var intensity1 = (score - 1) / 2
  186. r = 255
  187. g = Math.round(180 + 75 * intensity1)
  188. b = Math.round(180 + 75 * intensity1)
  189. } else if (score <= 6) {
  190. // 4-6: orange/yellow tint
  191. var intensity2 = (score - 4) / 2
  192. r = 255
  193. g = Math.round(200 + 55 * intensity2)
  194. b = Math.round(160 - 60 * intensity2)
  195. } else {
  196. // 7-10: green tint
  197. var intensity3 = (score - 7) / 3
  198. r = Math.round(200 - 120 * intensity3)
  199. g = Math.round(230 - 20 * intensity3)
  200. b = Math.round(200 - 120 * intensity3)
  201. }
  202. bgStyle = 'background: rgba(' + r + ',' + g + ',' + b + ',0.4)'
  203. }
  204. days.push({
  205. dayNum: d,
  206. weather: data ? data.weather : null,
  207. moodScore: data ? data.moodScore : null,
  208. emotionType: data ? data.emotionType : null,
  209. arousalLevel: data ? data.arousalLevel : null,
  210. isToday: d === today,
  211. bgStyle: bgStyle
  212. })
  213. }
  214. return days
  215. },
  216. distributionData() {
  217. const dist = this.trend && this.trend.weatherDistribution
  218. if (!dist) return []
  219. const total = Object.values(dist).reduce((a, b) => a + b, 0)
  220. if (total === 0) return []
  221. return Object.keys(dist).map(w => {
  222. const cfg = this.weatherConfig[w] || { icon: '?', label: w, color: '#ccc' }
  223. return {
  224. weather: w,
  225. icon: cfg.icon,
  226. label: cfg.label,
  227. color: cfg.color,
  228. count: dist[w],
  229. percent: Math.round(dist[w] / total * 100)
  230. }
  231. })
  232. },
  233. dailyData() {
  234. return this.trend && this.trend.dailyData || []
  235. }
  236. },
  237. onLoad() {
  238. this.currentChildId = uni.getStorageSync('currentChildId') || null
  239. this.loadData()
  240. },
  241. methods: {
  242. loadData() {
  243. const memberId = uni.getStorageSync('currentChildId')
  244. if (!memberId) return
  245. uni.request({
  246. url: config.API_BASE_URL + '/api/mind/checkin/stats',
  247. method: 'POST',
  248. data: { memberId },
  249. success: (res) => {
  250. if (res.data && res.data.code === 200) {
  251. this.stats = res.data.data
  252. }
  253. }
  254. })
  255. uni.request({
  256. url: config.API_BASE_URL + '/api/mind/checkin/trend',
  257. method: 'POST',
  258. data: { memberId, period: this.period },
  259. success: (res) => {
  260. if (res.data && res.data.code === 200) {
  261. this.trend = res.data.data
  262. // Extract scatter & trend data
  263. this.scatterData = this.trend && this.trend.scatterData || []
  264. this.moodTrendData = this.trend && this.trend.moodTrend || []
  265. // Draw charts after data is ready
  266. this.$nextTick(function() {
  267. this.drawMoodTrend()
  268. this.drawScatter()
  269. })
  270. }
  271. }
  272. })
  273. },
  274. switchPeriod(p) {
  275. this.period = p
  276. this.loadData()
  277. },
  278. weatherEmoji(weather) {
  279. const cfg = this.weatherConfig[weather]
  280. return cfg ? cfg.icon : ''
  281. },
  282. weatherLabel(weather) {
  283. const cfg = this.weatherConfig[weather]
  284. return cfg ? cfg.label : weather
  285. },
  286. emotionTypeLabel(type) {
  287. return this.emotionTypeLabels[type] || type
  288. },
  289. formatDate(dateStr) {
  290. if (!dateStr) return ''
  291. const d = parseDate(dateStr)
  292. if (!d) return ''
  293. return (d.getMonth() + 1) + '/' + d.getDate()
  294. },
  295. goCheckin() {
  296. uni.navigateTo({ url: '/pages/mind/emotion-checkin' })
  297. },
  298. showDayDetail(day) {
  299. // 点击日历格子可以跳转到当天的打卡详情
  300. // 简单 toast 显示评分
  301. uni.showToast({ title: '情绪评分: ' + day.moodScore + '/10', icon: 'none' })
  302. },
  303. viewDayCheckin(day) {
  304. // 查看单条打卡详情(当前简单响应)
  305. if (day.moodScore) {
  306. uni.showToast({ title: '情绪评分: ' + day.moodScore + '/10', icon: 'none' })
  307. }
  308. },
  309. // ===== Canvas 绘图 =====
  310. drawMoodTrend() {
  311. if (this.moodTrendData.length < 1) return
  312. var canvasId = 'moodTrendCanvas'
  313. var query = uni.createSelectorQuery()
  314. var self = this
  315. query.select('#' + canvasId).fields({ node: true, size: true }).exec(function(res) {
  316. // Fallback: use context API for older uni-app
  317. var ctx = uni.createCanvasContext(canvasId, self)
  318. var dpr = 2
  319. // Get canvas dimensions from the element
  320. query.select('#' + canvasId).boundingClientRect(function(rect) {
  321. if (!rect) return
  322. var width = rect.width || 300
  323. var height = rect.height || 200
  324. var canvasWidth = width * dpr
  325. var canvasHeight = height * dpr
  326. // Clear
  327. ctx.clearRect(0, 0, canvasWidth, canvasHeight)
  328. var data = self.moodTrendData
  329. var count = data.length
  330. if (count === 0) return
  331. var padding = { top: 20 * dpr, right: 20 * dpr, bottom: 30 * dpr, left: 30 * dpr }
  332. var plotW = canvasWidth - padding.left - padding.right
  333. var plotH = canvasHeight - padding.top - padding.bottom
  334. // Draw axes
  335. ctx.setStrokeStyle('#E0E0E0')
  336. ctx.setLineWidth(1 * dpr)
  337. ctx.beginPath()
  338. ctx.moveTo(padding.left, padding.top)
  339. ctx.lineTo(padding.left, padding.top + plotH)
  340. ctx.lineTo(padding.left + plotW, padding.top + plotH)
  341. ctx.stroke()
  342. // Draw Y axis labels
  343. ctx.setFontSize(10 * dpr)
  344. ctx.setFillStyle('#999')
  345. ctx.setTextAlign('right')
  346. for (var yVal = 2; yVal <= 10; yVal += 2) {
  347. var yPos = padding.top + plotH - (yVal / 10) * plotH
  348. ctx.fillText(yVal + '', padding.left - 6 * dpr, yPos + 3 * dpr)
  349. // Grid line
  350. ctx.setStrokeStyle('#F0F0F0')
  351. ctx.setLineWidth(1 * dpr)
  352. ctx.beginPath()
  353. ctx.moveTo(padding.left, yPos)
  354. ctx.lineTo(padding.left + plotW, yPos)
  355. ctx.stroke()
  356. }
  357. // Determine trend line color based on trend direction
  358. var avg = 0
  359. for (var si = 0; si < count; si++) {
  360. avg += data[si].moodScore
  361. }
  362. avg /= count
  363. var lineColor = avg >= 5 ? '#10B981' : '#FF6B9D'
  364. // Draw data points and lines
  365. ctx.setStrokeStyle(lineColor)
  366. ctx.setLineWidth(3 * dpr)
  367. ctx.setFillStyle(lineColor)
  368. for (var i = 0; i < count; i++) {
  369. var x = padding.left + (i / Math.max(count - 1, 1)) * plotW
  370. var y = padding.top + plotH - (data[i].moodScore / 10) * plotH
  371. if (i === 0) {
  372. ctx.beginPath()
  373. ctx.moveTo(x, y)
  374. } else {
  375. ctx.lineTo(x, y)
  376. }
  377. // Draw point circle
  378. ctx.beginPath()
  379. ctx.arc(x, y, 4 * dpr, 0, 2 * Math.PI)
  380. ctx.setFillStyle(lineColor)
  381. ctx.fill()
  382. }
  383. ctx.stroke()
  384. // Draw X axis labels (dates)
  385. ctx.setFontSize(9 * dpr)
  386. ctx.setFillStyle('#999')
  387. ctx.setTextAlign('center')
  388. var step = Math.max(1, Math.floor(count / 6))
  389. for (var di = 0; di < count; di += step) {
  390. var labelX = padding.left + (di / Math.max(count - 1, 1)) * plotW
  391. var labelText = self.formatDate(data[di].date)
  392. ctx.fillText(labelText, labelX, padding.top + plotH + 18 * dpr)
  393. }
  394. ctx.draw()
  395. }).exec()
  396. })
  397. },
  398. drawScatter() {
  399. if (this.scatterData.length < 3) return
  400. var canvasId = 'scatterCanvas'
  401. var query = uni.createSelectorQuery()
  402. var self = this
  403. query.select('#' + canvasId).boundingClientRect(function(rect) {
  404. if (!rect) return
  405. var ctx = uni.createCanvasContext(canvasId, self)
  406. var dpr = 2
  407. var width = rect.width || 300
  408. var height = rect.height || 200
  409. var canvasWidth = width * dpr
  410. var canvasHeight = height * dpr
  411. ctx.clearRect(0, 0, canvasWidth, canvasHeight)
  412. var padding = { top: 20 * dpr, right: 20 * dpr, bottom: 30 * dpr, left: 30 * dpr }
  413. var plotW = canvasWidth - padding.left - padding.right
  414. var plotH = canvasHeight - padding.top - padding.bottom
  415. // Draw background with 4 quadrants
  416. // Q1 (high arousal, high valence): top-right
  417. var midX = padding.left + plotW / 2
  418. var midY = padding.top + plotH / 2
  419. // Quadrant backgrounds
  420. ctx.setFillStyle('rgba(255,240,240,0.3)')
  421. ctx.fillRect(midX, padding.top, plotW / 2, plotH / 2) // high arousal, high valence
  422. ctx.setFillStyle('rgba(240,240,255,0.3)')
  423. ctx.fillRect(padding.left, padding.top, plotW / 2, plotH / 2) // high arousal, low valence
  424. ctx.setFillStyle('rgba(255,248,240,0.3)')
  425. ctx.fillRect(midX, midY, plotW / 2, plotH / 2) // low arousal, high valence
  426. ctx.setFillStyle('rgba(245,245,245,0.3)')
  427. ctx.fillRect(padding.left, midY, plotW / 2, plotH / 2) // low arousal, low valence
  428. // Quadrant labels
  429. ctx.setFontSize(10 * dpr)
  430. ctx.setFillStyle('rgba(0,0,0,0.15)')
  431. ctx.setTextAlign('center')
  432. ctx.fillText('兴奋', padding.left + plotW * 0.75, padding.top + plotH * 0.3)
  433. ctx.fillText('烦躁', padding.left + plotW * 0.25, padding.top + plotH * 0.3)
  434. ctx.fillText('平静', padding.left + plotW * 0.75, padding.top + plotH * 0.8)
  435. ctx.fillText('低落', padding.left + plotW * 0.25, padding.top + plotH * 0.8)
  436. // Axes
  437. ctx.setStrokeStyle('#E0E0E0')
  438. ctx.setLineWidth(1 * dpr)
  439. ctx.beginPath()
  440. ctx.moveTo(padding.left, padding.top + plotH / 2)
  441. ctx.lineTo(padding.left + plotW, padding.top + plotH / 2)
  442. ctx.stroke()
  443. ctx.beginPath()
  444. ctx.moveTo(padding.left + plotW / 2, padding.top)
  445. ctx.lineTo(padding.left + plotW / 2, padding.top + plotH)
  446. ctx.stroke()
  447. // Axis labels
  448. ctx.setFontSize(9 * dpr)
  449. ctx.setFillStyle('#999')
  450. ctx.setTextAlign('center')
  451. ctx.fillText('效价 →', padding.left + plotW / 2, padding.top + plotH + 18 * dpr)
  452. ctx.save()
  453. ctx.translate(padding.left - 4 * dpr, padding.top + plotH / 2)
  454. ctx.rotate(-Math.PI / 2)
  455. ctx.setTextAlign('center')
  456. ctx.fillText('激活度', 0, 0)
  457. ctx.restore()
  458. // Draw scatter points
  459. for (var i = 0; i < self.scatterData.length; i++) {
  460. var pt = self.scatterData[i]
  461. var px = padding.left + (pt.valence / 10) * plotW
  462. var py = padding.top + plotH - (pt.arousal / 10) * plotH
  463. // Color based on valence
  464. var color
  465. if (pt.valence >= 7) {
  466. color = '#10B981'
  467. } else if (pt.valence >= 5) {
  468. color = '#FFD93D'
  469. } else {
  470. color = '#FF6B9D'
  471. }
  472. ctx.beginPath()
  473. ctx.arc(px, py, 5 * dpr, 0, 2 * Math.PI)
  474. ctx.setFillStyle(color)
  475. ctx.setGlobalAlpha(0.7)
  476. ctx.fill()
  477. ctx.setGlobalAlpha(1)
  478. }
  479. ctx.draw()
  480. }).exec()
  481. }
  482. }
  483. }
  484. </script>
  485. <style scoped>
  486. .trend-container {
  487. min-height: 100vh;
  488. background: #F8F8F8;
  489. padding-bottom: 40rpx;
  490. }
  491. .stats-overview {
  492. display: flex;
  493. margin: 24rpx 32rpx;
  494. background: linear-gradient(135deg, #FF6B9D, #FF8CB3);
  495. border-radius: 20rpx;
  496. padding: 28rpx 16rpx;
  497. }
  498. .stat-item {
  499. flex: 1;
  500. text-align: center;
  501. }
  502. .stat-value {
  503. font-size: 36rpx;
  504. font-weight: 700;
  505. color: #fff;
  506. display: block;
  507. }
  508. .stat-label {
  509. font-size: 22rpx;
  510. color: rgba(255, 255, 255, 0.8);
  511. margin-top: 6rpx;
  512. display: block;
  513. }
  514. .period-tabs {
  515. display: flex;
  516. margin: 0 32rpx;
  517. background: #fff;
  518. border-radius: 12rpx;
  519. overflow: hidden;
  520. }
  521. .period-tab {
  522. flex: 1;
  523. text-align: center;
  524. padding: 16rpx 0;
  525. font-size: 26rpx;
  526. color: #666;
  527. }
  528. .period-active {
  529. background: #FF6B9D;
  530. color: #fff;
  531. font-weight: 600;
  532. }
  533. /* ===== 图表卡片 ===== */
  534. .chart-card {
  535. margin: 24rpx 32rpx;
  536. background: #fff;
  537. border-radius: 20rpx;
  538. padding: 28rpx;
  539. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
  540. }
  541. .chart-card .card-title {
  542. font-size: 28rpx;
  543. font-weight: 600;
  544. color: #333;
  545. display: block;
  546. margin-bottom: 4rpx;
  547. }
  548. .chart-card .card-subtitle {
  549. font-size: 22rpx;
  550. color: #999;
  551. display: block;
  552. margin-bottom: 16rpx;
  553. }
  554. .line-chart-canvas,
  555. .scatter-canvas {
  556. width: 100%;
  557. height: 360rpx;
  558. border-radius: 12rpx;
  559. background: #FCFCFC;
  560. }
  561. .calendar-card,
  562. .distribution-card,
  563. .daily-list-card {
  564. margin: 24rpx 32rpx;
  565. background: #fff;
  566. border-radius: 20rpx;
  567. padding: 28rpx;
  568. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
  569. }
  570. .card-title {
  571. font-size: 28rpx;
  572. font-weight: 600;
  573. color: #333;
  574. display: block;
  575. margin-bottom: 20rpx;
  576. }
  577. .calendar-grid {
  578. display: flex;
  579. flex-wrap: wrap;
  580. }
  581. .calendar-weekday {
  582. width: 14.28%;
  583. text-align: center;
  584. font-size: 22rpx;
  585. color: #999;
  586. padding: 10rpx 0;
  587. }
  588. .calendar-day {
  589. width: 14.28%;
  590. text-align: center;
  591. padding: 8rpx 0;
  592. min-height: 80rpx;
  593. display: flex;
  594. flex-direction: column;
  595. align-items: center;
  596. justify-content: center;
  597. border-radius: 8rpx;
  598. }
  599. .calendar-day.has-data {
  600. cursor: pointer;
  601. }
  602. .is-today {
  603. border: 2rpx solid #FF6B9D;
  604. box-sizing: border-box;
  605. }
  606. .day-num {
  607. font-size: 24rpx;
  608. color: #333;
  609. }
  610. .day-emoji-small {
  611. font-size: 20rpx;
  612. margin-top: 2rpx;
  613. }
  614. .day-score {
  615. font-size: 18rpx;
  616. color: #888;
  617. margin-top: 2rpx;
  618. }
  619. /* 热力图例 */
  620. .heatmap-legend {
  621. display: flex;
  622. align-items: center;
  623. justify-content: center;
  624. gap: 12rpx;
  625. margin-top: 16rpx;
  626. }
  627. .legend-label {
  628. font-size: 20rpx;
  629. color: #999;
  630. }
  631. .legend-bar {
  632. display: flex;
  633. gap: 2rpx;
  634. border-radius: 6rpx;
  635. overflow: hidden;
  636. }
  637. .legend-step {
  638. width: 24rpx;
  639. height: 16rpx;
  640. }
  641. /* ===== 情绪分布 ===== */
  642. .distribution-list {
  643. display: flex;
  644. flex-direction: column;
  645. gap: 16rpx;
  646. }
  647. .dist-item {
  648. display: flex;
  649. align-items: center;
  650. gap: 16rpx;
  651. }
  652. .dist-emoji {
  653. font-size: 32rpx;
  654. width: 48rpx;
  655. text-align: center;
  656. }
  657. .dist-label {
  658. font-size: 24rpx;
  659. color: #666;
  660. width: 120rpx;
  661. }
  662. .dist-bar-track {
  663. flex: 1;
  664. height: 20rpx;
  665. background: #F0F0F0;
  666. border-radius: 10rpx;
  667. overflow: hidden;
  668. }
  669. .dist-bar-fill {
  670. height: 100%;
  671. border-radius: 10rpx;
  672. transition: width 0.3s;
  673. }
  674. .dist-count {
  675. font-size: 24rpx;
  676. color: #999;
  677. width: 60rpx;
  678. text-align: right;
  679. }
  680. /* ===== 每日记录 ===== */
  681. .daily-item {
  682. display: flex;
  683. align-items: center;
  684. padding: 16rpx 0;
  685. border-bottom: 2rpx solid #F5F5F5;
  686. gap: 16rpx;
  687. }
  688. .daily-date {
  689. font-size: 24rpx;
  690. color: #999;
  691. width: 100rpx;
  692. flex-shrink: 0;
  693. }
  694. .daily-emoji {
  695. font-size: 32rpx;
  696. width: 40rpx;
  697. text-align: center;
  698. flex-shrink: 0;
  699. }
  700. .daily-weather {
  701. font-size: 26rpx;
  702. color: #666;
  703. width: 120rpx;
  704. flex-shrink: 0;
  705. }
  706. .daily-tags {
  707. display: flex;
  708. gap: 8rpx;
  709. flex-wrap: wrap;
  710. }
  711. .daily-tag {
  712. font-size: 20rpx;
  713. padding: 4rpx 12rpx;
  714. border-radius: 12rpx;
  715. color: #fff;
  716. }
  717. .score-tag { background: #FF6B9D; }
  718. .type-tag { background: #8B5CF6; }
  719. .arousal-tag { background: #3B82F6; }
  720. .empty-state {
  721. display: flex;
  722. flex-direction: column;
  723. align-items: center;
  724. padding: 120rpx 32rpx;
  725. }
  726. .empty-icon {
  727. font-size: 80rpx;
  728. margin-bottom: 20rpx;
  729. }
  730. .empty-text {
  731. font-size: 28rpx;
  732. color: #999;
  733. margin-bottom: 40rpx;
  734. }
  735. .empty-btn {
  736. background: #FF6B9D;
  737. color: #fff;
  738. padding: 16rpx 60rpx;
  739. border-radius: 40rpx;
  740. font-size: 28rpx;
  741. }
  742. </style>