message.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439
  1. <template>
  2. <view class="message-page">
  3. <!-- 消息列表 -->
  4. <scroll-view class="message-list" scroll-y :scroll-top="scrollTop" :scroll-into-view="scrollIntoView"
  5. @touchstart="handleListTouchStart" @touchmove="handleListTouchMove" @touchend="handleListTouchEnd">
  6. <view class="message-item" :class="message.direction" v-for="(message, index) in messages" :key="index"
  7. :id="'msg-' + index">
  8. <!-- 头像+时间区域 -->
  9. <view class="avatar-section">
  10. <image class="avatar" src="/static/logo.png"></image>
  11. <text class="msg-time">{{ message.time }}</text>
  12. </view>
  13. <!-- 内容区域 -->
  14. <view class="content-section">
  15. <!-- 部门/班级 | 姓名 -->
  16. <view class="user-info">{{ message.department }} | {{ message.name }}</view>
  17. <!-- 消息内容 -->
  18. <view class="message-content">
  19. <!-- 文字消息 -->
  20. <view v-if="message.type === 'text'" class="text-message-wrapper">
  21. <!-- 接收的消息:内容在左,按钮在右 -->
  22. <template v-if="message.direction === 'left'">
  23. <view class="text-message">
  24. <text>{{ message.content }}</text>
  25. </view>
  26. <view v-if="message.needReceipt" class="inline-receipt-button"
  27. :class="message.receiptStatus">
  28. {{ message.receiptStatus === 'read' ? '已读' : '确认阅读' }}
  29. </view>
  30. </template>
  31. <!-- 发送的消息:按钮在左,内容在右 -->
  32. <template v-else>
  33. <!-- 带回执按钮(仅在1分钟内显示) -->
  34. <view v-if="message.showReceiptToggle" class="receipt-toggle-wrapper">
  35. <SsOnoffButton name="needReceipt" label="带回执" :value="1"
  36. :modelValue="message.needReceipt ? 1 : 0"
  37. @update:modelValue="toggleReceipt(index, $event)" />
  38. </view>
  39. <!-- 阅读情况按钮 -->
  40. <view v-if="message.needReceipt && !message.showReceiptToggle" class="inline-receipt-button"
  41. :class="message.receiptStatus">
  42. 阅读情况
  43. </view>
  44. <!-- 文字内容 -->
  45. <view class="text-message">
  46. <text>{{ message.content }}</text>
  47. </view>
  48. </template>
  49. </view>
  50. <!-- 通话记录 -->
  51. <view v-if="message.type === 'call'" class="call-message">
  52. <image src="/static/icon/tingtong.png"></image>
  53. <text>通话时长 {{ message.duration }}</text>
  54. </view>
  55. <!-- 语音消息 -->
  56. <view
  57. v-if="message.type === 'voice'"
  58. class="voice-message"
  59. :style="getVoiceBubbleStyle(message)"
  60. @click.stop="toggleVoicePlayback(message, index)"
  61. >
  62. <image
  63. :src="message.direction === 'left' ? '/static/icon/guangbo.png' : '/static/icon/yinbo.png'">
  64. </image>
  65. <text>{{ message.duration }}" {{ message.voicePreview }}</text>
  66. <view v-if="message.isRecording" class="recording-dot"></view>
  67. </view>
  68. <!-- 图片消息 -->
  69. <view v-if="message.type === 'image'" class="image-message" @click.stop="openImagePreview(message)">
  70. <image class="image-preview" :src="message.imageUrl || '/static/logo.png'" mode="aspectFill"></image>
  71. </view>
  72. <!-- 文件消息 -->
  73. <view v-if="message.type === 'file'" class="file-message" @click.stop="openFilePreview(message)">
  74. <Icon lib="base" name="icon-file" size="39" :color="iconColor" />
  75. <text class="file-name">{{ message.fileName }}</text>
  76. </view>
  77. <!-- 视频消息 -->
  78. <view v-if="message.type === 'video'" class="video-message" @click.stop="openVideoPreview(message, index)">
  79. <video
  80. class="video-cover"
  81. :src="message.videoUrl"
  82. muted
  83. :controls="false"
  84. :show-center-play-btn="false"
  85. :enable-progress-gesture="false"
  86. object-fit="cover"
  87. ></video>
  88. <view class="video-play">
  89. <Icon lib="base" name="icon-vid" size="40" color="#ffffff" />
  90. </view>
  91. </view>
  92. </view>
  93. <!-- 语音转文字区域(仅语音消息且有转文字内容时显示) -->
  94. <view v-if="message.type === 'voice' && message.voiceText" class="voice-text-section">
  95. <!-- 接收的消息:转写在左,按钮在右 -->
  96. <template v-if="message.direction === 'left'">
  97. <view class="voice-text-content">{{ message.voiceText }}</view>
  98. <view v-if="message.needReceipt" class="receipt-button" :class="message.receiptStatus">
  99. {{ message.receiptStatus === 'read' ? '已读' : '确认阅读' }}
  100. </view>
  101. </template>
  102. <!-- 发送的消息:按钮在左,转写在右 -->
  103. <template v-else>
  104. <view v-if="message.needReceipt" class="receipt-button" :class="message.receiptStatus">
  105. 阅读情况
  106. </view>
  107. <view class="voice-text-content">{{ message.voiceText }}</view>
  108. </template>
  109. </view>
  110. </view>
  111. </view>
  112. </scroll-view>
  113. <!-- 底部操作栏 -->
  114. <view class="footer" :class="{ active: showMorePanel || showEmojiPanel }" @click.stop>
  115. <!-- 左侧:语音/键盘切换 -->
  116. <view class="tool-btn" @click="toggleInputMode">
  117. <Icon lib="base" :name="inputMode === 'voice' ? 'icon-txt' : 'icon-spk'" size="36" :color="iconColor" />
  118. </view>
  119. <!-- 中间:输入框 / 按住说话 -->
  120. <view class="center-area">
  121. <view
  122. v-if="inputMode === 'voice'"
  123. class="press-to-talk"
  124. @longpress="handlePressToTalkStart"
  125. @touchmove.stop.prevent="handlePressToTalkMove"
  126. @touchend.stop.prevent="handlePressToTalkEnd"
  127. @touchcancel.stop.prevent="handlePressToTalkCancel"
  128. >
  129. <Icon lib="base" name="icon-aud-bold" size="36" :color="iconColor" />
  130. <text class="press-text">长按说话</text>
  131. </view>
  132. <textarea
  133. v-else
  134. class="text-input"
  135. :class="{ capped: textLineCount >= 5 }"
  136. v-model="draftText"
  137. :focus="inputFocus"
  138. auto-height
  139. confirm-type="send"
  140. @confirm="sendTextMessage"
  141. maxlength="-1"
  142. @linechange="handleTextLineChange"
  143. @blur="inputFocus = false"
  144. />
  145. </view>
  146. <!-- 右侧:表情 + 更多 -->
  147. <view class="tool-btn" @click="toggleEmojiPanel">
  148. <Icon lib="base" name="icon-emoji" size="36" :color="iconColor" />
  149. </view>
  150. <view class="tool-btn" @click="toggleMorePanel">
  151. <Icon lib="base" name="icon-add" size="36" :color="iconColor" />
  152. </view>
  153. </view>
  154. <!-- 底部扩展面板(更多/表情) -->
  155. <view class="bottom-panel" :class="{ open: showMorePanel || showEmojiPanel }" @click.stop>
  156. <view v-show="showMorePanel" class="more-panel">
  157. <view class="more-grid">
  158. <view class="more-item" @click="handleMoreAction('file')">
  159. <view class="more-icon">
  160. <Icon lib="base" name="icon-file" size="36" :color="iconColor" />
  161. </view>
  162. <text class="more-text">文件</text>
  163. </view>
  164. <view class="more-item" @click="handleMoreAction('image')">
  165. <view class="more-icon">
  166. <Icon lib="base" name="icon-img" size="36" :color="iconColor" />
  167. </view>
  168. <text class="more-text">照片</text>
  169. </view>
  170. <view class="more-item" @click="handleMoreAction('camera')">
  171. <view class="more-icon">
  172. <Icon lib="base" name="icon-vid-bold" size="36" :color="iconColor" />
  173. </view>
  174. <text class="more-text">拍照</text>
  175. </view>
  176. <view class="more-item" @click="handleMoreAction('video')">
  177. <view class="more-icon">
  178. <Icon lib="base" name="icon-vid" size="36" :color="iconColor" />
  179. </view>
  180. <text class="more-text">视频留言</text>
  181. </view>
  182. </view>
  183. </view>
  184. <view v-show="showEmojiPanel" class="emoji-panel">
  185. <view class="emoji-grid">
  186. <view class="emoji-item" v-for="(emoji, index) in emojiList" :key="index"
  187. @click="insertEmoji(emoji)">
  188. {{ emoji }}
  189. </view>
  190. </view>
  191. </view>
  192. </view>
  193. <view v-if="showMediaPreview" class="media-preview-mask" @click="closeMediaPreview">
  194. <view class="media-preview-content" :class="previewType === 'image' ? 'image-mode' : 'video-mode'" @click.stop="handlePreviewContentClick">
  195. <swiper
  196. v-if="previewType === 'image'"
  197. class="media-preview-swiper"
  198. :current="previewImageIndex"
  199. @change="handleImageSwiperChange"
  200. >
  201. <swiper-item class="media-preview-swiper-item" v-for="(img, idx) in previewImageList" :key="idx">
  202. <image class="media-preview-image fit-x" :src="img" mode="widthFix"></image>
  203. </swiper-item>
  204. </swiper>
  205. <video
  206. v-if="previewType === 'video'"
  207. class="media-preview-video"
  208. :src="previewSource"
  209. autoplay
  210. controls
  211. object-fit="contain"
  212. @loadedmetadata="handlePreviewVideoLoaded"
  213. @error="handlePreviewVideoError"
  214. ></video>
  215. </view>
  216. <view v-if="previewType === 'video'" class="media-preview-exit" @click.stop="closeMediaPreview">退出</view>
  217. </view>
  218. <view v-if="showFileDialog" class="file-dialog-mask" @click="closeFileDialog">
  219. <view class="file-dialog" @click.stop>
  220. <view class="file-dialog-header">
  221. <Icon lib="base" name="icon-file" size="44" :color="iconColor" />
  222. <text class="file-dialog-name">{{ activeFileName }}</text>
  223. </view>
  224. <view class="file-dialog-actions">
  225. <view class="file-dialog-btn ghost" @click="closeFileDialog">取消</view>
  226. <view class="file-dialog-btn" @click="downloadFileFromDialog">下载</view>
  227. </view>
  228. </view>
  229. </view>
  230. <view v-if="isRecording" class="record-mask">
  231. <view class="record-panel">
  232. <view class="record-title">正在录音</view>
  233. <view class="record-time">{{ recordSeconds }}s</view>
  234. <view class="record-tip" :class="{ danger: isRecordCancel }">
  235. {{ isRecordCancel ? '松开取消发送' : '手指上滑,取消发送' }}
  236. </view>
  237. </view>
  238. </view>
  239. </view>
  240. </template>
  241. <script>
  242. import SsOnoffButton from '@/components/SsOnoffButton/index.vue'
  243. import Icon from '@/components/icon/index.vue'
  244. import { EMOJI_LIST } from '@/constants/emoji'
  245. import { collectImageUrls, getInitialParentMessages, createImageMessage } from '@/utils/parent-message-factory'
  246. import {
  247. buildTextOutgoingMessage,
  248. buildVoiceOutgoingMessage,
  249. pickFileOutgoingMessage,
  250. pickImageOutgoingMessages,
  251. pickVideoOutgoingMessage,
  252. shootImageOutgoingMessage
  253. } from '@/utils/parent-message-send'
  254. const RECEIPT_TOGGLE_TTL_MS = 60 * 1000
  255. export default {
  256. components: {
  257. SsOnoffButton,
  258. Icon
  259. },
  260. computed: {},
  261. data() {
  262. return {
  263. scrollTop: 0,
  264. scrollIntoView: '',
  265. inputMode: 'voice', // voice | text
  266. inputFocus: false,
  267. draftText: '',
  268. iconColor: '#575d6d',
  269. showEmojiPanel: false,
  270. showMorePanel: false,
  271. emojiList: EMOJI_LIST,
  272. showMediaPreview: false,
  273. previewType: '',
  274. previewSource: '',
  275. activeVideoIndex: -1,
  276. previewImageList: [],
  277. previewImageIndex: 0,
  278. showFileDialog: false,
  279. activeFileName: '',
  280. activeFileUrl: '',
  281. receiptToggleTimers: {},
  282. currentUserMeta: {
  283. direction: 'right',
  284. department: '家长',
  285. name: '我'
  286. },
  287. textLineCount: 1,
  288. listTouchMoved: false,
  289. touchStartX: 0,
  290. touchStartY: 0,
  291. recorderManager: null,
  292. isRecording: false,
  293. isRecordCancel: false,
  294. recordSeconds: 0,
  295. recordStartY: 0,
  296. recordTickTimer: null,
  297. recordGuardTimer: null,
  298. audioPlayer: null,
  299. playingVoiceIndex: -1,
  300. // 消息列表数据
  301. messages: getInitialParentMessages()
  302. }
  303. },
  304. onLoad(options) {
  305. // 获取路由参数中的角色信息
  306. const role = options.role
  307. console.log(role)
  308. if (!role) {
  309. uni.showToast({
  310. title: '缺少角色信息',
  311. icon: 'none'
  312. })
  313. return
  314. }
  315. // 这里可以根据角色获取对应的消息列表
  316. // this.getMessageList(role)
  317. },
  318. onReady() {
  319. // 页面渲染完成后,滚动到最新消息
  320. this.$nextTick(() => {
  321. this.scrollToBottom()
  322. this.initReceiptToggleTimers()
  323. this.initRecorder()
  324. })
  325. },
  326. onUnload() {
  327. this.stopVoicePlayback()
  328. if (this.audioPlayer) {
  329. this.audioPlayer.destroy()
  330. this.audioPlayer = null
  331. }
  332. this.cleanupRecorder()
  333. this.clearReceiptToggleTimers()
  334. },
  335. methods: {
  336. getVoiceBubbleStyle(message) {
  337. if (!message || !message.isPlaying) return {}
  338. const progress = Math.max(0, Math.min(100, Number(message.playProgress || 0)))
  339. if (message.direction === 'right') {
  340. return {
  341. backgroundImage: `linear-gradient(to right, #7d89b1 ${progress}%, #eeeeee ${progress}%)`
  342. }
  343. }
  344. return {
  345. backgroundImage: `linear-gradient(to right, #eeeeee ${progress}%, #7d89b1 ${progress}%)`
  346. }
  347. },
  348. resetVoiceItemState(index) {
  349. if (index < 0 || !this.messages[index]) return
  350. this.$set(this.messages[index], 'isPlaying', false)
  351. this.$set(this.messages[index], 'playProgress', 0)
  352. },
  353. updateVoicePlayProgress() {
  354. const index = this.playingVoiceIndex
  355. if (index < 0 || !this.messages[index] || !this.audioPlayer) return
  356. const duration = Number(this.audioPlayer.duration || 0)
  357. const currentTime = Number(this.audioPlayer.currentTime || 0)
  358. if (duration <= 0) return
  359. const progress = Math.max(0, Math.min(100, (currentTime / duration) * 100))
  360. this.$set(this.messages[index], 'playProgress', progress)
  361. },
  362. initAudioPlayer() {
  363. if (this.audioPlayer || !uni.createInnerAudioContext) return
  364. this.audioPlayer = uni.createInnerAudioContext()
  365. this.audioPlayer.onTimeUpdate(() => {
  366. this.updateVoicePlayProgress()
  367. })
  368. this.audioPlayer.onEnded(() => {
  369. this.resetVoiceItemState(this.playingVoiceIndex)
  370. this.playingVoiceIndex = -1
  371. })
  372. this.audioPlayer.onStop(() => {
  373. this.resetVoiceItemState(this.playingVoiceIndex)
  374. this.playingVoiceIndex = -1
  375. })
  376. this.audioPlayer.onError(() => {
  377. this.resetVoiceItemState(this.playingVoiceIndex)
  378. this.playingVoiceIndex = -1
  379. uni.showToast({ title: '语音播放失败', icon: 'none' })
  380. })
  381. },
  382. stopVoicePlayback() {
  383. if (this.audioPlayer) {
  384. this.audioPlayer.stop()
  385. }
  386. this.resetVoiceItemState(this.playingVoiceIndex)
  387. this.playingVoiceIndex = -1
  388. },
  389. toggleVoicePlayback(message, index) {
  390. if (!message || message.type !== 'voice') return
  391. if (!message.audioUrl) {
  392. uni.showToast({ title: '该语音暂无音频文件', icon: 'none' })
  393. return
  394. }
  395. this.initAudioPlayer()
  396. if (!this.audioPlayer) {
  397. uni.showToast({ title: '当前环境不支持播放', icon: 'none' })
  398. return
  399. }
  400. if (this.playingVoiceIndex === index) {
  401. this.stopVoicePlayback()
  402. return
  403. }
  404. if (this.playingVoiceIndex > -1) {
  405. this.audioPlayer.stop()
  406. this.resetVoiceItemState(this.playingVoiceIndex)
  407. }
  408. this.playingVoiceIndex = index
  409. this.$set(this.messages[index], 'isPlaying', true)
  410. this.$set(this.messages[index], 'playProgress', 0)
  411. this.audioPlayer.src = message.audioUrl
  412. this.audioPlayer.play()
  413. },
  414. initRecorder() {
  415. if (!uni.getRecorderManager) return
  416. this.recorderManager = uni.getRecorderManager()
  417. this.recorderManager.onStop((res) => {
  418. const canceled = this.isRecordCancel
  419. const durationMs = Number(res && res.duration ? res.duration : 0)
  420. const durationSeconds = Math.max(1, Math.round(durationMs / 1000) || this.recordSeconds)
  421. this.clearRecordTimers()
  422. this.isRecording = false
  423. this.isRecordCancel = false
  424. this.recordStartY = 0
  425. if (canceled) {
  426. uni.showToast({ title: '已取消发送', icon: 'none' })
  427. return
  428. }
  429. if (!res || !res.tempFilePath || durationSeconds < 1) {
  430. uni.showToast({ title: '录音时间太短', icon: 'none' })
  431. return
  432. }
  433. const voiceMessage = buildVoiceOutgoingMessage({
  434. durationSeconds,
  435. audioUrl: res.tempFilePath,
  436. voiceText: ''
  437. }, this.currentUserMeta)
  438. this.appendMessage(voiceMessage)
  439. })
  440. this.recorderManager.onError(() => {
  441. this.clearRecordTimers()
  442. this.isRecording = false
  443. this.isRecordCancel = false
  444. uni.showToast({ title: '录音失败', icon: 'none' })
  445. })
  446. },
  447. clearRecordTimers() {
  448. if (this.recordTickTimer) {
  449. clearInterval(this.recordTickTimer)
  450. this.recordTickTimer = null
  451. }
  452. if (this.recordGuardTimer) {
  453. clearTimeout(this.recordGuardTimer)
  454. this.recordGuardTimer = null
  455. }
  456. },
  457. cleanupRecorder() {
  458. this.clearRecordTimers()
  459. if (this.isRecording && this.recorderManager) {
  460. this.isRecordCancel = true
  461. try {
  462. this.recorderManager.stop()
  463. } catch (error) {
  464. // noop
  465. }
  466. }
  467. this.isRecording = false
  468. this.recordSeconds = 0
  469. },
  470. handlePressToTalkStart(event) {
  471. if (this.isRecording) return
  472. if (!this.recorderManager) {
  473. this.initRecorder()
  474. }
  475. if (!this.recorderManager) {
  476. uni.showToast({ title: '当前环境不支持录音', icon: 'none' })
  477. return
  478. }
  479. const touch = event && event.touches && event.touches[0]
  480. this.recordStartY = touch ? touch.clientY : 0
  481. this.recordSeconds = 0
  482. this.isRecordCancel = false
  483. this.isRecording = true
  484. this.clearRecordTimers()
  485. this.recordTickTimer = setInterval(() => {
  486. this.recordSeconds = Math.min(60, this.recordSeconds + 1)
  487. }, 1000)
  488. this.recordGuardTimer = setTimeout(() => {
  489. if (!this.isRecording || !this.recorderManager) return
  490. this.recorderManager.stop()
  491. }, 60000)
  492. try {
  493. this.recorderManager.start({
  494. duration: 60000,
  495. sampleRate: 16000,
  496. numberOfChannels: 1,
  497. encodeBitRate: 96000,
  498. format: 'mp3'
  499. })
  500. } catch (error) {
  501. this.clearRecordTimers()
  502. this.isRecording = false
  503. this.isRecordCancel = false
  504. uni.showToast({ title: '录音启动失败', icon: 'none' })
  505. }
  506. },
  507. handlePressToTalkMove(event) {
  508. if (!this.isRecording) return
  509. const touch = event && event.touches && event.touches[0]
  510. if (!touch) return
  511. const deltaY = this.recordStartY - touch.clientY
  512. this.isRecordCancel = deltaY > 80
  513. },
  514. handlePressToTalkEnd() {
  515. if (!this.isRecording || !this.recorderManager) return
  516. this.recorderManager.stop()
  517. },
  518. handlePressToTalkCancel() {
  519. if (!this.isRecording || !this.recorderManager) return
  520. this.isRecordCancel = true
  521. this.recorderManager.stop()
  522. },
  523. back() {
  524. uni.navigateBack({
  525. delta: 1
  526. })
  527. },
  528. // 切换带回执状态
  529. toggleReceipt(index, value) {
  530. this.messages[index].needReceipt = value === 1 || value === '1'
  531. },
  532. initReceiptToggleTimers() {
  533. this.messages.forEach((message, index) => {
  534. if (message.showReceiptToggle) {
  535. this.registerReceiptToggleTimer(index)
  536. }
  537. })
  538. },
  539. registerReceiptToggleTimer(index) {
  540. const message = this.messages[index]
  541. if (!message || !message.showReceiptToggle) return
  542. if (!message.receiptToggleCreatedAt) {
  543. message.receiptToggleCreatedAt = Date.now()
  544. }
  545. const expireAt = message.receiptToggleCreatedAt + RECEIPT_TOGGLE_TTL_MS
  546. const remain = expireAt - Date.now()
  547. if (remain <= 0) {
  548. message.showReceiptToggle = false
  549. this.clearReceiptToggleTimer(index)
  550. return
  551. }
  552. this.clearReceiptToggleTimer(index)
  553. this.receiptToggleTimers[index] = setTimeout(() => {
  554. const target = this.messages[index]
  555. if (target) {
  556. target.showReceiptToggle = false
  557. }
  558. this.clearReceiptToggleTimer(index)
  559. }, remain)
  560. },
  561. clearReceiptToggleTimer(index) {
  562. const timerId = this.receiptToggleTimers[index]
  563. if (timerId) {
  564. clearTimeout(timerId)
  565. delete this.receiptToggleTimers[index]
  566. }
  567. },
  568. clearReceiptToggleTimers() {
  569. Object.keys(this.receiptToggleTimers).forEach((key) => {
  570. this.clearReceiptToggleTimer(key)
  571. })
  572. },
  573. // 滚动到底部
  574. scrollToBottom() {
  575. const lastIndex = this.messages.length - 1
  576. if (lastIndex >= 0) {
  577. this.scrollIntoView = 'msg-' + lastIndex
  578. }
  579. },
  580. toggleInputMode() {
  581. if (this.inputMode === 'voice') {
  582. this.inputMode = 'text'
  583. this.showMorePanel = false
  584. this.showEmojiPanel = false
  585. this.$nextTick(() => {
  586. this.inputFocus = true
  587. })
  588. } else {
  589. this.inputMode = 'voice'
  590. this.showMorePanel = false
  591. this.showEmojiPanel = false
  592. this.inputFocus = false
  593. }
  594. },
  595. toggleEmojiPanel() {
  596. const nextStatus = !this.showEmojiPanel
  597. this.showEmojiPanel = nextStatus
  598. if (nextStatus) {
  599. this.inputMode = 'text'
  600. this.showMorePanel = false
  601. this.inputFocus = false
  602. }
  603. },
  604. toggleMorePanel() {
  605. const nextStatus = !this.showMorePanel
  606. this.showMorePanel = nextStatus
  607. if (nextStatus) {
  608. this.inputMode = 'text'
  609. this.showEmojiPanel = false
  610. this.inputFocus = false
  611. }
  612. },
  613. handlePageClick() {
  614. if (this.showMorePanel || this.showEmojiPanel) {
  615. this.showMorePanel = false
  616. this.showEmojiPanel = false
  617. }
  618. },
  619. insertEmoji(emoji) {
  620. this.inputMode = 'text'
  621. this.draftText = `${this.draftText}${emoji}`
  622. },
  623. handleListTouchStart(event) {
  624. const touch = event.touches && event.touches[0]
  625. if (!touch) return
  626. this.listTouchMoved = false
  627. this.touchStartX = touch.clientX
  628. this.touchStartY = touch.clientY
  629. },
  630. handleListTouchMove(event) {
  631. const touch = event.touches && event.touches[0]
  632. if (!touch) return
  633. const deltaX = Math.abs(touch.clientX - this.touchStartX)
  634. const deltaY = Math.abs(touch.clientY - this.touchStartY)
  635. if (deltaX > 8 || deltaY > 8) {
  636. this.listTouchMoved = true
  637. }
  638. },
  639. handleListTouchEnd() {
  640. if (!this.listTouchMoved) {
  641. this.handlePageClick()
  642. }
  643. },
  644. appendMessages(newMessages = []) {
  645. if (!newMessages.length) return
  646. const startIndex = this.messages.length
  647. this.messages = [...this.messages, ...newMessages]
  648. newMessages.forEach((message, offset) => {
  649. if (message.showReceiptToggle) {
  650. this.registerReceiptToggleTimer(startIndex + offset)
  651. }
  652. })
  653. this.$nextTick(() => {
  654. this.scrollToBottom()
  655. })
  656. },
  657. appendMessage(newMessage) {
  658. if (!newMessage) return
  659. this.appendMessages([newMessage])
  660. },
  661. async handleMoreAction(type) {
  662. try {
  663. if (type === 'file') {
  664. const fileMessage = await pickFileOutgoingMessage(this.currentUserMeta)
  665. if (fileMessage) this.appendMessage(fileMessage)
  666. return
  667. }
  668. if (type === 'image') {
  669. const imageMessages = await pickImageOutgoingMessages(this.currentUserMeta)
  670. if (imageMessages.length) this.appendMessages(imageMessages)
  671. return
  672. }
  673. if (type === 'camera') {
  674. const imageMessage = await shootImageOutgoingMessage(this.currentUserMeta)
  675. if (imageMessage) this.appendMessage(imageMessage)
  676. return
  677. }
  678. if (type === 'video') {
  679. const videoMessage = await pickVideoOutgoingMessage(this.currentUserMeta)
  680. if (videoMessage) this.appendMessage(videoMessage)
  681. return
  682. }
  683. uni.showToast({ title: `点击:${type}`, icon: 'none' })
  684. } catch (error) {
  685. uni.showToast({ title: '操作已取消', icon: 'none' })
  686. }
  687. },
  688. openImagePreview(message) {
  689. const imageUrls = collectImageUrls(this.messages)
  690. if (!imageUrls.length) return
  691. const currentUrl = message.imageUrl || imageUrls[0]
  692. const currentIndex = imageUrls.findIndex((item) => item === currentUrl)
  693. this.previewType = 'image'
  694. this.previewImageList = imageUrls
  695. this.previewImageIndex = currentIndex > -1 ? currentIndex : 0
  696. this.showMediaPreview = true
  697. },
  698. openVideoPreview(message, index) {
  699. this.previewType = 'video'
  700. this.previewSource = message.videoUrl || message.coverUrl || '/static/logo.png'
  701. this.activeVideoIndex = typeof index === 'number' ? index : -1
  702. this.showMediaPreview = true
  703. },
  704. openFilePreview(message) {
  705. this.activeFileName = message.fileName || '未命名文件'
  706. this.activeFileUrl = message.fileUrl || ''
  707. this.showFileDialog = true
  708. },
  709. downloadFileFromDialog() {
  710. if (!this.activeFileUrl) {
  711. uni.showToast({
  712. title: '文件地址不存在',
  713. icon: 'none'
  714. })
  715. return
  716. }
  717. const lowerUrl = (this.activeFileUrl || '').toLowerCase()
  718. const lowerName = (this.activeFileName || '').toLowerCase()
  719. const target = lowerName || lowerUrl
  720. const isDocType = /(\.pdf|\.doc|\.docx|\.xls|\.xlsx|\.ppt|\.pptx|\.txt)$/.test(target)
  721. uni.downloadFile({
  722. url: this.activeFileUrl,
  723. success: (res) => {
  724. if (res.statusCode === 200) {
  725. this.closeFileDialog()
  726. if (isDocType) {
  727. uni.openDocument({
  728. filePath: res.tempFilePath,
  729. showMenu: true,
  730. fail: () => {
  731. uni.showToast({
  732. title: '文件打开失败',
  733. icon: 'none'
  734. })
  735. }
  736. })
  737. } else {
  738. uni.showToast({
  739. title: '下载成功,当前类型不支持在线打开',
  740. icon: 'none'
  741. })
  742. }
  743. } else {
  744. uni.showToast({
  745. title: '下载失败',
  746. icon: 'none'
  747. })
  748. }
  749. },
  750. fail: () => {
  751. uni.showToast({
  752. title: '下载失败',
  753. icon: 'none'
  754. })
  755. }
  756. })
  757. },
  758. closeFileDialog() {
  759. this.showFileDialog = false
  760. this.activeFileName = ''
  761. this.activeFileUrl = ''
  762. },
  763. closeMediaPreview() {
  764. this.showMediaPreview = false
  765. this.previewType = ''
  766. this.previewSource = ''
  767. this.activeVideoIndex = -1
  768. this.previewImageList = []
  769. this.previewImageIndex = 0
  770. },
  771. handlePreviewVideoLoaded(event) {
  772. const seconds = event?.detail?.duration
  773. if (!seconds || this.activeVideoIndex < 0 || !this.messages[this.activeVideoIndex]) return
  774. const mins = Math.floor(seconds / 60)
  775. const secs = Math.floor(seconds % 60)
  776. const durationText = `${String(mins).padStart(2, '0')}:${String(secs).padStart(2, '0')}`
  777. this.messages[this.activeVideoIndex].duration = durationText
  778. },
  779. handlePreviewContentClick() {
  780. if (this.previewType === 'image') {
  781. this.closeMediaPreview()
  782. }
  783. },
  784. handleImageSwiperChange(event) {
  785. this.previewImageIndex = event.detail && event.detail.current ? event.detail.current : 0
  786. },
  787. handlePreviewVideoError() {
  788. uni.showToast({
  789. title: '视频加载失败,请使用H.264编码MP4',
  790. icon: 'none'
  791. })
  792. },
  793. handleTextLineChange(event) {
  794. this.textLineCount = event.detail && event.detail.lineCount ? event.detail.lineCount : 1
  795. },
  796. sendTextMessage() {
  797. const message = buildTextOutgoingMessage(this.draftText, this.currentUserMeta)
  798. if (!message) return
  799. message.receiptToggleCreatedAt = Date.now()
  800. this.appendMessage(message)
  801. this.draftText = ''
  802. this.textLineCount = 1
  803. },
  804. addImageFromUrl(url) {
  805. if (!url) return
  806. this.appendMessage(createImageMessage({
  807. ...this.currentUserMeta,
  808. imageUrl: url
  809. }))
  810. }
  811. }
  812. }
  813. </script>
  814. <style scoped lang="less">
  815. .message-page {
  816. height: 100vh;
  817. background: #f5f5f5;
  818. display: flex;
  819. flex-direction: column;
  820. overflow: hidden;
  821. .nav-header {
  822. padding: 20rpx;
  823. background: #fff;
  824. border-bottom: 1rpx solid #eee;
  825. }
  826. .back-btn {
  827. width: 100rpx;
  828. font-size: 28rpx;
  829. text-align: center;
  830. color: #333;
  831. border-radius: 5rpx;
  832. padding: 10rpx 20rpx;
  833. border: 1px solid #eee;
  834. display: flex;
  835. align-items: center;
  836. gap: 10rpx;
  837. }
  838. .back-btn image {
  839. width: 25rpx;
  840. height: 25rpx;
  841. }
  842. .message-list {
  843. flex: 1;
  844. padding: 20rpx;
  845. background: #fff;
  846. overflow-y: auto;
  847. box-sizing: border-box;
  848. }
  849. .message-item {
  850. display: flex;
  851. align-items: flex-start;
  852. margin: 42rpx 0;
  853. gap: 20rpx;
  854. }
  855. /* 头像+时间区域 */
  856. .avatar-section {
  857. display: flex;
  858. flex-direction: column;
  859. align-items: center;
  860. }
  861. .avatar {
  862. width: 92rpx;
  863. height: 92rpx;
  864. border-radius: 50%;
  865. flex-shrink: 0;
  866. }
  867. .msg-time {
  868. font-size: 32rpx;
  869. color: #666;
  870. white-space: nowrap;
  871. }
  872. /* 内容区域 */
  873. .content-section {
  874. flex: 1;
  875. display: flex;
  876. flex-direction: column;
  877. gap: 10rpx;
  878. }
  879. .user-info {
  880. font-size: 28rpx;
  881. color: #666;
  882. }
  883. .message-content {
  884. display: flex;
  885. align-items: center;
  886. }
  887. /* 文字消息容器 */
  888. .text-message-wrapper {
  889. display: flex;
  890. align-items: flex-end;
  891. gap: 10rpx;
  892. }
  893. /* 带回执按钮容器 */
  894. .receipt-toggle-wrapper {
  895. display: flex;
  896. align-items: center;
  897. }
  898. /* 消息气泡通用样式 */
  899. .text-message,
  900. .call-message,
  901. .voice-message,
  902. .file-message {
  903. background: #7d89b1;
  904. padding: 16rpx 20rpx;
  905. border-radius: 8rpx;
  906. color: #fff;
  907. font-size: 32rpx;
  908. }
  909. .image-message,
  910. .video-message {
  911. border-radius: 8rpx;
  912. overflow: hidden;
  913. border: 1rpx solid #dcdcdc;
  914. background: #ffffff;
  915. }
  916. /* 文字消息 */
  917. .text-message {
  918. max-width: 400rpx;
  919. word-wrap: break-word;
  920. }
  921. /* 通话记录 */
  922. .call-message {
  923. display: flex;
  924. align-items: center;
  925. gap: 10rpx;
  926. }
  927. .call-message image {
  928. width: 40rpx;
  929. height: 40rpx;
  930. }
  931. /* 语音消息 */
  932. .voice-message {
  933. position: relative;
  934. display: flex;
  935. align-items: center;
  936. gap: 10rpx;
  937. min-width: 100rpx;
  938. transition: background-image 0.12s linear;
  939. }
  940. .voice-message image {
  941. width: 40rpx;
  942. height: 40rpx;
  943. }
  944. .file-message {
  945. display: flex;
  946. align-items: center;
  947. gap: 12rpx;
  948. max-width: 420rpx;
  949. }
  950. .file-name {
  951. flex: 1;
  952. min-width: 0;
  953. font-size: 32rpx;
  954. white-space: nowrap;
  955. overflow: hidden;
  956. text-overflow: ellipsis;
  957. }
  958. .image-preview {
  959. width: 280rpx;
  960. height: 220rpx;
  961. display: block;
  962. }
  963. .video-message {
  964. position: relative;
  965. width: 280rpx;
  966. height: 220rpx;
  967. }
  968. .video-cover {
  969. width: 100%;
  970. height: 100%;
  971. display: block;
  972. }
  973. .video-play {
  974. position: absolute;
  975. left: 50%;
  976. top: 50%;
  977. transform: translate(-50%, -50%);
  978. width: 64rpx;
  979. height: 64rpx;
  980. border-radius: 50%;
  981. background: rgba(0, 0, 0, 0.45);
  982. display: flex;
  983. align-items: center;
  984. justify-content: center;
  985. }
  986. .recording-dot {
  987. width: 16rpx;
  988. height: 16rpx;
  989. background: #eb6100;
  990. border-radius: 50%;
  991. position: absolute;
  992. right: 10rpx;
  993. top: 10rpx;
  994. }
  995. /* 语音转文字区域 */
  996. .voice-text-section {
  997. display: flex;
  998. align-items: flex-end;
  999. gap: 20rpx;
  1000. }
  1001. .voice-text-content {
  1002. flex: 1;
  1003. background: #7d89b1;
  1004. padding: 20rpx;
  1005. border-radius: 8rpx;
  1006. font-size: 32rpx;
  1007. color: #fff;
  1008. line-height: 1.5;
  1009. }
  1010. /* 回执按钮通用样式 */
  1011. .inline-receipt-button,
  1012. .receipt-button {
  1013. background: #565d6d;
  1014. color: #fff;
  1015. padding: 10rpx 20rpx;
  1016. border-radius: 8rpx;
  1017. font-size: 28rpx;
  1018. white-space: nowrap;
  1019. cursor: pointer;
  1020. }
  1021. /* 右侧消息(发送) */
  1022. .right {
  1023. flex-direction: row-reverse;
  1024. }
  1025. .right .avatar {
  1026. border-radius: 50%;
  1027. }
  1028. .right .content-section {
  1029. align-items: flex-end;
  1030. }
  1031. .right .user-info {
  1032. text-align: right;
  1033. }
  1034. /* 右侧消息气泡样式 */
  1035. .right .text-message,
  1036. .right .call-message,
  1037. .right .voice-message,
  1038. .right .file-message,
  1039. .right .voice-text-content {
  1040. background: #eeeeee;
  1041. color: #333333;
  1042. border: 1rpx solid #dcdcdc;
  1043. }
  1044. .footer {
  1045. padding: 16rpx 24rpx;
  1046. background: #eeeeee;
  1047. display: flex;
  1048. align-items: flex-end;
  1049. gap: 16rpx;
  1050. border-top: 4rpx solid transparent;
  1051. box-sizing: border-box;
  1052. }
  1053. .footer.active {
  1054. border-top-color: #dcdcdc;
  1055. }
  1056. .tool-btn {
  1057. width: 78rpx;
  1058. height: 78rpx;
  1059. border-radius: 4rpx;
  1060. background: #ffffff;
  1061. border: 1rpx solid #e5e7eb;
  1062. display: flex;
  1063. align-items: center;
  1064. justify-content: center;
  1065. flex-shrink: 0;
  1066. align-self: flex-end;
  1067. }
  1068. .center-area {
  1069. flex: 1;
  1070. min-width: 0;
  1071. display: flex;
  1072. align-items: flex-end;
  1073. }
  1074. .press-to-talk {
  1075. width: 100%;
  1076. height: 78rpx;
  1077. border-radius: 4rpx;
  1078. background: #ffffff;
  1079. border: 1rpx solid #e5e7eb;
  1080. display: flex;
  1081. align-items: center;
  1082. justify-content: center;
  1083. gap: 12rpx;
  1084. }
  1085. .press-text {
  1086. color: #6b7280;
  1087. font-size: 30rpx;
  1088. line-height: 1;
  1089. }
  1090. .text-input {
  1091. width: 100%;
  1092. min-height: 82rpx;
  1093. max-height: 234rpx;
  1094. border-radius: 4rpx;
  1095. background: #ffffff;
  1096. border: 1rpx solid #e5e7eb;
  1097. padding: 18rpx 20rpx;
  1098. font-size: 32rpx;
  1099. line-height: 39rpx;
  1100. color: #111827;
  1101. overflow-y: auto;
  1102. box-sizing: border-box;
  1103. }
  1104. .text-input.capped {
  1105. height: 234rpx;
  1106. }
  1107. .bottom-panel {
  1108. background: #eeeeee;
  1109. border-top: 1rpx solid transparent;
  1110. max-height: 0;
  1111. opacity: 0;
  1112. overflow: hidden;
  1113. transform: translateY(24rpx);
  1114. transition: max-height 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
  1115. }
  1116. .bottom-panel.open {
  1117. border-top-color: #dcdcdc;
  1118. max-height: 380rpx;
  1119. opacity: 1;
  1120. transform: translateY(0);
  1121. }
  1122. .more-panel {
  1123. background: #eeeeee;
  1124. padding: 30rpx 24rpx;
  1125. box-sizing: border-box;
  1126. }
  1127. .emoji-panel {
  1128. background: #eeeeee;
  1129. padding: 20rpx 24rpx;
  1130. max-height: 320rpx;
  1131. overflow-y: auto;
  1132. }
  1133. .emoji-grid {
  1134. display: grid;
  1135. grid-template-columns: repeat(8, 1fr);
  1136. gap: 12rpx;
  1137. }
  1138. .emoji-item {
  1139. height: 52rpx;
  1140. line-height: 52rpx;
  1141. text-align: center;
  1142. font-size: 36rpx;
  1143. border-radius: 4rpx;
  1144. }
  1145. .more-grid {
  1146. display: flex;
  1147. align-items: flex-start;
  1148. justify-content: space-between;
  1149. }
  1150. .more-item {
  1151. width: 25%;
  1152. display: flex;
  1153. flex-direction: column;
  1154. align-items: center;
  1155. gap: 16rpx;
  1156. }
  1157. .more-icon {
  1158. width: 96rpx;
  1159. height: 96rpx;
  1160. border-radius: 4rpx;
  1161. background: #ffffff;
  1162. border: 1rpx solid #e5e7eb;
  1163. display: flex;
  1164. align-items: center;
  1165. justify-content: center;
  1166. }
  1167. .more-text {
  1168. font-size: 28rpx;
  1169. color: #6b7280;
  1170. white-space: nowrap;
  1171. }
  1172. .media-preview-mask {
  1173. position: fixed;
  1174. left: 0;
  1175. top: 0;
  1176. width: 100vw;
  1177. height: 100vh;
  1178. background: rgba(0, 0, 0, 0.78);
  1179. display: flex;
  1180. align-items: center;
  1181. justify-content: center;
  1182. z-index: 9999;
  1183. }
  1184. .media-preview-content {
  1185. display: flex;
  1186. align-items: center;
  1187. justify-content: center;
  1188. padding: 0;
  1189. box-sizing: border-box;
  1190. }
  1191. .media-preview-content.video-mode {
  1192. width: 100vw;
  1193. height: 100vh;
  1194. background: transparent;
  1195. border-radius: 0;
  1196. }
  1197. .media-preview-content.image-mode {
  1198. width: 100vw;
  1199. height: 100vh;
  1200. background: transparent;
  1201. border-radius: 0;
  1202. }
  1203. .media-preview-video {
  1204. width: 100vw;
  1205. height: 100vh;
  1206. object-fit: cover;
  1207. }
  1208. .media-preview-exit {
  1209. position: fixed;
  1210. top: 90rpx;
  1211. right: 30rpx;
  1212. height: 56rpx;
  1213. line-height: 56rpx;
  1214. padding: 0 18rpx;
  1215. border-radius: 28rpx;
  1216. font-size: 26rpx;
  1217. color: #fff;
  1218. background: rgba(0, 0, 0, 0.45);
  1219. z-index: 10001;
  1220. }
  1221. .media-preview-swiper {
  1222. width: 100vw;
  1223. height: 100vh;
  1224. }
  1225. .media-preview-swiper-item {
  1226. display: flex;
  1227. align-items: center;
  1228. justify-content: center;
  1229. }
  1230. .media-preview-image.fit-x {
  1231. width: 100vw;
  1232. height: auto;
  1233. }
  1234. .file-dialog-mask {
  1235. position: fixed;
  1236. left: 0;
  1237. top: 0;
  1238. width: 100vw;
  1239. height: 100vh;
  1240. background: rgba(255, 255, 255, 0.96);
  1241. display: flex;
  1242. align-items: center;
  1243. justify-content: center;
  1244. z-index: 10000;
  1245. }
  1246. .file-dialog {
  1247. width: 100vw;
  1248. height: 100vh;
  1249. background: transparent;
  1250. border-radius: 0;
  1251. padding: 0 60rpx;
  1252. box-sizing: border-box;
  1253. display: flex;
  1254. flex-direction: column;
  1255. align-items: center;
  1256. justify-content: center;
  1257. }
  1258. .file-dialog-header {
  1259. display: flex;
  1260. flex-direction: column;
  1261. align-items: center;
  1262. gap: 18rpx;
  1263. }
  1264. .file-dialog-name {
  1265. max-width: 620rpx;
  1266. font-size: 30rpx;
  1267. color: #333;
  1268. white-space: nowrap;
  1269. overflow: hidden;
  1270. text-overflow: ellipsis;
  1271. text-align: center;
  1272. }
  1273. .file-dialog-actions {
  1274. display: flex;
  1275. justify-content: center;
  1276. gap: 24rpx;
  1277. padding-top: 40rpx;
  1278. }
  1279. .file-dialog-btn {
  1280. min-width: 120rpx;
  1281. height: 64rpx;
  1282. line-height: 64rpx;
  1283. text-align: center;
  1284. background: #575d6d;
  1285. color: #fff;
  1286. font-size: 28rpx;
  1287. border-radius: 8rpx;
  1288. }
  1289. .file-dialog-btn.ghost {
  1290. background: #f1f2f4;
  1291. color: #666;
  1292. }
  1293. .record-mask {
  1294. position: fixed;
  1295. left: 0;
  1296. top: 0;
  1297. width: 100vw;
  1298. height: 100vh;
  1299. background: rgba(0, 0, 0, 0.2);
  1300. display: flex;
  1301. align-items: center;
  1302. justify-content: center;
  1303. z-index: 12000;
  1304. pointer-events: none;
  1305. }
  1306. .record-panel {
  1307. width: 360rpx;
  1308. padding: 30rpx 24rpx;
  1309. border-radius: 16rpx;
  1310. background: rgba(0, 0, 0, 0.72);
  1311. display: flex;
  1312. flex-direction: column;
  1313. align-items: center;
  1314. gap: 14rpx;
  1315. }
  1316. .record-title {
  1317. font-size: 32rpx;
  1318. color: #fff;
  1319. }
  1320. .record-time {
  1321. font-size: 42rpx;
  1322. font-weight: 600;
  1323. color: #fff;
  1324. }
  1325. .record-tip {
  1326. font-size: 26rpx;
  1327. color: rgba(255, 255, 255, 0.9);
  1328. }
  1329. .record-tip.danger {
  1330. color: #ffb2b2;
  1331. }
  1332. }
  1333. </style>