emotion-trend.vue 23 KB

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