diet-checkin.vue 25 KB

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