emotion-checkin.vue 27 KB

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