emotion-checkin.vue 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046
  1. <template>
  2. <view class="checkin-container">
  3. <!-- 顶部:日期 + 连续打卡 -->
  4. <view class="checkin-header">
  5. <text class="checkin-date">{{ todayDisplay }}</text>
  6. <view class="streak-badge" v-if="stats && stats.currentStreak > 0">
  7. <text class="streak-icon">&#x1F525;</text>
  8. <text class="streak-text">连续{{ stats.currentStreak }}天</text>
  9. </view>
  10. </view>
  11. <!-- ===== Phase 1.1: 2D 效价-激活度网格 ===== -->
  12. <view class="section">
  13. <text class="section-title">在方格中点击你的情绪位置</text>
  14. <view class="affect-grid" @tap="onAffectGridTap">
  15. <!-- 象限标签 -->
  16. <text class="grid-label label-nw">烦躁/紧张</text>
  17. <text class="grid-label label-ne">兴奋/愉快</text>
  18. <text class="grid-label label-sw">低落/疲惫</text>
  19. <text class="grid-label label-se">平静/放松</text>
  20. <!-- 坐标轴 -->
  21. <text class="axis-label axis-bottom">消极 ← 情绪效价 → 积极</text>
  22. <text class="axis-label axis-left">激<br/>活<br/>度</text>
  23. <!-- 选中的圆点 -->
  24. <view class="affect-dot" :style="{ left: affectDotX + 'rpx', top: affectDotY + 'rpx' }">
  25. <view class="affect-dot-inner"></view>
  26. </view>
  27. </view>
  28. <view class="affect-values">
  29. <text class="affect-val">效价: {{ affectValence }}/10</text>
  30. <text class="affect-val">激活度: {{ affectArousal }}/10</text>
  31. </view>
  32. </view>
  33. <!-- ===== Plutchik 情绪轮 ===== -->
  34. <view class="section">
  35. <text class="section-title">选择你的核心情绪</text>
  36. <view class="emotion-wheel">
  37. <view
  38. v-for="em in plutchikEmotions"
  39. :key="em.type"
  40. :class="['emotion-btn', selectedEmotionType === em.type ? 'emotion-active' : '']"
  41. :style="{ borderColor: selectedEmotionType === em.type ? em.color : '#eee' }"
  42. @click="selectedEmotionType = em.type">
  43. <text class="emotion-icon">{{ em.icon }}</text>
  44. <text class="emotion-label">{{ em.label }}</text>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- ===== 强度滑条 ===== -->
  49. <view class="section">
  50. <text class="section-title">情绪强度</text>
  51. <view class="slider-row">
  52. <text class="slider-label">弱</text>
  53. <slider class="custom-slider" min="1" max="10" :value="intensityLevel" @change="onIntensityChange" activeColor="#FF6B9D" block-size="20" />
  54. <text class="slider-value">{{ intensityLevel }}</text>
  55. </view>
  56. <view class="intensity-hint">{{ intensityHint }}</view>
  57. </view>
  58. <!-- ===== 精力水平 ===== -->
  59. <view class="section">
  60. <text class="section-title">精力水平</text>
  61. <view class="slider-row">
  62. <text class="slider-label">低</text>
  63. <slider class="custom-slider" min="1" max="10" :value="energyLevel" @change="onEnergyChange" activeColor="#10B981" block-size="20" />
  64. <text class="slider-value">{{ energyLevel }}</text>
  65. </view>
  66. </view>
  67. <!-- ===== 压力水平 ===== -->
  68. <view class="section">
  69. <text class="section-title">压力水平</text>
  70. <view class="slider-row">
  71. <text class="slider-label">无压力</text>
  72. <slider class="custom-slider" min="1" max="10" :value="stressLevel" @change="onStressChange" activeColor="#F59E0B" block-size="20" />
  73. <text class="slider-value">{{ stressLevel }}</text>
  74. </view>
  75. </view>
  76. <!-- ===== 情绪标签(精细标签) ===== -->
  77. <view class="section">
  78. <text class="section-title">情绪标签(可多选)</text>
  79. <view class="tag-grid">
  80. <view
  81. v-for="tag in emotionTags"
  82. :key="tag"
  83. :class="['tag-btn', selectedTags.indexOf(tag) !== -1 ? 'tag-active' : '']"
  84. @click="toggleTag(tag)">
  85. <text>{{ tag }}</text>
  86. </view>
  87. </view>
  88. <view class="custom-tag-row" v-if="showCustomTagInput">
  89. <input class="custom-tag-input" v-model="customTag" placeholder="输入自定义情绪" />
  90. <text class="custom-tag-add" @click="addCustomTag">添加</text>
  91. </view>
  92. <text class="custom-tag-trigger" v-if="!showCustomTagInput" @click="showCustomTagInput = true">+ 自定义标签</text>
  93. </view>
  94. <!-- 拍照 -->
  95. <view class="section">
  96. <text class="section-title">拍一张照片记录心情</text>
  97. <view class="photo-area" @click="takePhoto">
  98. <image v-if="photoPath" :src="photoPath" mode="aspectFill" class="photo-preview" />
  99. <view v-else class="photo-placeholder">
  100. <text class="photo-icon">&#x1F4F7;</text>
  101. <text class="photo-hint">点击拍照</text>
  102. </view>
  103. </view>
  104. <text class="photo-note">照片仅对自己可见</text>
  105. </view>
  106. <!-- AI 情绪识别 -->
  107. <view class="section" v-if="photoPath">
  108. <text class="section-title">\uD83E\uDD16 AI 情绪识别</text>
  109. <view class="ai-recognize-btn" v-if="!aiResult && !aiAnalyzing" @click="analyzeEmotion">
  110. <text class="ai-btn-icon">\uD83D\uDD0D</text>
  111. <text class="ai-btn-text">识别照片中的情绪</text>
  112. </view>
  113. <view class="ai-analyzing" v-if="aiAnalyzing">
  114. <text class="ai-loading-text">AI 分析中...</text>
  115. </view>
  116. <view class="ai-result" v-if="aiResult">
  117. <text class="ai-result-title">识别结果</text>
  118. <view class="ai-emotion-list">
  119. <view class="ai-emotion-item" v-for="em in aiResult" :key="em.label">
  120. <text class="ai-emotion-label">{{ em.label }}</text>
  121. <view class="ai-emotion-bar-track">
  122. <view class="ai-emotion-bar-fill" :style="{ width: em.confidence + '%', background: em.color }"></view>
  123. </view>
  124. <text class="ai-emotion-value">{{ em.confidence }}%</text>
  125. </view>
  126. </view>
  127. <view class="ai-apply-tags" @click="applyAiTags">
  128. <text class="ai-apply-text">应用为情绪标签</text>
  129. </view>
  130. </view>
  131. </view>
  132. <!-- 文字记录 -->
  133. <view class="section">
  134. <text class="section-title">记录一下(选填)</text>
  135. <textarea
  136. class="note-input"
  137. v-model="note"
  138. placeholder="今天发生了什么?"
  139. maxlength="500" />
  140. </view>
  141. <!-- 提交按钮 -->
  142. <view class="submit-area">
  143. <button
  144. class="submit-btn"
  145. :class="{ 'submit-disabled': !canSubmit }"
  146. :disabled="!canSubmit"
  147. @click="submitCheckin">
  148. <text class="submit-icon">&#x2764;</text>
  149. <text>记录心情</text>
  150. </button>
  151. </view>
  152. <!-- 提交中 loading -->
  153. <view class="loading-mask" v-if="submitting">
  154. <view class="loading-box">
  155. <text class="loading-text">记录中...</text>
  156. </view>
  157. </view>
  158. </view>
  159. </template>
  160. <script>
  161. import config from '../../config'
  162. export default {
  163. data() {
  164. return {
  165. // --- 2D 效价-激活度网格 ---
  166. affectValence: 5, // 1-10
  167. affectArousal: 5, // 1-10
  168. gridWidth: 360, // rpx, 会在 onReady 中动态计算
  169. gridHeight: 360,
  170. // --- Plutchik 情绪轮 ---
  171. selectedEmotionType: '',
  172. // --- 滑条 ---
  173. intensityLevel: 5,
  174. energyLevel: 6,
  175. stressLevel: 4,
  176. // --- 旧字段保留兼容 ---
  177. selectedWeather: 'sunny', // 自动从效价映射
  178. selectedTags: [],
  179. customTag: '',
  180. showCustomTagInput: false,
  181. photoPath: '',
  182. note: '',
  183. submitting: false,
  184. aiAnalyzing: false,
  185. aiResult: null,
  186. aiEmotionColors: {
  187. '开心': '#10B981',
  188. '平静': '#3B82F6',
  189. '惊喜': '#8B5CF6',
  190. '难过': '#6B9BD2',
  191. '生气': '#EF4444',
  192. '紧张': '#F59E0B',
  193. '疲惫': '#9CA3AF',
  194. '害怕': '#7C3AED'
  195. },
  196. stats: null,
  197. // Plutchik 8 基本情绪
  198. plutchikEmotions: [
  199. { type: 'joy', icon: '\uD83D\uDE04', label: '开心', color: '#FFD93D' },
  200. { type: 'trust', icon: '\uD83E\uDD1D', label: '信任', color: '#6BCB77' },
  201. { type: 'fear', icon: '\uD83D\uDE31', label: '恐惧', color: '#9B59B6' },
  202. { type: 'surprise', icon: '\uD83D\uDE32', label: '惊讶', color: '#FF9FF3' },
  203. { type: 'sadness', icon: '\uD83D\uDE22', label: '悲伤', color: '#6B9BD2' },
  204. { type: 'disgust', icon: '\uD83E\uDD2E', label: '厌恶', color: '#A0A0A0' },
  205. { type: 'anger', icon: '\uD83D\uDE21', label: '愤怒', color: '#FF6B6B' },
  206. { type: 'anticipation',icon: '\uD83E\uDD29', label: '期待', color: '#FF8C42' }
  207. ],
  208. emotionTags: ['开心', '期待', '平静', '惊喜', '难过', '生气', '紧张', '无聊', '疲惫', '害怕'],
  209. // 强度提示文案
  210. intensityHints: {
  211. 1: '几乎感觉不到',
  212. 2: '很微弱',
  213. 3: '有一点',
  214. 4: '稍微明显',
  215. 5: '中等强度',
  216. 6: '比较明显',
  217. 7: '相当强烈',
  218. 8: '很强烈',
  219. 9: '非常强烈',
  220. 10: '前所未有的强烈'
  221. }
  222. }
  223. },
  224. computed: {
  225. todayDisplay() {
  226. const now = new Date()
  227. const y = now.getFullYear()
  228. const m = now.getMonth() + 1
  229. const d = now.getDate()
  230. const weekdays = ['日', '一', '二', '三', '四', '五', '六']
  231. return y + '年' + m + '月' + d + '日 周' + weekdays[now.getDay()]
  232. },
  233. canSubmit() {
  234. return this.affectValence > 0 && this.selectedEmotionType
  235. },
  236. // 圆点位置(rpx)
  237. affectDotX() {
  238. // valence 1-10 → 0 to gridWidth
  239. // 留出边距: 从 20 到 gridWidth-20
  240. const margin = 20
  241. const usable = this.gridWidth - 2 * margin
  242. return margin + ((this.affectValence - 1) / 9) * usable
  243. },
  244. affectDotY() {
  245. // arousal 1-10 → gridHeight to 0 (Y轴反向)
  246. const margin = 20
  247. const usable = this.gridHeight - 2 * margin
  248. return margin + (1 - (this.affectArousal - 1) / 9) * usable
  249. },
  250. intensityHint() {
  251. return this.intensityHints[this.intensityLevel] || ''
  252. }
  253. },
  254. onLoad() {
  255. this.loadStats()
  256. },
  257. onReady() {
  258. // 估算 grid 尺寸(基于屏幕宽度)
  259. var sysInfo = uni.getSystemInfoSync()
  260. // 页面左右margin=32rpx, section padding=28rpx
  261. // gridWidth ≈ screenWidth - (32+28)*2 = screenWidth - 120
  262. var screenWidth = sysInfo.windowWidth
  263. var gridRpx = screenWidth - 120 // 估算 rpx
  264. if (gridRpx < 300) gridRpx = 300
  265. this.gridWidth = gridRpx
  266. this.gridHeight = gridRpx
  267. },
  268. methods: {
  269. loadStats() {
  270. const app = getApp()
  271. const childId = app.globalData.currentChildId
  272. if (!childId) return
  273. uni.request({
  274. url: config.API_BASE_URL + '/api/mind/checkin/stats',
  275. method: 'POST',
  276. data: { childId },
  277. success: (res) => {
  278. if (res.data && res.data.code === 200 && res.data.data) {
  279. this.stats = res.data.data
  280. }
  281. }
  282. })
  283. },
  284. // ===== 2D 效价-激活度网格 =====
  285. onAffectGridTap(e) {
  286. // 获取点击相对位置
  287. var rect = e.target
  288. // 使用 touches 或 detail
  289. var x = e.detail && e.detail.x ? e.detail.x : 0
  290. var y = e.detail && e.detail.y ? e.detail.y : 0
  291. // fallback: 从 pageX/pageY 计算(推荐)
  292. if (e.detail && e.detail.x !== undefined) {
  293. // uni-app 在 @tap 事件中 detail 有 x/y 表示相对于目标元素的偏移
  294. x = e.detail.x
  295. y = e.detail.y
  296. }
  297. // px → rpx 转换
  298. var sysInfo = uni.getSystemInfoSync()
  299. var scale = 750 / sysInfo.windowWidth
  300. // 直接使用事件中的偏移(px),然后转 rpx
  301. // 注意: 如果 e.detail 没有 x/y,尝试从 e.touches 获取
  302. if ((x === 0 && y === 0) || !e.detail.x) {
  303. var touch = e.touches ? e.touches[0] : null
  304. if (touch) {
  305. // 需要根据 grid 的位置计算相对偏移
  306. x = touch.x || 0
  307. y = touch.y || 0
  308. }
  309. }
  310. // 直接用 rpx 计算,简化版:click 的位置相对 grid 容器
  311. // uni-app 的 @tap 的 detail = {x, y} 是相对于被点击元素的 px 值
  312. var pxX = e.detail.x || 0
  313. var pxY = e.detail.y || 0
  314. var rpxX = pxX * scale
  315. var rpxY = pxY * scale
  316. // 约束在有效范围内
  317. var margin = 20
  318. var maxRpx = this.gridWidth - margin
  319. if (rpxX < margin) rpxX = margin
  320. if (rpxX > maxRpx) rpxX = maxRpx
  321. if (rpxY < margin) rpxY = margin
  322. if (rpxY > this.gridHeight - margin) rpxY = this.gridHeight - margin
  323. // 映射到 1-10
  324. var usable = this.gridWidth - 2 * margin
  325. var val = Math.round(1 + ((rpxX - margin) / usable) * 9)
  326. var aro = Math.round(10 - ((rpxY - margin) / usable) * 9)
  327. this.affectValence = Math.max(1, Math.min(10, val))
  328. this.affectArousal = Math.max(1, Math.min(10, aro))
  329. // 自动映射 moodWeather 用于向后兼容
  330. this.updateWeatherFromAffect()
  331. },
  332. updateWeatherFromAffect() {
  333. // 效价高 + 激活度高 = rainbow
  334. if (this.affectValence >= 7 && this.affectArousal >= 7) {
  335. this.selectedWeather = 'rainbow'
  336. } else if (this.affectValence >= 6) {
  337. // 效价高 = sunny
  338. this.selectedWeather = 'sunny'
  339. } else if (this.affectValence <= 4 && this.affectArousal >= 7) {
  340. // 效价低 + 激活度高 = stormy
  341. this.selectedWeather = 'stormy'
  342. } else if (this.affectValence <= 4 && this.affectArousal <= 4) {
  343. // 效价低 + 激活度低 = rainy
  344. this.selectedWeather = 'rainy'
  345. } else {
  346. this.selectedWeather = 'cloudy'
  347. }
  348. },
  349. // ===== 滑条变化 =====
  350. onIntensityChange(e) {
  351. this.intensityLevel = e.detail.value
  352. },
  353. onEnergyChange(e) {
  354. this.energyLevel = e.detail.value
  355. },
  356. onStressChange(e) {
  357. this.stressLevel = e.detail.value
  358. },
  359. // ===== 情绪标签 =====
  360. toggleTag(tag) {
  361. const idx = this.selectedTags.indexOf(tag)
  362. if (idx !== -1) {
  363. this.selectedTags.splice(idx, 1)
  364. } else {
  365. this.selectedTags.push(tag)
  366. }
  367. },
  368. addCustomTag() {
  369. const tag = this.customTag.trim()
  370. if (tag && this.emotionTags.indexOf(tag) === -1 && this.selectedTags.indexOf(tag) === -1) {
  371. this.selectedTags.push(tag)
  372. }
  373. this.customTag = ''
  374. this.showCustomTagInput = false
  375. },
  376. // ===== 拍照 & AI =====
  377. takePhoto() {
  378. uni.chooseImage({
  379. count: 1,
  380. sourceType: ['camera', 'album'],
  381. success: (res) => {
  382. this.photoPath = res.tempFilePaths[0]
  383. this.aiResult = null
  384. }
  385. })
  386. },
  387. analyzeEmotion() {
  388. this.aiAnalyzing = true
  389. this.aiResult = null
  390. var self = this
  391. setTimeout(function() {
  392. self.aiAnalyzing = false
  393. var baseEmotions = [
  394. { label: '开心', confidence: 45, color: '#10B981' },
  395. { label: '平静', confidence: 30, color: '#3B82F6' },
  396. { label: '惊喜', confidence: 15, color: '#8B5CF6' },
  397. { label: '疲惫', confidence: 10, color: '#9CA3AF' }
  398. ]
  399. // Adjust based on affect valence
  400. if (self.affectValence <= 4) {
  401. baseEmotions = [
  402. { label: '难过', confidence: 55, color: '#6B9BD2' },
  403. { label: '疲惫', confidence: 25, color: '#9CA3AF' },
  404. { label: '平静', confidence: 12, color: '#3B82F6' },
  405. { label: '生气', confidence: 8, color: '#EF4444' }
  406. ]
  407. } else if (self.affectValence >= 8) {
  408. baseEmotions = [
  409. { label: '开心', confidence: 60, color: '#10B981' },
  410. { label: '惊喜', confidence: 25, color: '#8B5CF6' },
  411. { label: '平静', confidence: 10, color: '#3B82F6' },
  412. { label: '期待', confidence: 5, color: '#F59E0B' }
  413. ]
  414. }
  415. self.aiResult = baseEmotions
  416. }, 1200)
  417. },
  418. applyAiTags() {
  419. if (!this.aiResult) return
  420. var detected = []
  421. for (var i = 0; i < this.aiResult.length; i++) {
  422. var em = this.aiResult[i]
  423. if (em.confidence >= 20 && this.emotionTags.indexOf(em.label) !== -1) {
  424. detected.push(em.label)
  425. }
  426. }
  427. var merged = this.selectedTags.slice()
  428. for (var j = 0; j < detected.length; j++) {
  429. if (merged.indexOf(detected[j]) === -1) {
  430. merged.push(detected[j])
  431. }
  432. }
  433. this.selectedTags = merged
  434. uni.showToast({ title: '已应用情绪标签', icon: 'success' })
  435. },
  436. // ===== 提交 =====
  437. submitCheckin() {
  438. if (!this.canSubmit || this.submitting) return
  439. this.submitting = true
  440. const app = getApp()
  441. const childId = app.globalData.currentChildId
  442. const doSubmit = (photoUrl) => {
  443. uni.request({
  444. url: config.API_BASE_URL + '/api/mind/checkin/create',
  445. method: 'POST',
  446. data: {
  447. childId: childId,
  448. // 旧字段向后兼容
  449. moodWeather: this.selectedWeather,
  450. emotionTags: JSON.stringify(this.selectedTags),
  451. photoUrl: photoUrl || '',
  452. note: this.note,
  453. // Phase 1.1 精细情绪字段
  454. moodScore: this.affectValence,
  455. emotionType: this.selectedEmotionType,
  456. stressLevel: this.stressLevel,
  457. arousalLevel: this.affectArousal,
  458. energyLevel: this.energyLevel
  459. },
  460. success: (res) => {
  461. this.submitting = false
  462. if (res.data && res.data.code === 200) {
  463. uni.showToast({
  464. title: '+5 心能量',
  465. icon: 'none',
  466. duration: 2000
  467. })
  468. setTimeout(() => {
  469. uni.navigateTo({ url: '/pages/mind/emotion-trend' })
  470. }, 1500)
  471. } else {
  472. uni.showToast({ title: res.data && res.data.message || '提交失败', icon: 'none' })
  473. }
  474. },
  475. fail: () => {
  476. this.submitting = false
  477. uni.showToast({ title: '网络错误', icon: 'none' })
  478. }
  479. })
  480. }
  481. if (this.photoPath) {
  482. uni.uploadFile({
  483. url: config.API_BASE_URL + '/api/upload',
  484. filePath: this.photoPath,
  485. name: 'file',
  486. success: (uploadRes) => {
  487. let photoUrl = ''
  488. try {
  489. const data = JSON.parse(uploadRes.data)
  490. photoUrl = data.data || data.url || ''
  491. } catch (e) {
  492. photoUrl = uploadRes.data
  493. }
  494. doSubmit(photoUrl)
  495. },
  496. fail: () => doSubmit('')
  497. })
  498. } else {
  499. doSubmit('')
  500. }
  501. }
  502. }
  503. }
  504. </script>
  505. <style scoped>
  506. .checkin-container {
  507. min-height: 100vh;
  508. background: linear-gradient(180deg, #FFF0F5 0%, #FFFFFF 100%);
  509. padding-bottom: 40rpx;
  510. }
  511. .checkin-header {
  512. display: flex;
  513. align-items: center;
  514. justify-content: space-between;
  515. padding: 30rpx 32rpx;
  516. }
  517. .checkin-date {
  518. font-size: 32rpx;
  519. font-weight: 600;
  520. color: #333;
  521. }
  522. .streak-badge {
  523. display: flex;
  524. align-items: center;
  525. background: linear-gradient(135deg, #FF6B9D, #FF8CB3);
  526. border-radius: 30rpx;
  527. padding: 8rpx 24rpx;
  528. }
  529. .streak-icon {
  530. font-size: 28rpx;
  531. margin-right: 8rpx;
  532. }
  533. .streak-text {
  534. font-size: 24rpx;
  535. color: #fff;
  536. font-weight: 500;
  537. }
  538. .section {
  539. margin: 20rpx 32rpx;
  540. background: #fff;
  541. border-radius: 20rpx;
  542. padding: 28rpx;
  543. box-shadow: 0 2rpx 12rpx rgba(255, 107, 157, 0.08);
  544. }
  545. .section-title {
  546. font-size: 28rpx;
  547. font-weight: 600;
  548. color: #333;
  549. margin-bottom: 20rpx;
  550. display: block;
  551. }
  552. /* ===== 2D 效价-激活度网格 ===== */
  553. .affect-grid {
  554. position: relative;
  555. width: 100%;
  556. /* height is set dynamically equal to width via aspect-ratio or inline style */
  557. aspect-ratio: 1;
  558. background: linear-gradient(135deg, #FFF5F5 0%, #FFF0FF 25%, #F0F0FF 50%, #F0FFF4 75%, #FFFFF0 100%);
  559. border-radius: 16rpx;
  560. border: 2rpx solid #E8E8E8;
  561. margin-bottom: 16rpx;
  562. /* Ensure the grid has a defined height — fallback */
  563. min-height: 300rpx;
  564. /* Overlap grid lines for visual clarity */
  565. overflow: hidden;
  566. }
  567. /* 网格线:用伪元素或背景渐变 */
  568. .affect-grid::before {
  569. content: '';
  570. position: absolute;
  571. left: 50%;
  572. top: 0;
  573. bottom: 0;
  574. width: 2rpx;
  575. background: rgba(0,0,0,0.06);
  576. transform: translateX(-50%);
  577. pointer-events: none;
  578. }
  579. .affect-grid::after {
  580. content: '';
  581. position: absolute;
  582. top: 50%;
  583. left: 0;
  584. right: 0;
  585. height: 2rpx;
  586. background: rgba(0,0,0,0.06);
  587. transform: translateY(-50%);
  588. pointer-events: none;
  589. }
  590. .grid-label {
  591. position: absolute;
  592. font-size: 22rpx;
  593. color: rgba(0,0,0,0.25);
  594. pointer-events: none;
  595. }
  596. .label-nw { top: 20rpx; left: 20rpx; }
  597. .label-ne { top: 20rpx; right: 20rpx; }
  598. .label-sw { bottom: 20rpx; left: 20rpx; }
  599. .label-se { bottom: 20rpx; right: 20rpx; }
  600. .axis-label {
  601. position: absolute;
  602. font-size: 20rpx;
  603. color: rgba(0,0,0,0.2);
  604. pointer-events: none;
  605. }
  606. .axis-bottom {
  607. bottom: 4rpx;
  608. left: 50%;
  609. transform: translateX(-50%);
  610. white-space: nowrap;
  611. }
  612. .axis-left {
  613. left: 4rpx;
  614. top: 50%;
  615. transform: translateY(-50%);
  616. font-size: 18rpx;
  617. line-height: 1.4;
  618. text-align: center;
  619. }
  620. .affect-dot {
  621. position: absolute;
  622. width: 44rpx;
  623. height: 44rpx;
  624. margin-left: -22rpx;
  625. margin-top: -22rpx;
  626. pointer-events: none;
  627. z-index: 2;
  628. }
  629. .affect-dot-inner {
  630. width: 100%;
  631. height: 100%;
  632. border-radius: 50%;
  633. background: #FF6B9D;
  634. box-shadow: 0 0 12rpx rgba(255, 107, 157, 0.5);
  635. border: 4rpx solid #fff;
  636. box-sizing: border-box;
  637. }
  638. .affect-values {
  639. display: flex;
  640. justify-content: center;
  641. gap: 40rpx;
  642. }
  643. .affect-val {
  644. font-size: 24rpx;
  645. color: #888;
  646. }
  647. /* ===== Plutchik 情绪轮 ===== */
  648. .emotion-wheel {
  649. display: flex;
  650. flex-wrap: wrap;
  651. gap: 16rpx;
  652. justify-content: center;
  653. }
  654. .emotion-btn {
  655. display: flex;
  656. flex-direction: column;
  657. align-items: center;
  658. width: 130rpx;
  659. padding: 16rpx 8rpx;
  660. border-radius: 20rpx;
  661. border: 3rpx solid #eee;
  662. background: #FAFAFA;
  663. transition: all 0.2s;
  664. }
  665. .emotion-active {
  666. background: #FFF0F5;
  667. transform: scale(1.05);
  668. }
  669. .emotion-icon {
  670. font-size: 48rpx;
  671. margin-bottom: 6rpx;
  672. }
  673. .emotion-label {
  674. font-size: 24rpx;
  675. color: #555;
  676. }
  677. /* ===== 滑条 ===== */
  678. .slider-row {
  679. display: flex;
  680. align-items: center;
  681. gap: 16rpx;
  682. }
  683. .slider-label {
  684. font-size: 24rpx;
  685. color: #999;
  686. white-space: nowrap;
  687. width: 64rpx;
  688. }
  689. .custom-slider {
  690. flex: 1;
  691. }
  692. .slider-value {
  693. font-size: 28rpx;
  694. font-weight: 600;
  695. color: #FF6B9D;
  696. width: 40rpx;
  697. text-align: center;
  698. }
  699. .intensity-hint {
  700. font-size: 22rpx;
  701. color: #aaa;
  702. text-align: center;
  703. margin-top: 4rpx;
  704. }
  705. /* ===== 情绪标签 ===== */
  706. .tag-grid {
  707. display: flex;
  708. flex-wrap: wrap;
  709. gap: 16rpx;
  710. }
  711. .tag-btn {
  712. padding: 12rpx 28rpx;
  713. border-radius: 30rpx;
  714. background: #F5F5F5;
  715. font-size: 26rpx;
  716. color: #666;
  717. border: 2rpx solid transparent;
  718. }
  719. .tag-active {
  720. background: #FFF0F5;
  721. color: #FF6B9D;
  722. border-color: #FF6B9D;
  723. }
  724. .custom-tag-row {
  725. display: flex;
  726. align-items: center;
  727. margin-top: 16rpx;
  728. gap: 16rpx;
  729. }
  730. .custom-tag-input {
  731. flex: 1;
  732. height: 60rpx;
  733. border: 2rpx solid #E0E0E0;
  734. border-radius: 12rpx;
  735. padding: 0 16rpx;
  736. font-size: 26rpx;
  737. }
  738. .custom-tag-add {
  739. padding: 12rpx 24rpx;
  740. background: #FF6B9D;
  741. color: #fff;
  742. border-radius: 12rpx;
  743. font-size: 26rpx;
  744. }
  745. .custom-tag-trigger {
  746. display: inline-block;
  747. margin-top: 16rpx;
  748. color: #FF6B9D;
  749. font-size: 26rpx;
  750. }
  751. /* ===== 拍照 ===== */
  752. .photo-area {
  753. width: 200rpx;
  754. height: 200rpx;
  755. border-radius: 16rpx;
  756. overflow: hidden;
  757. background: #F5F5F5;
  758. display: flex;
  759. align-items: center;
  760. justify-content: center;
  761. }
  762. .photo-preview {
  763. width: 100%;
  764. height: 100%;
  765. }
  766. .photo-placeholder {
  767. display: flex;
  768. flex-direction: column;
  769. align-items: center;
  770. }
  771. .photo-icon {
  772. font-size: 60rpx;
  773. }
  774. .photo-hint {
  775. font-size: 24rpx;
  776. color: #999;
  777. margin-top: 8rpx;
  778. }
  779. .photo-note {
  780. display: block;
  781. font-size: 22rpx;
  782. color: #999;
  783. margin-top: 12rpx;
  784. }
  785. /* ===== AI 情绪识别 ===== */
  786. .ai-recognize-btn {
  787. display: flex;
  788. align-items: center;
  789. justify-content: center;
  790. padding: 20rpx;
  791. background: linear-gradient(135deg, #8B5CF6, #A78BFA);
  792. border-radius: 16rpx;
  793. cursor: pointer;
  794. }
  795. .ai-btn-icon {
  796. font-size: 32rpx;
  797. margin-right: 10rpx;
  798. }
  799. .ai-btn-text {
  800. font-size: 26rpx;
  801. color: #fff;
  802. font-weight: 500;
  803. }
  804. .ai-recognize-btn:active {
  805. opacity: 0.8;
  806. }
  807. .ai-analyzing {
  808. display: flex;
  809. align-items: center;
  810. justify-content: center;
  811. padding: 30rpx 0;
  812. }
  813. .ai-loading-text {
  814. font-size: 26rpx;
  815. color: #8B5CF6;
  816. }
  817. .ai-result {
  818. margin-top: 16rpx;
  819. }
  820. .ai-result-title {
  821. font-size: 24rpx;
  822. color: #666;
  823. margin-bottom: 12rpx;
  824. display: block;
  825. }
  826. .ai-emotion-list {
  827. display: flex;
  828. flex-direction: column;
  829. gap: 12rpx;
  830. }
  831. .ai-emotion-item {
  832. display: flex;
  833. align-items: center;
  834. gap: 12rpx;
  835. }
  836. .ai-emotion-label {
  837. font-size: 24rpx;
  838. color: #333;
  839. width: 64rpx;
  840. flex-shrink: 0;
  841. }
  842. .ai-emotion-bar-track {
  843. flex: 1;
  844. height: 16rpx;
  845. background: #F0F0F0;
  846. border-radius: 8rpx;
  847. overflow: hidden;
  848. }
  849. .ai-emotion-bar-fill {
  850. height: 100%;
  851. border-radius: 8rpx;
  852. transition: width 0.5s;
  853. }
  854. .ai-emotion-value {
  855. font-size: 22rpx;
  856. color: #999;
  857. width: 56rpx;
  858. text-align: right;
  859. }
  860. .ai-apply-tags {
  861. margin-top: 20rpx;
  862. padding: 16rpx;
  863. background: #F5F0FF;
  864. border-radius: 12rpx;
  865. text-align: center;
  866. cursor: pointer;
  867. }
  868. .ai-apply-text {
  869. font-size: 26rpx;
  870. color: #8B5CF6;
  871. font-weight: 500;
  872. }
  873. .ai-apply-tags:active {
  874. opacity: 0.7;
  875. }
  876. .note-input {
  877. width: 100%;
  878. min-height: 140rpx;
  879. background: #F9F9F9;
  880. border-radius: 12rpx;
  881. padding: 20rpx;
  882. font-size: 26rpx;
  883. color: #333;
  884. box-sizing: border-box;
  885. }
  886. .submit-area {
  887. margin: 40rpx 32rpx;
  888. }
  889. .submit-btn {
  890. width: 100%;
  891. height: 88rpx;
  892. line-height: 88rpx;
  893. background: linear-gradient(135deg, #FF6B9D, #FF8CB3);
  894. color: #fff;
  895. border-radius: 44rpx;
  896. font-size: 30rpx;
  897. font-weight: 600;
  898. display: flex;
  899. align-items: center;
  900. justify-content: center;
  901. }
  902. .submit-disabled {
  903. opacity: 0.5;
  904. }
  905. .submit-icon {
  906. margin-right: 8rpx;
  907. }
  908. .loading-mask {
  909. position: fixed;
  910. top: 0;
  911. left: 0;
  912. right: 0;
  913. bottom: 0;
  914. background: rgba(0, 0, 0, 0.3);
  915. display: flex;
  916. align-items: center;
  917. justify-content: center;
  918. z-index: 999;
  919. }
  920. .loading-box {
  921. background: #fff;
  922. padding: 40rpx 60rpx;
  923. border-radius: 20rpx;
  924. }
  925. .loading-text {
  926. font-size: 28rpx;
  927. color: #666;
  928. }
  929. </style>