emotion-trend.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  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. // 成长页(growth-emotion-checkin)历史词表
  141. 'calm': '平静', 'excited': '兴奋', 'sad': '难过', 'angry': '生气',
  142. 'anxious': '焦虑', 'tired': '疲惫', 'scared': '害怕'
  143. },
  144. // 散点/折线图数据
  145. scatterData: [],
  146. moodTrendData: [],
  147. // Canvas 上下文
  148. scatterCtx: null,
  149. trendCtx: null
  150. }
  151. },
  152. computed: {
  153. hasChildId() {
  154. return !!this.currentChildId
  155. },
  156. calendarDays() {
  157. const days = []
  158. const now = new Date()
  159. const year = now.getFullYear()
  160. const month = now.getMonth()
  161. const firstDay = new Date(year, month, 1).getDay()
  162. const daysInMonth = new Date(year, month + 1, 0).getDate()
  163. const today = now.getDate()
  164. // Build data map from dailyData
  165. const dataMap = {}
  166. if (this.trend && this.trend.dailyData) {
  167. for (const d of this.trend.dailyData) {
  168. if (d.date) {
  169. const dateObj = parseDate(d.date)
  170. if (!dateObj) continue
  171. dataMap[dateObj.getDate()] = d
  172. }
  173. }
  174. }
  175. // Empty leading cells
  176. for (let i = 0; i < firstDay; i++) {
  177. days.push({ dayNum: '', weather: null, moodScore: null, isToday: false, bgStyle: '' })
  178. }
  179. for (let d = 1; d <= daysInMonth; d++) {
  180. const data = dataMap[d]
  181. var bgStyle = ''
  182. if (data && data.moodScore) {
  183. // Heatmap intensity: moodScore 1-10 mapped to color
  184. var score = data.moodScore
  185. var r, g, b
  186. if (score <= 3) {
  187. // 1-3: red tint
  188. var intensity1 = (score - 1) / 2
  189. r = 255
  190. g = Math.round(180 + 75 * intensity1)
  191. b = Math.round(180 + 75 * intensity1)
  192. } else if (score <= 6) {
  193. // 4-6: orange/yellow tint
  194. var intensity2 = (score - 4) / 2
  195. r = 255
  196. g = Math.round(200 + 55 * intensity2)
  197. b = Math.round(160 - 60 * intensity2)
  198. } else {
  199. // 7-10: green tint
  200. var intensity3 = (score - 7) / 3
  201. r = Math.round(200 - 120 * intensity3)
  202. g = Math.round(230 - 20 * intensity3)
  203. b = Math.round(200 - 120 * intensity3)
  204. }
  205. bgStyle = 'background: rgba(' + r + ',' + g + ',' + b + ',0.4)'
  206. }
  207. days.push({
  208. dayNum: d,
  209. weather: data ? data.weather : null,
  210. moodScore: data ? data.moodScore : null,
  211. emotionType: data ? data.emotionType : null,
  212. arousalLevel: data ? data.arousalLevel : null,
  213. isToday: d === today,
  214. bgStyle: bgStyle
  215. })
  216. }
  217. return days
  218. },
  219. distributionData() {
  220. const dist = this.trend && this.trend.weatherDistribution
  221. if (!dist) return []
  222. const total = Object.values(dist).reduce((a, b) => a + b, 0)
  223. if (total === 0) return []
  224. return Object.keys(dist).map(w => {
  225. const cfg = this.weatherConfig[w] || { icon: '?', label: w, color: '#ccc' }
  226. return {
  227. weather: w,
  228. icon: cfg.icon,
  229. label: cfg.label,
  230. color: cfg.color,
  231. count: dist[w],
  232. percent: Math.round(dist[w] / total * 100)
  233. }
  234. })
  235. },
  236. dailyData() {
  237. return this.trend && this.trend.dailyData || []
  238. }
  239. },
  240. onLoad(options) {
  241. // memberId 优先取页面参数(成长页/情绪打卡页跳转传入),再兜底本地存储链
  242. var memberId = (options && options.memberId) || uni.getStorageSync('currentChildId') || uni.getStorageSync('currentMemberId') || uni.getStorageSync('userId') || null
  243. this.currentChildId = memberId
  244. this.loadData()
  245. },
  246. methods: {
  247. loadData() {
  248. var memberId = this.currentChildId
  249. if (!memberId) return
  250. uni.request({
  251. url: config.API_BASE_URL + '/api/mind/checkin/stats',
  252. method: 'POST',
  253. data: { memberId },
  254. success: (res) => {
  255. if (res.data && res.data.code === 200) {
  256. this.stats = res.data.data
  257. }
  258. }
  259. })
  260. uni.request({
  261. url: config.API_BASE_URL + '/api/mind/checkin/trend',
  262. method: 'POST',
  263. data: { memberId, period: this.period },
  264. success: (res) => {
  265. if (res.data && res.data.code === 200) {
  266. this.trend = res.data.data
  267. // Extract scatter & trend data
  268. this.scatterData = this.trend && this.trend.scatterData || []
  269. this.moodTrendData = this.trend && this.trend.moodTrend || []
  270. // Draw charts after data is ready
  271. this.$nextTick(function() {
  272. this.drawMoodTrend()
  273. this.drawScatter()
  274. })
  275. }
  276. }
  277. })
  278. },
  279. switchPeriod(p) {
  280. this.period = p
  281. this.loadData()
  282. },
  283. weatherEmoji(weather) {
  284. const cfg = this.weatherConfig[weather]
  285. return cfg ? cfg.icon : ''
  286. },
  287. weatherLabel(weather) {
  288. const cfg = this.weatherConfig[weather]
  289. return cfg ? cfg.label : weather
  290. },
  291. emotionTypeLabel(type) {
  292. return this.emotionTypeLabels[type] || type
  293. },
  294. formatDate(dateStr) {
  295. if (!dateStr) return ''
  296. const d = parseDate(dateStr)
  297. if (!d) return ''
  298. return (d.getMonth() + 1) + '/' + d.getDate()
  299. },
  300. goCheckin() {
  301. uni.navigateTo({ url: '/pages/mind-detail/emotion-checkin' })
  302. },
  303. showDayDetail(day) {
  304. // 点击日历格子可以跳转到当天的打卡详情
  305. // 简单 toast 显示评分
  306. uni.showToast({ title: '情绪评分: ' + day.moodScore + '/10', icon: 'none' })
  307. },
  308. viewDayCheckin(day) {
  309. // 查看单条打卡详情(当前简单响应)
  310. if (day.moodScore) {
  311. uni.showToast({ title: '情绪评分: ' + day.moodScore + '/10', icon: 'none' })
  312. }
  313. },
  314. // ===== Canvas 绘图 =====
  315. drawMoodTrend() {
  316. if (this.moodTrendData.length < 1) return
  317. var canvasId = 'moodTrendCanvas'
  318. var query = uni.createSelectorQuery()
  319. var self = this
  320. query.select('#' + canvasId).fields({ node: true, size: true }).exec(function(res) {
  321. // Fallback: use context API for older uni-app
  322. var ctx = uni.createCanvasContext(canvasId, self)
  323. var dpr = 2
  324. // Get canvas dimensions from the element
  325. query.select('#' + canvasId).boundingClientRect(function(rect) {
  326. if (!rect) return
  327. var width = rect.width || 300
  328. var height = rect.height || 200
  329. var canvasWidth = width * dpr
  330. var canvasHeight = height * dpr
  331. // Clear
  332. ctx.clearRect(0, 0, canvasWidth, canvasHeight)
  333. var data = self.moodTrendData
  334. var count = data.length
  335. if (count === 0) return
  336. var padding = { top: 20 * dpr, right: 20 * dpr, bottom: 30 * dpr, left: 30 * dpr }
  337. var plotW = canvasWidth - padding.left - padding.right
  338. var plotH = canvasHeight - padding.top - padding.bottom
  339. // Draw axes
  340. ctx.setStrokeStyle('#E0E0E0')
  341. ctx.setLineWidth(1 * dpr)
  342. ctx.beginPath()
  343. ctx.moveTo(padding.left, padding.top)
  344. ctx.lineTo(padding.left, padding.top + plotH)
  345. ctx.lineTo(padding.left + plotW, padding.top + plotH)
  346. ctx.stroke()
  347. // Draw Y axis labels
  348. ctx.setFontSize(10 * dpr)
  349. ctx.setFillStyle('#999')
  350. ctx.setTextAlign('right')
  351. for (var yVal = 2; yVal <= 10; yVal += 2) {
  352. var yPos = padding.top + plotH - (yVal / 10) * plotH
  353. ctx.fillText(yVal + '', padding.left - 6 * dpr, yPos + 3 * dpr)
  354. // Grid line
  355. ctx.setStrokeStyle('#F0F0F0')
  356. ctx.setLineWidth(1 * dpr)
  357. ctx.beginPath()
  358. ctx.moveTo(padding.left, yPos)
  359. ctx.lineTo(padding.left + plotW, yPos)
  360. ctx.stroke()
  361. }
  362. // Determine trend line color based on trend direction
  363. var avg = 0
  364. for (var si = 0; si < count; si++) {
  365. avg += data[si].moodScore
  366. }
  367. avg /= count
  368. var lineColor = avg >= 5 ? '#10B981' : '#FF6B9D'
  369. // Draw data points and lines
  370. ctx.setStrokeStyle(lineColor)
  371. ctx.setLineWidth(3 * dpr)
  372. ctx.setFillStyle(lineColor)
  373. for (var i = 0; i < count; i++) {
  374. var x = padding.left + (i / Math.max(count - 1, 1)) * plotW
  375. var y = padding.top + plotH - (data[i].moodScore / 10) * plotH
  376. if (i === 0) {
  377. ctx.beginPath()
  378. ctx.moveTo(x, y)
  379. } else {
  380. ctx.lineTo(x, y)
  381. }
  382. // Draw point circle
  383. ctx.beginPath()
  384. ctx.arc(x, y, 4 * dpr, 0, 2 * Math.PI)
  385. ctx.setFillStyle(lineColor)
  386. ctx.fill()
  387. }
  388. ctx.stroke()
  389. // Draw X axis labels (dates)
  390. ctx.setFontSize(9 * dpr)
  391. ctx.setFillStyle('#999')
  392. ctx.setTextAlign('center')
  393. var step = Math.max(1, Math.floor(count / 6))
  394. for (var di = 0; di < count; di += step) {
  395. var labelX = padding.left + (di / Math.max(count - 1, 1)) * plotW
  396. var labelText = self.formatDate(data[di].date)
  397. ctx.fillText(labelText, labelX, padding.top + plotH + 18 * dpr)
  398. }
  399. ctx.draw()
  400. }).exec()
  401. })
  402. },
  403. drawScatter() {
  404. if (this.scatterData.length < 3) return
  405. var canvasId = 'scatterCanvas'
  406. var query = uni.createSelectorQuery()
  407. var self = this
  408. query.select('#' + canvasId).boundingClientRect(function(rect) {
  409. if (!rect) return
  410. var ctx = uni.createCanvasContext(canvasId, self)
  411. var dpr = 2
  412. var width = rect.width || 300
  413. var height = rect.height || 200
  414. var canvasWidth = width * dpr
  415. var canvasHeight = height * dpr
  416. ctx.clearRect(0, 0, canvasWidth, canvasHeight)
  417. var padding = { top: 20 * dpr, right: 20 * dpr, bottom: 30 * dpr, left: 30 * dpr }
  418. var plotW = canvasWidth - padding.left - padding.right
  419. var plotH = canvasHeight - padding.top - padding.bottom
  420. // Draw background with 4 quadrants
  421. // Q1 (high arousal, high valence): top-right
  422. var midX = padding.left + plotW / 2
  423. var midY = padding.top + plotH / 2
  424. // Quadrant backgrounds
  425. ctx.setFillStyle('rgba(255,240,240,0.3)')
  426. ctx.fillRect(midX, padding.top, plotW / 2, plotH / 2) // high arousal, high valence
  427. ctx.setFillStyle('rgba(240,240,255,0.3)')
  428. ctx.fillRect(padding.left, padding.top, plotW / 2, plotH / 2) // high arousal, low valence
  429. ctx.setFillStyle('rgba(255,248,240,0.3)')
  430. ctx.fillRect(midX, midY, plotW / 2, plotH / 2) // low arousal, high valence
  431. ctx.setFillStyle('rgba(245,245,245,0.3)')
  432. ctx.fillRect(padding.left, midY, plotW / 2, plotH / 2) // low arousal, low valence
  433. // Quadrant labels
  434. ctx.setFontSize(10 * dpr)
  435. ctx.setFillStyle('rgba(0,0,0,0.15)')
  436. ctx.setTextAlign('center')
  437. ctx.fillText('兴奋', padding.left + plotW * 0.75, padding.top + plotH * 0.3)
  438. ctx.fillText('烦躁', padding.left + plotW * 0.25, padding.top + plotH * 0.3)
  439. ctx.fillText('平静', padding.left + plotW * 0.75, padding.top + plotH * 0.8)
  440. ctx.fillText('低落', padding.left + plotW * 0.25, padding.top + plotH * 0.8)
  441. // Axes
  442. ctx.setStrokeStyle('#E0E0E0')
  443. ctx.setLineWidth(1 * dpr)
  444. ctx.beginPath()
  445. ctx.moveTo(padding.left, padding.top + plotH / 2)
  446. ctx.lineTo(padding.left + plotW, padding.top + plotH / 2)
  447. ctx.stroke()
  448. ctx.beginPath()
  449. ctx.moveTo(padding.left + plotW / 2, padding.top)
  450. ctx.lineTo(padding.left + plotW / 2, padding.top + plotH)
  451. ctx.stroke()
  452. // Axis labels
  453. ctx.setFontSize(9 * dpr)
  454. ctx.setFillStyle('#999')
  455. ctx.setTextAlign('center')
  456. ctx.fillText('效价 →', padding.left + plotW / 2, padding.top + plotH + 18 * dpr)
  457. ctx.save()
  458. ctx.translate(padding.left - 4 * dpr, padding.top + plotH / 2)
  459. ctx.rotate(-Math.PI / 2)
  460. ctx.setTextAlign('center')
  461. ctx.fillText('激活度', 0, 0)
  462. ctx.restore()
  463. // Draw scatter points
  464. for (var i = 0; i < self.scatterData.length; i++) {
  465. var pt = self.scatterData[i]
  466. var px = padding.left + (pt.valence / 10) * plotW
  467. var py = padding.top + plotH - (pt.arousal / 10) * plotH
  468. // Color based on valence
  469. var color
  470. if (pt.valence >= 7) {
  471. color = '#10B981'
  472. } else if (pt.valence >= 5) {
  473. color = '#FFD93D'
  474. } else {
  475. color = '#FF6B9D'
  476. }
  477. ctx.beginPath()
  478. ctx.arc(px, py, 5 * dpr, 0, 2 * Math.PI)
  479. ctx.setFillStyle(color)
  480. ctx.setGlobalAlpha(0.7)
  481. ctx.fill()
  482. ctx.setGlobalAlpha(1)
  483. }
  484. ctx.draw()
  485. }).exec()
  486. }
  487. }
  488. }
  489. </script>
  490. <style scoped>
  491. .trend-container {
  492. min-height: 100vh;
  493. background: #F8F8F8;
  494. padding-bottom: 40rpx;
  495. }
  496. .stats-overview {
  497. display: flex;
  498. margin: 24rpx 32rpx;
  499. background: linear-gradient(135deg, #FF6B9D, #FF8CB3);
  500. border-radius: 20rpx;
  501. padding: 28rpx 16rpx;
  502. }
  503. .stat-item {
  504. flex: 1;
  505. text-align: center;
  506. }
  507. .stat-value {
  508. font-size: 36rpx;
  509. font-weight: 700;
  510. color: #fff;
  511. display: block;
  512. }
  513. .stat-label {
  514. font-size: 22rpx;
  515. color: rgba(255, 255, 255, 0.8);
  516. margin-top: 6rpx;
  517. display: block;
  518. }
  519. .period-tabs {
  520. display: flex;
  521. margin: 0 32rpx;
  522. background: #fff;
  523. border-radius: 12rpx;
  524. overflow: hidden;
  525. }
  526. .period-tab {
  527. flex: 1;
  528. text-align: center;
  529. padding: 16rpx 0;
  530. font-size: 26rpx;
  531. color: #666;
  532. }
  533. .period-active {
  534. background: #FF6B9D;
  535. color: #fff;
  536. font-weight: 600;
  537. }
  538. /* ===== 图表卡片 ===== */
  539. .chart-card {
  540. margin: 24rpx 32rpx;
  541. background: #fff;
  542. border-radius: 20rpx;
  543. padding: 28rpx;
  544. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
  545. }
  546. .chart-card .card-title {
  547. font-size: 28rpx;
  548. font-weight: 600;
  549. color: #333;
  550. display: block;
  551. margin-bottom: 4rpx;
  552. }
  553. .chart-card .card-subtitle {
  554. font-size: 22rpx;
  555. color: #999;
  556. display: block;
  557. margin-bottom: 16rpx;
  558. }
  559. .line-chart-canvas,
  560. .scatter-canvas {
  561. width: 100%;
  562. height: 360rpx;
  563. border-radius: 12rpx;
  564. background: #FCFCFC;
  565. }
  566. .calendar-card,
  567. .distribution-card,
  568. .daily-list-card {
  569. margin: 24rpx 32rpx;
  570. background: #fff;
  571. border-radius: 20rpx;
  572. padding: 28rpx;
  573. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
  574. }
  575. .card-title {
  576. font-size: 28rpx;
  577. font-weight: 600;
  578. color: #333;
  579. display: block;
  580. margin-bottom: 20rpx;
  581. }
  582. .calendar-grid {
  583. display: flex;
  584. flex-wrap: wrap;
  585. }
  586. .calendar-weekday {
  587. width: 14.28%;
  588. text-align: center;
  589. font-size: 22rpx;
  590. color: #999;
  591. padding: 10rpx 0;
  592. }
  593. .calendar-day {
  594. width: 14.28%;
  595. text-align: center;
  596. padding: 8rpx 0;
  597. min-height: 80rpx;
  598. display: flex;
  599. flex-direction: column;
  600. align-items: center;
  601. justify-content: center;
  602. border-radius: 8rpx;
  603. }
  604. .calendar-day.has-data {
  605. cursor: pointer;
  606. }
  607. .is-today {
  608. border: 2rpx solid #FF6B9D;
  609. box-sizing: border-box;
  610. }
  611. .day-num {
  612. font-size: 24rpx;
  613. color: #333;
  614. }
  615. .day-emoji-small {
  616. font-size: 20rpx;
  617. margin-top: 2rpx;
  618. }
  619. .day-score {
  620. font-size: 18rpx;
  621. color: #888;
  622. margin-top: 2rpx;
  623. }
  624. /* 热力图例 */
  625. .heatmap-legend {
  626. display: flex;
  627. align-items: center;
  628. justify-content: center;
  629. gap: 12rpx;
  630. margin-top: 16rpx;
  631. }
  632. .legend-label {
  633. font-size: 20rpx;
  634. color: #999;
  635. }
  636. .legend-bar {
  637. display: flex;
  638. gap: 2rpx;
  639. border-radius: 6rpx;
  640. overflow: hidden;
  641. }
  642. .legend-step {
  643. width: 24rpx;
  644. height: 16rpx;
  645. }
  646. /* ===== 情绪分布 ===== */
  647. .distribution-list {
  648. display: flex;
  649. flex-direction: column;
  650. gap: 16rpx;
  651. }
  652. .dist-item {
  653. display: flex;
  654. align-items: center;
  655. gap: 16rpx;
  656. }
  657. .dist-emoji {
  658. font-size: 32rpx;
  659. width: 48rpx;
  660. text-align: center;
  661. }
  662. .dist-label {
  663. font-size: 24rpx;
  664. color: #666;
  665. width: 120rpx;
  666. }
  667. .dist-bar-track {
  668. flex: 1;
  669. height: 20rpx;
  670. background: #F0F0F0;
  671. border-radius: 10rpx;
  672. overflow: hidden;
  673. }
  674. .dist-bar-fill {
  675. height: 100%;
  676. border-radius: 10rpx;
  677. transition: width 0.3s;
  678. }
  679. .dist-count {
  680. font-size: 24rpx;
  681. color: #999;
  682. width: 60rpx;
  683. text-align: right;
  684. }
  685. /* ===== 每日记录 ===== */
  686. .daily-item {
  687. display: flex;
  688. align-items: center;
  689. padding: 16rpx 0;
  690. border-bottom: 2rpx solid #F5F5F5;
  691. gap: 16rpx;
  692. }
  693. .daily-date {
  694. font-size: 24rpx;
  695. color: #999;
  696. width: 100rpx;
  697. flex-shrink: 0;
  698. }
  699. .daily-emoji {
  700. font-size: 32rpx;
  701. width: 40rpx;
  702. text-align: center;
  703. flex-shrink: 0;
  704. }
  705. .daily-weather {
  706. font-size: 26rpx;
  707. color: #666;
  708. width: 120rpx;
  709. flex-shrink: 0;
  710. }
  711. .daily-tags {
  712. display: flex;
  713. gap: 8rpx;
  714. flex-wrap: wrap;
  715. }
  716. .daily-tag {
  717. font-size: 20rpx;
  718. padding: 4rpx 12rpx;
  719. border-radius: 12rpx;
  720. color: #fff;
  721. }
  722. .score-tag { background: #FF6B9D; }
  723. .type-tag { background: #8B5CF6; }
  724. .arousal-tag { background: #3B82F6; }
  725. .empty-state {
  726. display: flex;
  727. flex-direction: column;
  728. align-items: center;
  729. padding: 120rpx 32rpx;
  730. }
  731. .empty-icon {
  732. font-size: 80rpx;
  733. margin-bottom: 20rpx;
  734. }
  735. .empty-text {
  736. font-size: 28rpx;
  737. color: #999;
  738. margin-bottom: 40rpx;
  739. }
  740. .empty-btn {
  741. background: #FF6B9D;
  742. color: #fff;
  743. padding: 16rpx 60rpx;
  744. border-radius: 40rpx;
  745. font-size: 28rpx;
  746. }
  747. </style>