diet-checkin.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <template>
  2. <view class="page" :style="{ '--font-scale': fontScale }">
  3. <!-- 顶部导航栏 -->
  4. <view class="nav-bar">
  5. <view class="nav-left" @click="goBack">
  6. <text class="nav-icon">‹</text>
  7. <text class="nav-title">{{ todayText }}</text>
  8. </view>
  9. </view>
  10. <scroll-view class="content" scroll-y>
  11. <!-- 补打提示 -->
  12. <view class="backfill-banner" v-if="form.isBackfill">
  13. <text class="backfill-icon">⏪</text>
  14. <text class="backfill-text">补打模式:{{ form.recordDate }} 的记录,无能量值</text>
  15. </view>
  16. <!-- 餐次选择 -->
  17. <view class="card">
  18. <view class="card-header">
  19. <text class="card-icon">🍽️</text>
  20. <text class="card-title">选择餐次(可多选)</text>
  21. </view>
  22. <view class="card-body">
  23. <view class="tag-row">
  24. <TagChip v-for="m in mealTypes" :key="m.value" :label="m.label"
  25. :active="form.mealTypes.indexOf(m.value) > -1"
  26. @select="toggleMealType(m.value)" />
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 食物清单 & 备注 -->
  31. <view class="card">
  32. <view class="card-header">
  33. <text class="card-icon">📝</text>
  34. <text class="card-title">记录详情</text>
  35. </view>
  36. <view class="card-body">
  37. <view class="form-group">
  38. <text class="form-label">食物清单</text>
  39. <textarea class="form-textarea" v-model="form.foodItems" placeholder="吃了什么?如:米饭1碗、青菜、鸡腿" maxlength="200"></textarea>
  40. </view>
  41. <view class="form-group">
  42. <text class="form-label">备注(选填)</text>
  43. <input class="form-input" v-model="form.remark" placeholder="今天的饮食感受..." />
  44. </view>
  45. </view>
  46. </view>
  47. <!-- 媒体工具栏 -->
  48. <view class="card">
  49. <view class="card-header">
  50. <text class="card-icon">📎</text>
  51. <text class="card-title">添加媒体</text>
  52. </view>
  53. <view class="recognize-quota-hint" v-if="foodRecognizeQuota && !foodRecognizeQuota.unlimited && foodRecognizeQuota.total > 0">
  54. <text class="recognize-quota-hint-text">今日还可识别 {{foodRecognizeQuota.remaining || 0}}/{{foodRecognizeQuota.total}} 次,升级 FAMILY 不限次</text>
  55. </view>
  56. <view class="card-body">
  57. <view class="media-toolbar">
  58. <view class="tool-btn" @click="choosePhoto">
  59. <text class="tool-icon">📷</text>
  60. <text class="tool-label">照片</text>
  61. <text class="tool-count" v-if="form.photos.length > 0">{{ form.photos.length }}/9</text>
  62. </view>
  63. <view class="tool-divider"></view>
  64. <view class="tool-btn" @click="toggleRecord">
  65. <text class="tool-icon">🎙</text>
  66. <text class="tool-label">{{ isRecording ? '录音中…' : (form.voicePath ? '已录制' : '录音') }}</text>
  67. <text class="tool-count" v-if="isRecording">{{ recordSeconds }}s</text>
  68. </view>
  69. </view>
  70. <!-- 照片缩略图 -->
  71. <view class="photo-strip" v-if="form.photos.length > 0">
  72. <view class="photo-item" v-for="(img, idx) in form.photos" :key="getPhotoKey(img, idx)" @click="removePhoto(idx)">
  73. <image :src="img" mode="aspectFill" class="photo-img" lazy-load />
  74. <view class="photo-delete-overlay">
  75. <text class="delete-icon">×</text>
  76. </view>
  77. </view>
  78. </view>
  79. <!-- 录音状态 -->
  80. <view class="voice-strip" v-if="isRecording">
  81. <view class="waveform">
  82. <view class="wave-bar" v-for="n in 7" :key="n" :style="{animationDelay: (n * 0.1) + 's'}"></view>
  83. </view>
  84. <view class="voice-controls">
  85. <view class="mini-btn cancel-mini" @click="cancelRecord"><text>取消</text></view>
  86. <view class="mini-btn done-mini" @click="finishRecord"><text>完成</text></view>
  87. </view>
  88. </view>
  89. <view class="voice-strip" v-else-if="form.voicePath">
  90. <view class="voice-player">
  91. <text class="play-icon">▶</text>
  92. <text class="voice-duration">{{ recordDurationText }}</text>
  93. </view>
  94. <view class="delete-voice" @click="deleteVoice"><text>×</text></view>
  95. </view>
  96. </view>
  97. </view>
  98. <!-- 提交按钮 -->
  99. <view class="submit-wrap">
  100. <view class="submit-btn" :class="{ 'submitting': submitting }" @click="doCheckin">
  101. <text>{{ submitting ? '提交中...' : '✓ 完成打卡' }}</text>
  102. </view>
  103. </view>
  104. <!-- 历史记录 -->
  105. <view class="card" v-if="history.length > 0">
  106. <view class="card-header">
  107. <text class="card-icon">📜</text>
  108. <text class="card-title">今日记录</text>
  109. </view>
  110. <view class="card-body">
  111. <view class="history-list">
  112. <view class="history-item" v-for="item in history" :key="item.id">
  113. <view class="history-left">
  114. <text class="history-type">{{ mealTypeLabel(item.mealType) }}</text>
  115. <text class="history-content">{{ item.foodItems || item.notes || '-' }}</text>
  116. </view>
  117. <view class="history-right">
  118. <text class="history-date">{{ formatDate(item.createdAt) }}</text>
  119. </view>
  120. </view>
  121. </view>
  122. </view>
  123. </view>
  124. <!-- 底部留白 -->
  125. <view class="bottom-spacer"></view>
  126. </scroll-view>
  127. <!-- 图片识别结果确认弹窗 -->
  128. <view class="recognize-overlay" v-if="showRecognizeModal" @click="cancelRecognize">
  129. <view class="recognize-modal" @tap.stop>
  130. <view class="recognize-header">
  131. <text class="recognize-title">🍽️ 识别结果</text>
  132. <text class="recognize-count">{{ recognizedFoods.length }} 种食材</text>
  133. </view>
  134. <view class="recognize-body">
  135. <view class="food-chip" v-for="(f, idx) in recognizedFoods" :key="getFoodsKey(f, idx)">
  136. <text class="food-chip-name">{{ f.name }}</text>
  137. <text class="food-chip-cat" v-if="f.category && f.category !== 'unknown'">{{ f.category }}</text>
  138. <text class="food-chip-del" @click="removeRecognizedFood(idx)">×</text>
  139. </view>
  140. <view class="recognize-hint">
  141. <text>可手动删除不需要的食材,确认后自动填入食物清单</text>
  142. </view>
  143. </view>
  144. <view class="recognize-footer">
  145. <view class="btn-cancel" @click="cancelRecognize"><text>取消</text></view>
  146. <view class="btn-confirm" @click="confirmRecognize"><text>✓ 确认填入</text></view>
  147. </view>
  148. </view>
  149. </view>
  150. </view>
  151. </template>
  152. <script>
  153. import config from '../../config'
  154. import { resolveCheckinMemberId } from '../../utils/memberNormalize.js'
  155. import { parseDate } from '../../utils/format.js'
  156. import { sttTranscribe, recognizeDietFood, getAllQuotaStatus } from '../../utils/api.js'
  157. import shareMixin from '../../components/share-mixin.js'
  158. import { pickImage } from '../../utils/image-picker.js'
  159. import TagChip from '../../components/TagChip.vue'
  160. import fontScaleMixin from '@/mixins/font-scale.js'
  161. export default {
  162. mixins: [fontScaleMixin],
  163. components: { TagChip },
  164. mixins: [shareMixin],
  165. data() {
  166. return {
  167. memberId: null,
  168. taskId: null,
  169. submitting: false,
  170. pendingSubmit: false,
  171. isRecording: false,
  172. recordSeconds: 0,
  173. recordTimer: null,
  174. recorderManager: null,
  175. history: [],
  176. todayText: '',
  177. showRecognizeModal: false,
  178. recognizedFoods: [],
  179. foodRecognizeQuota: null,
  180. mealTypes: [
  181. { label: '早餐', value: 'breakfast' },
  182. { label: '午餐', value: 'lunch' },
  183. { label: '晚餐', value: 'dinner' },
  184. { label: '加餐', value: 'snack' }
  185. ],
  186. form: {
  187. mealTypes: [],
  188. foodItems: '',
  189. remark: '',
  190. photos: [],
  191. voicePath: '',
  192. voiceText: '',
  193. voiceDuration: 0,
  194. recordDate: '',
  195. isBackfill: false
  196. }
  197. }
  198. },
  199. computed: {
  200. // 餐次多选 → 逗号拼接字符串(后端契约不变:mealType 仍为单值 String,VARCHAR(32) 够用)
  201. // 固定按早餐→午餐→晚餐→加餐输出,避免点击顺序影响 records 页首项样式语义
  202. mealType: function() {
  203. var arr = this.form.mealTypes || []
  204. if (arr.length <= 1) return arr.join(',')
  205. var order = { breakfast: 0, lunch: 1, dinner: 2, snack: 3 }
  206. return arr.slice().sort(function(a, b) {
  207. var ia = order[a] === undefined ? 9 : order[a]
  208. var ib = order[b] === undefined ? 9 : order[b]
  209. return ia - ib
  210. }).join(',')
  211. },
  212. recordDurationText: function() {
  213. if (!this.form.voicePath) return ''
  214. var s = this.recordSeconds
  215. return '录音 ' + s + '秒'
  216. }
  217. },
  218. onLoad: function(options) {
  219. this.taskId = options.taskId || null
  220. this.todayText = this.getToday()
  221. this.setShareInfo('我在用浠艾福记录家庭成员的每日饮食,一起来打卡吧', '/pages/growth/diet-checkin')
  222. this.memberId = resolveCheckinMemberId(options, {
  223. currentRole: uni.getStorageSync('currentRole') || uni.getStorageSync('role') || 'parent',
  224. currentChildId: uni.getStorageSync('currentChildId'),
  225. currentMemberId: uni.getStorageSync('currentMemberId'),
  226. userId: uni.getStorageSync('userId')
  227. })
  228. // 支持从 records 页传 date 参数(补打)
  229. if (options.date) {
  230. this.form.recordDate = options.date
  231. this.form.isBackfill = true
  232. }
  233. this.recorderManager = uni.getRecorderManager()
  234. this.recorderManager.onStart(() => {
  235. this.isRecording = true
  236. this.recordSeconds = 0
  237. this.recordTimer = setInterval(() => {
  238. this.recordSeconds++
  239. }, 1000)
  240. })
  241. this.recorderManager.onStop((res) => {
  242. this.isRecording = false
  243. if (this.recordTimer) { clearInterval(this.recordTimer); this.recordTimer = null }
  244. this.form.voicePath = res.tempFilePath
  245. this.form.voiceDuration = res.duration
  246. var self = this
  247. uni.showLoading({ title: '语音识别中...', mask: true })
  248. sttTranscribe(res.tempFilePath).then(function(text) {
  249. self.form.voiceText = text
  250. // 语音转写成功:若食物清单为空则自动填入
  251. if (!self.form.foodItems || !self.form.foodItems.trim()) {
  252. self.form.foodItems = text.trim()
  253. }
  254. uni.hideLoading()
  255. // 保存时停止录音 → 语音已就绪,继续提交
  256. if (self.pendingSubmit) { self.pendingSubmit = false; self.doCheckin() }
  257. }).catch(function(err) {
  258. uni.hideLoading()
  259. console.warn('STT 转写失败:', err)
  260. if (self.pendingSubmit) { self.pendingSubmit = false; self.doCheckin() }
  261. })
  262. })
  263. this.recorderManager.onError((err) => {
  264. this.isRecording = false
  265. if (this.recordTimer) { clearInterval(this.recordTimer); this.recordTimer = null }
  266. uni.showToast({ title: '录音失败', icon: 'none' })
  267. })
  268. // 加载饮食识别配额
  269. var selfQuota = this
  270. getAllQuotaStatus().then(function(res) {
  271. if (res.data && res.data.FOOD_RECOGNIZE) {
  272. selfQuota.foodRecognizeQuota = res.data.FOOD_RECOGNIZE
  273. }
  274. }).catch(function() {})
  275. this.loadHistory()
  276. },
  277. onUnload: function() {
  278. if (this.recordTimer) clearInterval(this.recordTimer)
  279. },
  280. methods: {
  281. getToday: function() {
  282. var d = new Date()
  283. var weekdays = ['日', '一', '二', '三', '四', '五', '六']
  284. return d.getFullYear() + '年' + (d.getMonth() + 1) + '月' + d.getDate() + '日 周' + weekdays[d.getDay()]
  285. },
  286. goBack: function() { uni.navigateBack() },
  287. // 餐次 toggle 多选:已选则移除,未选则追加
  288. toggleMealType: function(value) {
  289. var arr = this.form.mealTypes
  290. var i = arr.indexOf(value)
  291. if (i > -1) { arr.splice(i, 1) } else { arr.push(value) }
  292. },
  293. mealTypeLabel: function(type) {
  294. var m = { breakfast: '早餐', lunch: '午餐', dinner: '晚餐', snack: '加餐' }
  295. if (!type) return '饮食'
  296. // 兼容逗号拼接多餐次(breakfast,lunch → 早餐、午餐);未知值原样输出
  297. var parts = String(type).split(',')
  298. var labels = []
  299. for (var i = 0; i < parts.length; i++) {
  300. var v = parts[i] && parts[i].trim()
  301. if (!v) continue
  302. labels.push(m[v] || v)
  303. }
  304. return labels.length > 0 ? labels.join('、') : '饮食'
  305. },
  306. formatDate: function(dateStr) {
  307. if (!dateStr) return ''
  308. var d = parseDate(dateStr)
  309. if (!d) return dateStr
  310. var m2 = (d.getMonth() + 1).toString().padStart(2, '0')
  311. var day = d.getDate().toString().padStart(2, '0')
  312. return m2 + '-' + day
  313. },
  314. loadHistory: function() {
  315. var self = this
  316. var token = uni.getStorageSync('token')
  317. if (!token || !self.memberId) return
  318. uni.request({
  319. url: config.API_BASE_URL + '/api/health/meal/list',
  320. method: 'POST',
  321. data: { memberId: self.memberId },
  322. header: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token },
  323. success: function(res) {
  324. if (res.data && res.data.code === 200 && res.data.data) {
  325. self.history = res.data.data.slice(0, 5)
  326. }
  327. }
  328. })
  329. },
  330. choosePhoto: function() {
  331. var self = this
  332. pickImage({
  333. count: 9 - self.form.photos.length,
  334. sizeType: ['compressed'],
  335. sourceType: ['album', 'camera'],
  336. success: async function(res) {
  337. for (var i = 0; i < res.tempFilePaths.length; i++) {
  338. if (self.form.photos.length >= 9) break
  339. var path = res.tempFilePaths[i]
  340. self.form.photos.push(path)
  341. try {
  342. var url = await self.uploadFile(path)
  343. if (url) {
  344. var absUrl = url.indexOf('http') === 0 ? url : config.API_BASE_URL + url
  345. var recognizeRes = await new Promise(function(resolve) {
  346. uni.request({
  347. url: config.API_BASE_URL + '/api/diet/record/recognize',
  348. method: 'POST',
  349. data: { image_url: absUrl },
  350. header: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + uni.getStorageSync('token') },
  351. success: function(r) { resolve(r) },
  352. fail: function() { resolve({ data: { code: 500 } }) }
  353. })
  354. })
  355. if (recognizeRes.data && recognizeRes.data.code === 403) {
  356. uni.showToast({ title: recognizeRes.data.message || '今日饮食识别额度已用完', icon: 'none' })
  357. } else if (recognizeRes.data && recognizeRes.data.code === 200 && recognizeRes.data.data && recognizeRes.data.data.foods) {
  358. var foods = recognizeRes.data.data.foods
  359. for (var f = 0; f < foods.length; f++) {
  360. self.recognizedFoods.push({ name: foods[f].name, category: foods[f].category })
  361. }
  362. }
  363. }
  364. } catch (e) { /* ignore */ }
  365. }
  366. if (self.recognizedFoods.length > 0) {
  367. self.showRecognizeResult()
  368. }
  369. }
  370. })
  371. },
  372. getPhotoKey: function(img, idx) {
  373. return img ? img : ('p' + idx)
  374. },
  375. removePhoto: function(idx) {
  376. this.form.photos.splice(idx, 1)
  377. },
  378. toggleRecord: function() {
  379. if (this.isRecording) {
  380. this.recorderManager.stop()
  381. } else {
  382. this.recorderManager.start({ duration: 60000, format: 'mp3' })
  383. }
  384. },
  385. cancelRecord: function() {
  386. if (this.isRecording) {
  387. this.recorderManager.stop()
  388. }
  389. this.form.voicePath = ''
  390. },
  391. finishRecord: function() {
  392. if (this.isRecording) {
  393. this.recorderManager.stop()
  394. }
  395. },
  396. deleteVoice: function() {
  397. this.form.voicePath = ''
  398. },
  399. showRecognizeResult: function() {
  400. this.showRecognizeModal = true
  401. },
  402. confirmRecognize: function() {
  403. var self = this
  404. var names = []
  405. for (var i = 0; i < self.recognizedFoods.length; i++) {
  406. if (self.recognizedFoods[i].name && self.recognizedFoods[i].name.trim()) {
  407. names.push(self.recognizedFoods[i].name.trim())
  408. }
  409. }
  410. if (names.length > 0) {
  411. var newText = names.join('、')
  412. if (self.form.foodItems && self.form.foodItems.trim()) {
  413. self.form.foodItems = self.form.foodItems + '、' + newText
  414. } else {
  415. self.form.foodItems = newText
  416. }
  417. }
  418. self.showRecognizeModal = false
  419. self.recognizedFoods = []
  420. },
  421. cancelRecognize: function() {
  422. this.showRecognizeModal = false
  423. this.recognizedFoods = []
  424. },
  425. removeRecognizedFood: function(idx) {
  426. this.recognizedFoods.splice(idx, 1)
  427. },
  428. getFoodsKey: function(item, idx) {
  429. return item.name || ('food' + idx)
  430. },
  431. uploadFile: function(filePath) {
  432. var self = this
  433. return new Promise(function(resolve, reject) {
  434. uni.uploadFile({
  435. url: config.API_BASE_URL + '/api/media/upload',
  436. filePath: filePath,
  437. name: 'file',
  438. header: { 'Authorization': 'Bearer ' + uni.getStorageSync('token') },
  439. success: function(res) {
  440. try {
  441. var data = JSON.parse(res.data)
  442. if (data && data.code === 200 && data.data && data.data.url) {
  443. resolve(data.data.url)
  444. } else if (data && data.url) {
  445. resolve(data.url)
  446. } else {
  447. resolve('')
  448. }
  449. } catch (e) {
  450. resolve('')
  451. }
  452. },
  453. fail: function() { reject() }
  454. })
  455. })
  456. },
  457. doCheckin: function() {
  458. var self = this
  459. if (self.submitting) return
  460. // 保存时正在录音 → 先停止录音,等待 onStop 完成语音后继续提交
  461. if (self.isRecording) {
  462. self.pendingSubmit = true
  463. self.recorderManager.stop()
  464. return
  465. }
  466. self.submitCheckin()
  467. },
  468. submitCheckin: async function() {
  469. var self = this
  470. if (!self.form.mealTypes || self.form.mealTypes.length === 0) { uni.showToast({ title: '请选择餐次', icon: 'none' }); return }
  471. // 内容校验:文字(食物清单/备注)、图片、语音 至少有一项
  472. var hasText = (self.form.foodItems && self.form.foodItems.trim()) || (self.form.remark && self.form.remark.trim())
  473. var hasPhoto = self.form.photos && self.form.photos.length > 0
  474. var hasVoice = self.form.voicePath || (self.form.voiceText && self.form.voiceText.trim())
  475. if (!hasText && !hasPhoto && !hasVoice) { uni.showToast({ title: '请填写内容或添加图片/语音', icon: 'none' }); return }
  476. if (!self.memberId) { uni.showToast({ title: '成员ID无效', icon: 'none' }); return }
  477. self.submitting = true
  478. try {
  479. var photoUrls = []
  480. if (self.form.photos && self.form.photos.length > 0) {
  481. for (var i = 0; i < self.form.photos.length; i++) {
  482. try { var url = await self.uploadFile(self.form.photos[i]) } catch(e) { url = '' }
  483. if (url) photoUrls.push(url)
  484. }
  485. }
  486. var voiceUrl = ''
  487. if (self.form.voicePath) {
  488. try { voiceUrl = await self.uploadFile(self.form.voicePath) } catch(e) { voiceUrl = '' }
  489. }
  490. var token = uni.getStorageSync('token')
  491. uni.request({
  492. url: config.API_BASE_URL + '/api/health/meal/create',
  493. method: 'POST',
  494. data: {
  495. memberId: self.memberId,
  496. taskId: self.taskId || undefined,
  497. mealType: self.mealType,
  498. foodItems: self.form.foodItems || '',
  499. remark: self.form.remark || '',
  500. photoUrls: photoUrls.join(','),
  501. voiceUrl: voiceUrl,
  502. voiceText: self.form.voiceText || '',
  503. recordDate: self.form.recordDate || undefined,
  504. isBackfill: self.form.isBackfill ? 1 : 0
  505. },
  506. header: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token },
  507. success: function(res) {
  508. self.submitting = false
  509. if (res.data && res.data.code === 200) {
  510. uni.showToast({ title: self.taskId ? '打卡成功,任务已完成' : '打卡成功', icon: 'success' })
  511. // 打卡成功:任务已完成(后端 create 已按任务归属自动完成并自纠成员,
  512. // 无需再调 /api/tasks/{id}/complete——历史冗余调用在双身份/已完成时会触发 500)
  513. setTimeout(function() {
  514. uni.navigateBack()
  515. }, 800)
  516. } else {
  517. uni.showToast({ title: (res.data && res.data.message) || '打卡失败', icon: 'none' })
  518. }
  519. },
  520. fail: function() {
  521. self.submitting = false
  522. uni.showToast({ title: '网络错误', icon: 'none' })
  523. }
  524. })
  525. } catch (e) {
  526. self.submitting = false
  527. uni.showToast({ title: '提交失败', icon: 'none' })
  528. }
  529. }
  530. }
  531. }
  532. </script>
  533. <style scoped lang="scss">
  534. /* ===== 页面基础 ===== */
  535. .page { min-height: 100vh; background: $uni-primary-pale; }
  536. .nav-bar { height: 88rpx; padding: 24rpx 24rpx 0; display: flex; align-items: flex-end; }
  537. .nav-left { display: flex; align-items: center; gap: 10rpx; }
  538. .nav-icon { font-size: calc(48rpx * var(--font-scale, 1)); color: $facade-text-strong; line-height: 1; }
  539. .nav-title { font-size: calc(34rpx * var(--font-scale, 1)); font-weight: 600; color: $facade-text-strong; }
  540. .content { padding-bottom: 40rpx; }
  541. /* ===== 卡片通用 ===== */
  542. .card { margin: 16rpx 20rpx; background: $app-surface; border-radius: 24rpx; overflow: hidden; box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.05); }
  543. .card-header { display: flex; align-items: center; gap: 10rpx; padding: 20rpx 24rpx 8rpx; border-bottom: 1rpx solid $facade-fill-2; background: linear-gradient(90deg, #FFFAF0, $app-surface); }
  544. .card-icon { font-size: calc(32rpx * var(--font-scale, 1)); }
  545. .card-title { font-size: calc(30rpx * var(--font-scale, 1)); font-weight: 600; color: $facade-text-strong; }
  546. .card-body { padding: 20rpx 24rpx 24rpx; }
  547. /* ===== 表单 ===== */
  548. .form-group { margin-bottom: 20rpx; }
  549. .form-label { font-size: calc(26rpx * var(--font-scale, 1)); color: $facade-text-strong; font-weight: 500; margin-bottom: 10rpx; display: block; }
  550. .tag-row { display: flex; flex-wrap: wrap; gap: 10rpx; }
  551. .form-textarea { width: 100%; height: 120rpx; border: 1rpx solid $facade-fill-4; border-radius: 16rpx; padding: 16rpx; font-size: calc(26rpx * var(--font-scale, 1)); background: $facade-fill-ghost; box-sizing: border-box; font-family: inherit; }
  552. .form-input { width: 100%; height: 76rpx; border: 1rpx solid $facade-fill-4; border-radius: 16rpx; padding: 0 16rpx; font-size: calc(26rpx * var(--font-scale, 1)); background: $facade-fill-ghost; box-sizing: border-box; }
  553. /* ===== 媒体工具栏 ===== */
  554. .media-toolbar { display: flex; align-items: center; gap: 0; padding: 12rpx 0; }
  555. .tool-btn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6rpx; padding: 16rpx 0; }
  556. .tool-icon { font-size: calc(40rpx * var(--font-scale, 1)); }
  557. .tool-label { font-size: calc(24rpx * var(--font-scale, 1)); color: $facade-text-body; }
  558. .tool-count { font-size: calc(20rpx * var(--font-scale, 1)); color: $brand-primary; font-weight: 600; }
  559. .tool-divider { width: 1rpx; height: 56rpx; background: linear-gradient(180deg, transparent, $facade-fill-4, transparent); }
  560. /* ===== 照片缩略图 ===== */
  561. .photo-strip { display: flex; flex-wrap: wrap; gap: 10rpx; padding: 12rpx 0 4rpx; }
  562. .photo-item { position: relative; width: 132rpx; height: 132rpx; border-radius: 16rpx; overflow: hidden; }
  563. .photo-img { width: 100%; height: 100%; object-fit: cover; }
  564. .photo-delete-overlay { position: absolute; top: -6rpx; right: -6rpx; width: 32rpx; height: 32rpx; background: $status-danger; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 2rpx 8rpx rgba(239,68,68,0.3); z-index: 2; }
  565. .delete-icon { color: $app-surface; font-size: calc(22rpx * var(--font-scale, 1)); font-weight: bold; line-height: 32rpx; }
  566. /* ===== 录音展开区 ===== */
  567. .voice-strip { display: flex; align-items: center; justify-content: space-between; padding: 12rpx 0 4rpx; gap: 16rpx; }
  568. .waveform { display: flex; align-items: center; gap: 5rpx; height: 40rpx; flex: 1; }
  569. .wave-bar { width: 5rpx; height: 8rpx; background: $brand-primary; border-radius: 8rpx; animation: wave-anim 0.8s ease-in-out infinite; }
  570. @keyframes wave-anim { 0%, 100% { height: 8rpx; } 50% { height: 32rpx; } }
  571. .voice-controls { display: flex; gap: 12rpx; }
  572. .mini-btn { padding: 10rpx 24rpx; border-radius: 24rpx; font-size: calc(24rpx * var(--font-scale, 1)); }
  573. .cancel-mini { background: $facade-fill; color: $facade-text-body; }
  574. .done-mini { background: $brand-primary; color: $app-surface; font-weight: 600; }
  575. .voice-player { display: flex; align-items: center; gap: 10rpx; flex: 1; background: $fortune-1-tint; padding: 10rpx 20rpx; border-radius: 24rpx; }
  576. .play-icon { font-size: calc(26rpx * var(--font-scale, 1)); color: $brand-primary; }
  577. .voice-duration { font-size: calc(24rpx * var(--font-scale, 1)); color: $facade-text-body; }
  578. .delete-voice { width: 40rpx; height: 40rpx; display: flex; align-items: center; justify-content: center; color: $facade-text-muted; font-size: calc(28rpx * var(--font-scale, 1)); }
  579. /* ===== 提交按钮 ===== */
  580. .submit-wrap { padding: 24rpx 20rpx 32rpx; }
  581. .submit-btn { background: linear-gradient(135deg, $dim-body, $brand-primary); color: $app-surface; text-align: center; padding: 22rpx 0; border-radius: 16rpx; font-size: calc(30rpx * var(--font-scale, 1)); font-weight: 600; box-shadow: 0 6rpx 20rpx rgba(249,115,22,0.3); transition: transform 0.2s ease; }
  582. .submit-btn:active { transform: scale(0.98); }
  583. .submitting { opacity: 0.6; }
  584. /* ===== 补打横幅 ===== */
  585. .backfill-banner {
  586. display: flex; align-items: center; gap: 12rpx;
  587. background: linear-gradient(135deg, $fortune-1-tint, $mat-orange-100);
  588. border-bottom: 1rpx solid #FFE082;
  589. padding: 16rpx 24rpx;
  590. }
  591. .backfill-icon { font-size: calc(32rpx * var(--font-scale, 1)); }
  592. .backfill-text { font-size: calc(26rpx * var(--font-scale, 1)); color: $mat-orange-strong; font-weight: 500; }
  593. /* ===== 历史记录 ===== */
  594. .history-list { display: flex; flex-direction: column; gap: 12rpx; }
  595. .history-item { display: flex; justify-content: space-between; align-items: center; padding: 14rpx 0; border-bottom: 1rpx solid $facade-fill-2; }
  596. .history-left { flex: 1; min-width: 0; }
  597. .history-type { font-size: calc(26rpx * var(--font-scale, 1)); font-weight: 500; color: $facade-text-strong; display: block; }
  598. .history-content { font-size: calc(24rpx * var(--font-scale, 1)); color: $facade-text-faint; display: block; margin-top: 4rpx; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  599. .history-right { text-align: right; margin-left: 16rpx; flex-shrink: 0; }
  600. .history-date { font-size: calc(22rpx * var(--font-scale, 1)); color: $facade-text-muted; }
  601. /* ===== 底部留白 ===== */
  602. .bottom-spacer { height: 40rpx; }
  603. /* ===== 识别配额提示条 ===== */
  604. .recognize-quota-hint {
  605. display: flex; align-items: center; justify-content: center;
  606. padding: 12rpx 24rpx;
  607. background: linear-gradient(90deg, $uni-primary-pale, #FFFAF0);
  608. border-bottom: 1rpx solid $facade-fill-2;
  609. }
  610. .recognize-quota-hint-text {
  611. font-size: calc(22rpx * var(--font-scale, 1));
  612. color: $brand-primary;
  613. font-weight: 500;
  614. }
  615. /* ===== 识别结果弹窗 ===== */
  616. .recognize-overlay {
  617. position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  618. background: rgba(0,0,0,0.45); z-index: 999;
  619. display: flex; align-items: center; justify-content: center;
  620. }
  621. .recognize-modal {
  622. width: 600rpx; background: $app-surface; border-radius: 24rpx;
  623. overflow: hidden; box-shadow: 0 16rpx 48rpx rgba(0,0,0,0.18);
  624. }
  625. .recognize-header {
  626. display: flex; align-items: center; justify-content: space-between;
  627. padding: 28rpx 32rpx 20rpx; border-bottom: 1rpx solid $facade-fill;
  628. }
  629. .recognize-title { font-size: calc(32rpx * var(--font-scale, 1)); font-weight: 600; color: $facade-text-strong; }
  630. .recognize-count { font-size: calc(24rpx * var(--font-scale, 1)); color: $brand-primary; font-weight: 500; }
  631. .recognize-body { padding: 24rpx 32rpx; max-height: 420rpx; overflow-y: auto; }
  632. .food-chip {
  633. display: inline-flex; align-items: center; gap: 8rpx;
  634. background: $fortune-1-tint; border: 1rpx solid $mat-orange-100; border-radius: 24rpx;
  635. padding: 8rpx 20rpx; margin: 6rpx 8rpx 6rpx 0;
  636. }
  637. .food-chip-name { font-size: calc(26rpx * var(--font-scale, 1)); color: $mat-orange-strong; font-weight: 500; }
  638. .food-chip-cat { font-size: calc(20rpx * var(--font-scale, 1)); color: $facade-text-muted; }
  639. .food-chip-del {
  640. width: 32rpx; height: 32rpx; display: flex; align-items: center; justify-content: center;
  641. background: $facade-hairline-2; border-radius: 50%; color: $facade-text-muted; font-size: calc(24rpx * var(--font-scale, 1));
  642. }
  643. .recognize-hint {
  644. margin-top: 16rpx; padding: 12rpx 16rpx; background: $facade-fill-ghost;
  645. border-radius: 16rpx;
  646. }
  647. .recognize-hint text { font-size: calc(22rpx * var(--font-scale, 1)); color: $facade-text-muted; }
  648. .recognize-footer {
  649. display: flex; padding: 20rpx 32rpx 32rpx; gap: 20rpx;
  650. }
  651. .btn-cancel, .btn-confirm {
  652. flex: 1; text-align: center; padding: 18rpx 0; border-radius: 16rpx;
  653. font-size: calc(28rpx * var(--font-scale, 1)); font-weight: 600;
  654. }
  655. .btn-cancel { background: $facade-fill-2; color: $facade-text-body; }
  656. .btn-confirm { background: linear-gradient(135deg, $dim-body, $brand-primary); color: $app-surface; box-shadow: 0 4rpx 16rpx rgba(249,115,22,0.25); }
  657. </style>