detail-camera.vue 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532
  1. <template>
  2. <view class="container">
  3. <!-- 设备头部信息区域 -->
  4. <view class="device-header">
  5. <view class="device-info-row">
  6. <view class="device-name-container">
  7. <text class="device-name">{{ deviceInfo.name }}</text>
  8. <view
  9. class="status-tag"
  10. :class="deviceInfo.status === 1 ? 'status-online' : 'status-offline'"
  11. >
  12. <view class="status-dot" :class="{'offline-dot': deviceInfo.status === 1}"></view>
  13. {{ deviceInfo.status === 1 ? '在线' : '离线' }}
  14. </view>
  15. </view>
  16. <view class="refresh-btn" :class="{'refreshing': isRefreshing}" @tap="refreshData">
  17. <image src="/static/icons/refresh_icon.png" mode="aspectFit" style="width: 22px; height: 22px;"></image>
  18. </view>
  19. </view>
  20. <view class="device-meta-row">
  21. <view class="device-meta-item">
  22. <view class="meta-icon">
  23. <image src="/static/icons/device_icon.png" mode="aspectFit" style="width: 36rpx; height: 36rpx;"></image>
  24. </view>
  25. <text class="meta-label">设备编号:</text>
  26. <text class="meta-value">{{ deviceInfo.deviceId }}</text>
  27. </view>
  28. <view class="device-meta-item">
  29. <view class="meta-icon">
  30. <image src="/static/icons/location_icon.png" mode="aspectFit" style="width: 36rpx; height: 36rpx;"></image>
  31. </view>
  32. <text class="meta-label">安装位置:</text>
  33. <text class="meta-value">{{ deviceInfo.location }}</text>
  34. </view>
  35. <view class="device-meta-item">
  36. <view class="meta-icon">
  37. <image src="/static/icons/clock_icon.png" mode="aspectFit" style="width: 36rpx; height: 36rpx;"></image>
  38. </view>
  39. <text class="meta-label">最近更新:</text>
  40. <text class="meta-value">{{ formatDate(deviceInfo.lastUpdate) }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 视频预览区域 -->
  45. <view class="video-section">
  46. <view class="video-container" :class="{'fullscreen-mode': isFullscreen}">
  47. <image v-if="!isPlaying" src="/static/images/video-placeholder.jpg" mode="aspectFill" class="video-placeholder"></image>
  48. <!-- 使用跨平台视频播放组件 -->
  49. <!-- #ifdef H5 -->
  50. <view v-if="isPlaying" class="h5-video-wrapper">
  51. <Jessibuca ref="jessibucaRef" :videoUrl="getH5StreamUrl" :hasAudio="true" @error="onVideoError" />
  52. </view>
  53. <!-- #endif -->
  54. <!-- #ifdef MP-WEIXIN -->
  55. <live-player
  56. v-if="isPlaying"
  57. id="videoPlayer"
  58. :src="getMiniProgramStreamUrl"
  59. mode="live"
  60. :autoplay="true"
  61. :muted="isMuted"
  62. object-fit="contain"
  63. @statechange="onStateChange"
  64. @error="onVideoError"
  65. @fullscreenchange="onFullscreenChange"
  66. class="video-player"
  67. ></live-player>
  68. <!-- #endif -->
  69. <!-- 视频控制层 -->
  70. <view class="video-controls">
  71. <view class="control-row top-controls">
  72. <view class="signal-indicator">
  73. <image src="/static/icons/signal_icon.png" mode="aspectFit" style="width: 16px; height: 16px;"></image>
  74. <text class="signal-text">信号良好</text>
  75. </view>
  76. <view class="fullscreen-button" @click="toggleFullscreen">
  77. <image src="/static/icons/resize_icon.png" mode="aspectFit" style="width: 20px; height: 20px;"></image>
  78. </view>
  79. </view>
  80. <view class="control-row center-controls">
  81. <view v-if="!isPlaying" class="play-button" @click="togglePlayState">
  82. <image src="/static/icons/play_icon.png" mode="aspectFit" style="width: 32px; height: 32px;"></image>
  83. </view>
  84. <view v-else class="center-button-container" @click="togglePlayState">
  85. <view class="pause-icon">
  86. <image src="/static/icons/pause_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="control-row bottom-controls">
  91. <view class="video-time">{{ currentTime }}</view>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 云台控制区域 -->
  97. <!-- <view class="ptz-section">
  98. <view class="section-title">云台控制</view>
  99. <view class="ptz-container">
  100. // 圆形云台控制
  101. <view class="ptz-circle-container">
  102. 上箭头
  103. <view class="ptz-arrow ptz-up" @touchstart="controlPTZ('up', true)" @touchend="controlPTZ('up', false)">
  104. <image src="/static/icons/arrow_up_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  105. </view>
  106. // 左箭头
  107. <view class="ptz-arrow ptz-left" @touchstart="controlPTZ('left', true)" @touchend="controlPTZ('left', false)">
  108. <image src="/static/icons/arrow_left_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  109. </view>
  110. 中心拍照按钮
  111. <view class="ptz-center" @click="takeScreenshot">
  112. <image src="/static/icons/camera_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  113. </view>
  114. 右箭头
  115. <view class="ptz-arrow ptz-right" @touchstart="controlPTZ('right', true)" @touchend="controlPTZ('right', false)">
  116. <image src="/static/icons/arrow_right_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  117. </view>
  118. 下箭头
  119. <view class="ptz-arrow ptz-down" @touchstart="controlPTZ('down', true)" @touchend="controlPTZ('down', false)">
  120. <image src="/static/icons/arrow_down_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  121. </view>
  122. </view>
  123. 底部操作按钮
  124. <view class="ptz-bottom-controls">
  125. <view class="ptz-bottom-button" @touchstart="controlZoom('out', true)" @touchend="controlZoom('out', false)">
  126. <image src="/static/icons/zoom01_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  127. </view>
  128. <view class="ptz-bottom-button" @click="resetPTZ">
  129. <image src="/static/icons/resetPTZ_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  130. </view>
  131. <view class="ptz-bottom-button" @touchstart="controlZoom('in', true)" @touchend="controlZoom('in', false)">
  132. <image src="/static/icons/zoom02_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  133. </view>
  134. </view>
  135. </view>
  136. </view> -->
  137. <!-- 快捷功能按钮 -->
  138. <!-- <view class="quick-actions">
  139. <view class="action-button" @click="toggleVoiceIntercom">
  140. <view class="action-icon">
  141. <image src="/static/icons/Voice_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  142. </view>
  143. <text class="action-text">语音对讲</text>
  144. </view>
  145. <view class="action-button" @click="toggleMute">
  146. <view class="action-icon">
  147. <image v-if="isMuted" src="/static/icons/muted_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  148. <image v-else src="/static/icons/unmuted_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  149. </view>
  150. <text class="action-text">{{ isMuted ? '取消静音' : '静音' }}</text>
  151. </view>
  152. <view class="action-button" @click="navigateToHistory">
  153. <view class="action-icon">
  154. <image src="/static/icons/action_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  155. </view>
  156. <text class="action-text">视频回看</text>
  157. </view>
  158. </view> -->
  159. <!-- 告警信息列表 -->
  160. <view class="alerts-section">
  161. <view class="section-title">
  162. <text>告警信息</text>
  163. <view class="alert-badge" v-if="getUnhandledAlerts.length > 0">{{ getUnhandledAlerts.length }}</view>
  164. </view>
  165. <view class="alerts-list" v-if="getUnhandledAlerts.length > 0">
  166. <view
  167. v-for="(item, index) in getUnhandledAlerts.slice(0, 3)"
  168. :key="index"
  169. class="alert-item"
  170. :class="{
  171. 'alert-urgent': item.level === 3,
  172. 'alert-warning': item.level === 2,
  173. 'alert-info': item.level === 1
  174. }"
  175. >
  176. <view class="alert-item-icon">
  177. <image v-if="item.level === 3" src="/static/icons/warning_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  178. <image v-else-if="item.level === 2" src="/static/icons/info_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  179. <image v-else src="/static/icons/success_icon.png" mode="aspectFit" style="width: 24px; height: 24px;"></image>
  180. </view>
  181. <view class="alert-item-info">
  182. <text class="alert-item-type">{{ item.type }}</text>
  183. <text class="alert-item-level">
  184. {{ item.level === 3 ? '紧急' : item.level === 2 ? '警告' : '提示' }}
  185. </text>
  186. </view>
  187. <view class="alert-item-time">{{ formatSmartTime(item.time) }}</view>
  188. </view>
  189. </view>
  190. <view v-else class="empty-alert">
  191. <text class="empty-text">暂无告警信息</text>
  192. </view>
  193. </view>
  194. </view>
  195. </template>
  196. <script>
  197. import { getDeviceCollectorDetail } from "@/api/services/device.js";
  198. import { formatSmartTime, formatDate, getFormattedTime} from '@/utils/dateUtils'
  199. import { isPlayableInMiniProgram, buildPlatformStreamUrls } from '@/utils/media-utils'
  200. import config from '@/config/config'
  201. // 导入Jessibuca组件
  202. // #ifdef H5
  203. import Jessibuca from '@/components/common/jessibuca.vue'
  204. // #endif
  205. export default {
  206. components: {
  207. // #ifdef H5
  208. Jessibuca
  209. // #endif
  210. },
  211. data() {
  212. return {
  213. deviceInfo: {
  214. deviceId: '',
  215. name: '设备加载中...',
  216. status: '',
  217. location: '正在获取位置...',
  218. lastUpdate: '',
  219. deviceType: 'weather' ,// 默认类型,会根据API返回更新
  220. deviceTypeId:null,
  221. streamUrl: '',
  222. originalStreamUrl: 'ws://121.4.16.100:6080/rtp/34020000001110000001_34020000001320000012.live.flv',
  223. },
  224. isPlaying: false,
  225. isMuted: false,
  226. isRecording: false,
  227. isFullscreen: false,
  228. isVoiceActive: false,
  229. isGridView: false,
  230. isZoomMode: false,
  231. currentTime: '14:30:25',
  232. // 模拟历史录像数据
  233. recordHistory: [
  234. { id: 1, startTime: '今天 12:30', duration: '00:15:30', url: '' },
  235. { id: 2, startTime: '今天 10:15', duration: '00:05:22', url: '' },
  236. { id: 3, startTime: '昨天 18:45', duration: '00:30:10', url: '' },
  237. { id: 4, startTime: '昨天 14:20', duration: '00:10:05', url: '' }
  238. ],
  239. // 模拟告警数据
  240. alertHistory: [],
  241. livePlayerContext: null, // 小程序视频上下文
  242. isRefreshing: false
  243. }
  244. },
  245. computed: {
  246. // 获取所有未处理的告警
  247. getUnhandledAlerts() {
  248. return this.alertHistory.filter(alert => alert.status === 0);
  249. },
  250. // 获取H5环境使用的流地址
  251. getH5StreamUrl() {
  252. // 首先尝试使用设备返回的流URL
  253. // if (this.deviceInfo.streamUrl) {
  254. // return this.deviceInfo.streamUrl;
  255. // }
  256. // 如果没有设备特定的URL,则使用默认原始流
  257. return this.deviceInfo.originalStreamUrl || config.streamServer.wsFlvServer;
  258. },
  259. // 获取小程序环境使用的流地址
  260. getMiniProgramStreamUrl() {
  261. // 获取合适的小程序流地址
  262. const { streamServer } = config;
  263. // 如果有设备特定的RTMP流,优先使用
  264. if (this.deviceInfo.rtmpUrl) {
  265. return this.deviceInfo.rtmpUrl;
  266. }
  267. // 其次尝试使用HLS流
  268. if (this.deviceInfo.hlsUrl) {
  269. return this.deviceInfo.hlsUrl;
  270. }
  271. // 最后使用配置的默认流
  272. return streamServer.rtmpServer || streamServer.hlsServer;
  273. },
  274. },
  275. onReady() {
  276. // 设置页面标题
  277. uni.setNavigationBarTitle({
  278. title: this.deviceInfo.name
  279. })
  280. // 模拟更新时间
  281. this.startTimeUpdate()
  282. // #ifdef MP-WEIXIN
  283. // 创建小程序视频上下文
  284. this.livePlayerContext = uni.createLivePlayerContext('videoPlayer', this)
  285. // #endif
  286. // #ifdef H5
  287. // 加载Jessibuca的JS库
  288. this.loadJessibucaScript()
  289. // #endif
  290. // 监听全屏状态变化
  291. this.setupFullscreenListener()
  292. // 添加键盘事件监听
  293. this.setupKeyboardListener()
  294. // 初始化流地址
  295. this.initStreamUrl()
  296. },
  297. beforeUnmount() {
  298. // 移除全屏状态监听
  299. this.removeFullscreenListener()
  300. // 移除键盘事件监听
  301. this.removeKeyboardListener()
  302. },
  303. onLoad(options) {
  304. uni.$once('passDeviceData', (data) => {
  305. console.log('接收到数据', data);
  306. // 如果有传入设备ID,则获取设备信息
  307. if (data && data.deviceId) {
  308. this.deviceInfo.deviceId = data.deviceId;
  309. this.deviceInfo.location = data.fieldName;
  310. this.deviceInfo.name = data.deviceName;
  311. this.deviceInfo.status = data.status;
  312. this.deviceInfo.deviceTypeId = data.deviceTypeId || '';
  313. // 加载设备详情
  314. this.fetchDeviceInfo();
  315. }
  316. });
  317. },
  318. methods: {
  319. formatDate,
  320. formatSmartTime,
  321. // 加载Jessibuca脚本
  322. loadJessibucaScript() {
  323. const script = document.createElement('script')
  324. script.src = '/static/js/jessibuca/jessibuca.js'
  325. script.onload = () => {
  326. console.log('Jessibuca 脚本加载成功')
  327. }
  328. script.onerror = (error) => {
  329. console.error('Jessibuca 脚本加载失败:', error)
  330. }
  331. document.head.appendChild(script)
  332. },
  333. // 获取设备信息
  334. fetchDeviceInfo(deviceId) {
  335. // 这里应该是API请求,暂时用模拟数据
  336. console.log('获取设备信息:', deviceId)
  337. getDeviceCollectorDetail(this.deviceInfo.deviceId)
  338. .then(res => {
  339. if (res.data.data && res.data.code === 200) {
  340. const detail = res.data.data;
  341. this.deviceInfo.lastUpdate = getFormattedTime()
  342. // 更新页面标题
  343. uni.setNavigationBarTitle({
  344. title: this.deviceInfo.name
  345. });
  346. // 更新告警信息
  347. if (detail.alertRecordList && detail.alertRecordList.length > 0) {
  348. this.alertHistory = detail.alertRecordList.map(alert => ({
  349. id: alert.alertId,
  350. time: alert.alertTime,
  351. type: alert.alertContent,
  352. status: alert.processStatus,
  353. level: alert.alertLevel
  354. }));
  355. }
  356. }
  357. })
  358. },
  359. // 播放/暂停切换
  360. togglePlayState() {
  361. if (!this.isPlaying) {
  362. // 从未播放状态切换到播放状态
  363. this.isPlaying = true
  364. // #ifdef MP-WEIXIN
  365. // 小程序环境中,短暂延迟确保组件已加载
  366. setTimeout(() => {
  367. if (this.livePlayerContext) {
  368. this.livePlayerContext.play({
  369. success: () => {
  370. console.log('小程序视频播放成功')
  371. uni.vibrateShort()
  372. },
  373. fail: (err) => {
  374. console.error('小程序视频播放失败:', err)
  375. uni.showToast({
  376. title: '视频播放失败',
  377. icon: 'none'
  378. })
  379. }
  380. })
  381. }
  382. }, 300)
  383. // #endif
  384. // #ifdef H5
  385. // 浏览器环境中使用Jessibuca
  386. setTimeout(() => {
  387. uni.vibrateShort()
  388. }, 300)
  389. // #endif
  390. } else {
  391. // 从播放状态切换到暂停状态
  392. // #ifdef H5
  393. if (this.$refs.jessibucaRef) {
  394. this.$refs.jessibucaRef.pause()
  395. }
  396. // #endif
  397. // #ifdef MP-WEIXIN
  398. if (this.livePlayerContext) {
  399. this.livePlayerContext.pause()
  400. }
  401. // #endif
  402. this.isPlaying = false
  403. // 在页面上显示暂停状态
  404. uni.showToast({
  405. title: '视频已暂停',
  406. icon: 'none',
  407. duration: 1500
  408. })
  409. }
  410. },
  411. // 静音切换
  412. toggleMute() {
  413. this.isMuted = !this.isMuted
  414. // #ifdef H5
  415. if (this.$refs.jessibucaRef) {
  416. if (this.isMuted) {
  417. this.$refs.jessibucaRef.mute()
  418. } else {
  419. this.$refs.jessibucaRef.cancelMute()
  420. }
  421. }
  422. // #endif
  423. // #ifdef MP-WEIXIN
  424. // 小程序环境中直接通过属性绑定控制静音
  425. // #endif
  426. },
  427. // 全屏切换
  428. toggleFullscreen() {
  429. if (!this.isPlaying) {
  430. // 如果视频未播放,先开始播放
  431. this.togglePlayState()
  432. // 延迟执行全屏操作,等待视频元素加载
  433. setTimeout(() => {
  434. this.setFullscreen(true)
  435. }, 500)
  436. } else {
  437. this.setFullscreen(!this.isFullscreen)
  438. }
  439. },
  440. // 设置全屏状态
  441. setFullscreen(fullscreen) {
  442. this.isFullscreen = fullscreen
  443. // #ifdef H5
  444. // 浏览器环境
  445. if (this.isFullscreen) {
  446. // 如果是移动设备,尝试使用系统全屏
  447. const ua = navigator.userAgent.toLowerCase()
  448. const isMobile = /mobile|android|iphone|ipad/.test(ua)
  449. if (isMobile && this.$refs.jessibucaRef) {
  450. // 在移动设备上使用Jessibuca的全屏API
  451. this.$refs.jessibucaRef.fullscreenSwich()
  452. } else {
  453. // 适配屏幕尺寸
  454. setTimeout(() => {
  455. if (this.$refs.jessibucaRef) {
  456. this.$refs.jessibucaRef.resize()
  457. }
  458. }, 300)
  459. }
  460. // 锁定屏幕方向为横屏
  461. if (window.screen && window.screen.orientation && window.screen.orientation.lock) {
  462. window.screen.orientation.lock('landscape').catch(err => {
  463. console.error('无法锁定屏幕方向:', err)
  464. })
  465. }
  466. } else {
  467. // 退出全屏状态
  468. if (this.$refs.jessibucaRef) {
  469. // 在某些情况下需要先调用Jessibuca的退出全屏
  470. if (this.$refs.jessibucaRef.isFullscreen()) {
  471. this.$refs.jessibucaRef.fullscreenSwich()
  472. }
  473. // 重置视频大小
  474. setTimeout(() => {
  475. if (this.$refs.jessibucaRef) {
  476. this.$refs.jessibucaRef.resize()
  477. }
  478. }, 300)
  479. }
  480. // 解除屏幕方向锁定
  481. if (window.screen && window.screen.orientation && window.screen.orientation.unlock) {
  482. window.screen.orientation.unlock()
  483. }
  484. }
  485. // #endif
  486. // #ifdef MP-WEIXIN
  487. // 小程序环境
  488. if (this.livePlayerContext) {
  489. if (this.isFullscreen) {
  490. this.livePlayerContext.requestFullScreen({
  491. direction: 90, // 横屏
  492. success: () => {
  493. console.log('进入全屏模式成功')
  494. },
  495. fail: (err) => {
  496. console.error('进入全屏模式失败:', err)
  497. }
  498. })
  499. } else {
  500. this.livePlayerContext.exitFullScreen({
  501. success: () => {
  502. console.log('退出全屏模式成功')
  503. },
  504. fail: (err) => {
  505. console.error('退出全屏模式失败:', err)
  506. }
  507. })
  508. }
  509. }
  510. // #endif
  511. },
  512. // 截图
  513. takeScreenshot() {
  514. // #ifdef H5
  515. if (this.$refs.jessibucaRef && this.isPlaying) {
  516. this.$refs.jessibucaRef.screenshot()
  517. uni.showToast({
  518. title: '截图已保存',
  519. icon: 'success'
  520. })
  521. } else {
  522. uni.showToast({
  523. title: '请先播放视频',
  524. icon: 'none'
  525. })
  526. }
  527. // #endif
  528. // #ifdef MP-WEIXIN
  529. if (this.livePlayerContext && this.isPlaying) {
  530. this.livePlayerContext.snapshot({
  531. success: (res) => {
  532. console.log('截图成功:', res.tempImagePath)
  533. // 可以保存到相册或做其他处理
  534. uni.saveImageToPhotosAlbum({
  535. filePath: res.tempImagePath,
  536. success: () => {
  537. uni.showToast({
  538. title: '截图已保存到相册',
  539. icon: 'success'
  540. })
  541. },
  542. fail: (err) => {
  543. console.error('保存截图失败:', err)
  544. uni.showToast({
  545. title: '保存截图失败',
  546. icon: 'none'
  547. })
  548. }
  549. })
  550. },
  551. fail: (err) => {
  552. console.error('截图失败:', err)
  553. uni.showToast({
  554. title: '截图失败',
  555. icon: 'none'
  556. })
  557. }
  558. })
  559. } else {
  560. uni.showToast({
  561. title: '请先播放视频',
  562. icon: 'none'
  563. })
  564. }
  565. // #endif
  566. },
  567. // 小程序播放器状态变化处理
  568. onStateChange(e) {
  569. console.log('播放器状态变化:', e.detail)
  570. const state = e.detail.code
  571. // 根据状态码处理
  572. switch (state) {
  573. case 2001: // 已连接服务器
  574. console.log('已连接服务器')
  575. break
  576. case 2002: // 已连接服务器,开始拉流
  577. console.log('开始拉流')
  578. break
  579. case 2003: // 网络接收到首个视频帧
  580. console.log('网络接收到首个视频帧')
  581. break
  582. case 2004: // 视频播放开始
  583. console.log('视频播放开始')
  584. break
  585. case 2005: // 视频播放进度
  586. console.log('视频播放进度')
  587. break
  588. case 2006: // 视频播放结束
  589. console.log('视频播放结束')
  590. this.isPlaying = false
  591. break
  592. case 2007: // 视频播放Loading
  593. console.log('视频播放Loading')
  594. break
  595. case 2008: // 解码器启动
  596. console.log('解码器启动')
  597. break
  598. case 2009: // 视频分辨率改变
  599. console.log('视频分辨率改变')
  600. break
  601. case -2301: // 网络断连,且重新连接亦不能恢复,播放器已停止
  602. console.error('网络断连,且重新连接亦不能恢复,播放器已停止')
  603. this.isPlaying = false
  604. uni.showToast({
  605. title: '网络断连,请重试',
  606. icon: 'none'
  607. })
  608. break
  609. case -2302: // 获取加速拉流地址失败
  610. console.error('获取加速拉流地址失败')
  611. break
  612. case 2101: // 当前视频帧解码失败
  613. console.error('当前视频帧解码失败')
  614. break
  615. case 2102: // 当前音频帧解码失败
  616. console.error('当前音频帧解码失败')
  617. break
  618. case 2103: // 网络断连, 已启动自动重连
  619. console.warn('网络断连, 已启动自动重连')
  620. break
  621. case 2104: // 网络断连, 重连中...
  622. console.warn('网络断连, 重连中...')
  623. break
  624. case 2105: // 网络断连, 重连成功
  625. console.log('网络断连, 重连成功')
  626. break
  627. case 2106: // 网络断连, 重连失败
  628. console.error('网络断连, 重连失败')
  629. break
  630. case 2107: // 播放器连接超时
  631. console.error('播放器连接超时')
  632. break
  633. case 2108: // 获取点播文件信息失败
  634. console.error('获取点播文件信息失败')
  635. break
  636. default:
  637. console.log('其他状态:', state)
  638. }
  639. },
  640. // 小程序全屏状态变化
  641. onFullscreenChange(e) {
  642. this.isFullscreen = e.detail.fullScreen
  643. console.log('全屏状态变化:', this.isFullscreen)
  644. },
  645. // 初始化流地址
  646. initStreamUrl() {
  647. const originalUrl = this.deviceInfo.originalStreamUrl
  648. // 使用配置中的流服务器信息
  649. const streamUrls = buildPlatformStreamUrls(originalUrl, {
  650. streamServer: config.streamServer,
  651. fallbackToHls: true
  652. })
  653. // #ifdef H5
  654. this.deviceInfo.streamUrl = streamUrls.h5Url
  655. // #endif
  656. // #ifdef MP-WEIXIN
  657. // 检查是否可以在小程序中播放
  658. if (streamUrls.miniProgramUrl) {
  659. this.deviceInfo.streamUrl = streamUrls.miniProgramUrl
  660. } else {
  661. // 如果没有可用的小程序播放地址,显示提示
  662. uni.showToast({
  663. title: '当前视频流不支持小程序播放',
  664. icon: 'none',
  665. duration: 3000
  666. })
  667. }
  668. // #endif
  669. console.log('初始化流地址:', this.deviceInfo.streamUrl)
  670. },
  671. // 切换九宫格视图
  672. toggleGridView() {
  673. this.isGridView = !this.isGridView
  674. uni.showToast({
  675. title: this.isGridView ? '切换到多画面模式' : '切换到单画面模式',
  676. icon: 'none'
  677. })
  678. },
  679. // 语音对讲
  680. toggleVoiceIntercom() {
  681. this.isVoiceActive = !this.isVoiceActive
  682. if (this.isVoiceActive) {
  683. uni.showToast({
  684. title: '语音对讲已开启',
  685. icon: 'none'
  686. })
  687. } else {
  688. uni.showToast({
  689. title: '语音对讲已关闭',
  690. icon: 'none'
  691. })
  692. }
  693. },
  694. // 云台控制
  695. controlPTZ(direction, isStart) {
  696. // 模拟云台控制
  697. if (isStart) {
  698. console.log(`开始控制云台: ${direction}`)
  699. uni.vibrateShort() // 短震动反馈
  700. } else {
  701. console.log(`停止控制云台: ${direction}`)
  702. }
  703. },
  704. // 云台复位
  705. resetPTZ() {
  706. console.log('云台复位')
  707. uni.vibrateShort() // 短震动反馈
  708. uni.showToast({
  709. title: '云台已复位',
  710. icon: 'none'
  711. })
  712. },
  713. // 变焦控制
  714. controlZoom(type, isStart) {
  715. // 模拟变焦控制
  716. if (isStart) {
  717. console.log(`开始控制变焦: ${type}`)
  718. uni.vibrateShort() // 短震动反馈
  719. } else {
  720. console.log(`停止控制变焦: ${type}`)
  721. }
  722. },
  723. // 切换缩放模式
  724. toggleZoom() {
  725. this.isZoomMode = !this.isZoomMode
  726. uni.showToast({
  727. title: this.isZoomMode ? '进入缩放模式' : '退出缩放模式',
  728. icon: 'none'
  729. })
  730. },
  731. // 添加预设位
  732. addPreset() {
  733. uni.showModal({
  734. title: '添加预设位',
  735. content: '是否保存当前位置为预设位?',
  736. success: (res) => {
  737. if (res.confirm) {
  738. uni.showToast({
  739. title: '预设位已保存',
  740. icon: 'success'
  741. })
  742. }
  743. }
  744. })
  745. },
  746. // 处理告警点击
  747. handleAlert(item) {
  748. uni.navigateTo({
  749. url: `/pages/alerts/alert-detail?alertId=${item.id}&deviceId=${this.deviceInfo.deviceId}`
  750. })
  751. },
  752. // 跳转到历史视频页面
  753. navigateToHistory() {
  754. uni.navigateTo({
  755. url: `/pages/video/history?deviceId=${this.deviceInfo.deviceId}`
  756. })
  757. },
  758. // 视频播放错误处理
  759. onVideoError(e) {
  760. console.error('视频播放错误:', e);
  761. uni.showToast({
  762. title: '视频加载失败,请检查网络连接',
  763. icon: 'none',
  764. duration: 2000
  765. });
  766. // 在H5环境,尝试重新加载或使用备用流
  767. // #ifdef H5
  768. setTimeout(() => {
  769. if (this.isPlaying && this.$refs.jessibucaRef) {
  770. console.log('尝试重新加载视频流');
  771. // 可以尝试使用备用流地址
  772. if (this.deviceInfo.originalStreamUrl !== config.streamServer.wsFlvServer) {
  773. this.deviceInfo.streamUrl = config.streamServer.wsFlvServer;
  774. this.$nextTick(() => {
  775. if (this.$refs.jessibucaRef) {
  776. this.$refs.jessibucaRef.play();
  777. }
  778. });
  779. }
  780. }
  781. }, 3000);
  782. // #endif
  783. },
  784. // 更新时间
  785. startTimeUpdate() {
  786. // 模拟时间更新
  787. setInterval(() => {
  788. const now = new Date()
  789. const hours = String(now.getHours()).padStart(2, '0')
  790. const minutes = String(now.getMinutes()).padStart(2, '0')
  791. const seconds = String(now.getSeconds()).padStart(2, '0')
  792. this.currentTime = `${hours}:${minutes}:${seconds}`
  793. }, 1000)
  794. },
  795. // 设置全屏状态监听
  796. setupFullscreenListener() {
  797. this.fullscreenChangeHandler = () => {
  798. const isFullscreen = !!(
  799. document.fullscreenElement ||
  800. document.mozFullScreenElement ||
  801. document.webkitFullscreenElement ||
  802. document.msFullscreenElement
  803. );
  804. if (this.isFullscreen !== isFullscreen) {
  805. this.isFullscreen = isFullscreen;
  806. }
  807. };
  808. // document.addEventListener('fullscreenchange', this.fullscreenChangeHandler);
  809. // document.addEventListener('webkitfullscreenchange', this.fullscreenChangeHandler);
  810. // document.addEventListener('mozfullscreenchange', this.fullscreenChangeHandler);
  811. // document.addEventListener('MSFullscreenChange', this.fullscreenChangeHandler);
  812. },
  813. // 移除全屏状态监听
  814. removeFullscreenListener() {
  815. if (this.fullscreenChangeHandler) {
  816. // document.removeEventListener('fullscreenchange', this.fullscreenChangeHandler);
  817. // document.removeEventListener('webkitfullscreenchange', this.fullscreenChangeHandler);
  818. // document.removeEventListener('mozfullscreenchange', this.fullscreenChangeHandler);
  819. // document.removeEventListener('MSFullscreenChange', this.fullscreenChangeHandler);
  820. }
  821. },
  822. // 设置键盘监听
  823. setupKeyboardListener() {
  824. this.keydownHandler = (event) => {
  825. // ESC键退出全屏
  826. if (event.key === 'Escape' && this.isFullscreen) {
  827. this.setFullscreen(false);
  828. }
  829. // F键切换全屏
  830. if (event.key === 'f' || event.key === 'F') {
  831. this.toggleFullscreen();
  832. event.preventDefault();
  833. }
  834. };
  835. // document.addEventListener('keydown', this.keydownHandler);
  836. },
  837. // 移除键盘监听
  838. removeKeyboardListener() {
  839. if (this.keydownHandler) {
  840. // document.removeEventListener('keydown', this.keydownHandler);
  841. }
  842. }
  843. }
  844. }
  845. </script>
  846. <style>
  847. /* 基础样式 */
  848. .container {
  849. display: flex;
  850. flex-direction: column;
  851. min-height: 100vh;
  852. background-color: #F8FCF9;
  853. padding-bottom: 30rpx;
  854. }
  855. /* 设备头部样式 */
  856. .device-header {
  857. background-color: #FFFFFF;
  858. border-radius: 20rpx;
  859. padding: 26rpx 30rpx 30rpx;
  860. margin: 20rpx 30rpx 20rpx;
  861. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
  862. }
  863. .device-info-row {
  864. display: flex;
  865. justify-content: space-between;
  866. align-items: flex-start;
  867. margin-bottom: 24rpx;
  868. }
  869. .device-name-container {
  870. display: flex;
  871. flex-direction: column;
  872. align-items: flex-start;
  873. }
  874. .device-name {
  875. font-size: 34rpx;
  876. color: #333333;
  877. font-weight: 600;
  878. margin-bottom: 10rpx;
  879. }
  880. .status-tag {
  881. padding: 4rpx 12rpx 4rpx 24rpx;
  882. border-radius: 30rpx;
  883. font-size: 22rpx;
  884. font-weight: 500;
  885. flex-shrink: 0;
  886. position: relative;
  887. overflow: hidden;
  888. }
  889. .status-online {
  890. background-color: rgba(76, 175, 80, 0.1);
  891. color: #3BB44A;
  892. }
  893. .status-offline {
  894. background-color: rgba(245, 108, 108, 0.1);
  895. color: #F56C6C;
  896. padding-left: 24rpx;
  897. }
  898. .status-dot {
  899. position: absolute;
  900. width: 6rpx;
  901. height: 6rpx;
  902. background-color: #3BB44A;
  903. border-radius: 50%;
  904. top: 50%;
  905. left: 12rpx;
  906. transform: translateY(-50%);
  907. box-shadow: 0 0 4rpx rgba(76, 175, 80, 0.8);
  908. animation: blink 1.5s infinite;
  909. display: inline-block;
  910. }
  911. .status-dot.offline-dot {
  912. background-color: #F56C6C;
  913. box-shadow: 0 0 4rpx rgba(245, 108, 108, 0.8);
  914. }
  915. @keyframes blink {
  916. 0% {
  917. opacity: 0.4;
  918. }
  919. 50% {
  920. opacity: 1;
  921. }
  922. 100% {
  923. opacity: 0.4;
  924. }
  925. }
  926. .device-meta-row {
  927. display: flex;
  928. flex-direction: column;
  929. }
  930. .device-meta-item {
  931. display: flex;
  932. align-items: center;
  933. font-size: 26rpx;
  934. margin-top: 18rpx;
  935. }
  936. .meta-icon {
  937. width: 36rpx;
  938. height: 36rpx;
  939. display: flex;
  940. align-items: center;
  941. justify-content: center;
  942. margin-right: 8rpx;
  943. }
  944. .meta-label {
  945. color: #999999;
  946. min-width: 140rpx;
  947. font-size: 26rpx;
  948. }
  949. .meta-value {
  950. color: #333333;
  951. flex: 1;
  952. font-size: 26rpx;
  953. }
  954. /* 视频预览区域 */
  955. .video-section {
  956. margin: 0 30rpx 20rpx;
  957. position: relative;
  958. z-index: 1;
  959. }
  960. .video-container {
  961. position: relative;
  962. width: 100%;
  963. height: 420rpx; /* 16:9比例 */
  964. background-color: #000000;
  965. border-radius: 16rpx;
  966. overflow: hidden;
  967. box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.1);
  968. transition: all 0.3s ease;
  969. }
  970. .video-container.fullscreen-mode {
  971. position: fixed;
  972. top: 0;
  973. left: 0;
  974. width: 100vw;
  975. height: 100vh;
  976. margin: 0;
  977. z-index: 9999;
  978. border-radius: 0;
  979. }
  980. .video-container.fullscreen-mode .video-controls {
  981. padding: 30rpx;
  982. }
  983. .video-container.fullscreen-mode .top-controls,
  984. .video-container.fullscreen-mode .bottom-controls {
  985. opacity: 0;
  986. transition: opacity 0.3s ease;
  987. }
  988. .video-container.fullscreen-mode:hover .top-controls,
  989. .video-container.fullscreen-mode:hover .bottom-controls {
  990. opacity: 1;
  991. }
  992. .video-player, .video-placeholder {
  993. width: 100%;
  994. height: 100%;
  995. object-fit: contain;
  996. }
  997. .video-controls {
  998. position: absolute;
  999. top: 0;
  1000. left: 0;
  1001. width: 100%;
  1002. height: 100%;
  1003. display: flex;
  1004. flex-direction: column;
  1005. justify-content: space-between;
  1006. padding: 20rpx;
  1007. box-sizing: border-box;
  1008. background: linear-gradient(to bottom, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0) 70%, rgba(0,0,0,0.4) 100%);
  1009. }
  1010. .control-row {
  1011. display: flex;
  1012. justify-content: space-between;
  1013. align-items: center;
  1014. width: 100%;
  1015. }
  1016. .top-controls {
  1017. height: 80rpx;
  1018. }
  1019. .center-controls {
  1020. height: 120rpx;
  1021. justify-content: center;
  1022. align-items: center;
  1023. }
  1024. .bottom-controls {
  1025. height: 80rpx;
  1026. }
  1027. .signal-indicator {
  1028. display: flex;
  1029. align-items: center;
  1030. color: #FFFFFF;
  1031. font-size: 24rpx;
  1032. background-color: rgba(0, 0, 0, 0.5);
  1033. padding: 8rpx 16rpx;
  1034. border-radius: 30rpx;
  1035. }
  1036. .signal-indicator svg {
  1037. margin-right: 8rpx;
  1038. }
  1039. .signal-text {
  1040. font-weight: 500;
  1041. }
  1042. .fullscreen-button {
  1043. width: 60rpx;
  1044. height: 60rpx;
  1045. display: flex;
  1046. align-items: center;
  1047. justify-content: center;
  1048. color: #FFFFFF;
  1049. background-color: rgba(0, 0, 0, 0.5);
  1050. border-radius: 50%;
  1051. transition: all 0.2s;
  1052. }
  1053. .fullscreen-button:active {
  1054. background-color: rgba(76, 175, 80, 0.7);
  1055. transform: scale(0.9);
  1056. }
  1057. .video-time {
  1058. color: #FFFFFF;
  1059. font-size: 26rpx;
  1060. background-color: rgba(0, 0, 0, 0.5);
  1061. padding: 6rpx 16rpx;
  1062. border-radius: 30rpx;
  1063. font-weight: 500;
  1064. }
  1065. .play-button {
  1066. width: 100rpx;
  1067. height: 100rpx;
  1068. border-radius: 50%;
  1069. background-color: rgba(255, 255, 255, 0.9);
  1070. display: flex;
  1071. align-items: center;
  1072. justify-content: center;
  1073. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.5);
  1074. transition: all 0.2s;
  1075. transform: scale(1);
  1076. }
  1077. .play-button:active {
  1078. transform: scale(0.92);
  1079. background-color: rgba(255, 255, 255, 1);
  1080. }
  1081. .center-button-container {
  1082. width: 100%;
  1083. height: 100%;
  1084. display: flex;
  1085. align-items: center;
  1086. justify-content: center;
  1087. }
  1088. .pause-icon {
  1089. width: 80rpx;
  1090. height: 80rpx;
  1091. border-radius: 50%;
  1092. background-color: rgba(0, 0, 0, 0.5);
  1093. display: flex;
  1094. align-items: center;
  1095. justify-content: center;
  1096. opacity: 0;
  1097. transition: opacity 0.3s;
  1098. }
  1099. .center-button-container:active .pause-icon {
  1100. opacity: 1;
  1101. background-color: rgba(76, 175, 80, 0.7);
  1102. }
  1103. /* 云台控制区域 */
  1104. .ptz-section {
  1105. margin: 0 30rpx 20rpx;
  1106. background-color: #FFFFFF;
  1107. border-radius: 20rpx;
  1108. padding: 24rpx;
  1109. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
  1110. }
  1111. .section-title {
  1112. font-size: 30rpx;
  1113. font-weight: 600;
  1114. color: #333333;
  1115. margin-bottom: 20rpx;
  1116. padding: 0 10rpx;
  1117. display: flex;
  1118. align-items: center;
  1119. }
  1120. .alert-badge {
  1121. background-color: #F56C6C;
  1122. color: #FFFFFF;
  1123. font-size: 22rpx;
  1124. border-radius: 30rpx;
  1125. padding: 2rpx 12rpx;
  1126. margin-left: 12rpx;
  1127. font-weight: normal;
  1128. min-width: 32rpx;
  1129. text-align: center;
  1130. }
  1131. .ptz-container {
  1132. display: flex;
  1133. flex-direction: column;
  1134. align-items: center;
  1135. padding: 20rpx 0;
  1136. }
  1137. .ptz-circle-container {
  1138. position: relative;
  1139. width: 300rpx;
  1140. height: 300rpx;
  1141. margin: 20rpx 0;
  1142. }
  1143. .ptz-arrow {
  1144. position: absolute;
  1145. width: 70rpx;
  1146. height: 70rpx;
  1147. display: flex;
  1148. align-items: center;
  1149. justify-content: center;
  1150. background-color: #F0F9F0;
  1151. border-radius: 50%;
  1152. color: #3BB44A;
  1153. font-size: 36rpx;
  1154. transition: all 0.2s;
  1155. box-shadow: 0 2rpx 10rpx rgba(76, 175, 80, 0.15);
  1156. }
  1157. .ptz-up {
  1158. top: 0;
  1159. left: 50%;
  1160. transform: translateX(-50%);
  1161. }
  1162. .ptz-down {
  1163. bottom: 0;
  1164. left: 50%;
  1165. transform: translateX(-50%);
  1166. }
  1167. .ptz-left {
  1168. left: 0;
  1169. top: 50%;
  1170. transform: translateY(-50%);
  1171. }
  1172. .ptz-right {
  1173. right: 0;
  1174. top: 50%;
  1175. transform: translateY(-50%);
  1176. }
  1177. .ptz-center {
  1178. position: absolute;
  1179. top: 50%;
  1180. left: 50%;
  1181. transform: translate(-50%, -50%);
  1182. width: 90rpx;
  1183. height: 90rpx;
  1184. display: flex;
  1185. align-items: center;
  1186. justify-content: center;
  1187. background-color: #F0F9F0;
  1188. border-radius: 50%;
  1189. color: #3BB44A;
  1190. font-size: 36rpx;
  1191. transition: all 0.2s;
  1192. box-shadow: 0 2rpx 10rpx rgba(76, 175, 80, 0.15);
  1193. }
  1194. .ptz-arrow:active, .ptz-center:active {
  1195. background-color: #3BB44A;
  1196. transform-origin: center;
  1197. }
  1198. .ptz-arrow:active svg path, .ptz-center:active svg path {
  1199. fill: #FFFFFF;
  1200. }
  1201. .ptz-up:active {
  1202. transform: scale(0.92) translateX(-50%);
  1203. }
  1204. .ptz-down:active {
  1205. transform: scale(0.92) translateX(-50%);
  1206. }
  1207. .ptz-left:active {
  1208. transform: scale(0.92) translateY(-50%);
  1209. }
  1210. .ptz-right:active {
  1211. transform: scale(0.92) translateY(-50%);
  1212. }
  1213. .ptz-center:active {
  1214. transform: translate(-50%, -50%) scale(0.92);
  1215. }
  1216. .ptz-bottom-controls {
  1217. display: flex;
  1218. justify-content: space-between;
  1219. align-items: center;
  1220. width: 300rpx;
  1221. margin-top: 30rpx;
  1222. }
  1223. .ptz-bottom-button {
  1224. width: 80rpx;
  1225. height: 80rpx;
  1226. border-radius: 50%;
  1227. background-color: #F0F9F0;
  1228. display: flex;
  1229. align-items: center;
  1230. justify-content: center;
  1231. color: #3BB44A;
  1232. font-size: 32rpx;
  1233. font-weight: 500;
  1234. transition: all 0.2s;
  1235. box-shadow: 0 2rpx 10rpx rgba(76, 175, 80, 0.1);
  1236. }
  1237. .ptz-bottom-button:active {
  1238. background-color: #3BB44A;
  1239. color: #FFFFFF;
  1240. transform: scale(0.92);
  1241. }
  1242. .ptz-bottom-button:active svg path {
  1243. fill: #FFFFFF;
  1244. }
  1245. /* 快捷功能按钮 */
  1246. .quick-actions {
  1247. display: flex;
  1248. justify-content: space-evenly;
  1249. margin: 0 30rpx 20rpx;
  1250. background-color: #FFFFFF;
  1251. border-radius: 20rpx;
  1252. padding: 24rpx 30rpx;
  1253. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
  1254. }
  1255. .action-button {
  1256. display: flex;
  1257. flex-direction: column;
  1258. align-items: center;
  1259. width: 160rpx;
  1260. }
  1261. .action-icon {
  1262. width: 100rpx;
  1263. height: 100rpx;
  1264. border-radius: 50%;
  1265. background-color: #F0F9F0;
  1266. display: flex;
  1267. align-items: center;
  1268. justify-content: center;
  1269. color: #3BB44A;
  1270. margin-bottom: 12rpx;
  1271. transition: all 0.2s;
  1272. box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.1);
  1273. }
  1274. .action-icon:active {
  1275. background-color: #3BB44A;
  1276. transform: scale(0.92);
  1277. }
  1278. .action-icon:active svg path {
  1279. fill: #FFFFFF;
  1280. }
  1281. .action-text {
  1282. font-size: 24rpx;
  1283. color: #666666;
  1284. text-align: center;
  1285. }
  1286. /* 告警信息列表 */
  1287. .alerts-section {
  1288. margin: 0 30rpx;
  1289. background-color: #FFFFFF;
  1290. border-radius: 20rpx;
  1291. padding: 24rpx;
  1292. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
  1293. }
  1294. .alerts-list {
  1295. display: flex;
  1296. flex-direction: column;
  1297. }
  1298. .alert-item {
  1299. display: flex;
  1300. align-items: center;
  1301. padding: 24rpx 20rpx;
  1302. border-radius: 12rpx;
  1303. margin-bottom: 16rpx;
  1304. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  1305. position: relative;
  1306. }
  1307. .alert-urgent {
  1308. background-color: #FEF3F3;
  1309. border-left: 4rpx solid #F56C6C;
  1310. }
  1311. .alert-warning {
  1312. background-color: #FFF8E6;
  1313. border-left: 4rpx solid #E6A23C;
  1314. }
  1315. .alert-info {
  1316. background-color: #F2FAF5;
  1317. border-left: 4rpx solid #67C23A;
  1318. }
  1319. .alert-item-icon {
  1320. width: 50rpx;
  1321. height: 50rpx;
  1322. display: flex;
  1323. align-items: center;
  1324. justify-content: center;
  1325. margin-right: 16rpx;
  1326. }
  1327. .alert-item-info {
  1328. flex: 1;
  1329. display: flex;
  1330. flex-direction: column;
  1331. }
  1332. .alert-item-type {
  1333. font-size: 28rpx;
  1334. color: #333333;
  1335. font-weight: 500;
  1336. margin-bottom: 8rpx;
  1337. }
  1338. .alert-item-level {
  1339. font-size: 24rpx;
  1340. color: #999999;
  1341. }
  1342. .alert-item-time {
  1343. font-size: 24rpx;
  1344. color: #999999;
  1345. margin-left: 16rpx;
  1346. min-width: 100rpx;
  1347. text-align: right;
  1348. }
  1349. .empty-alert {
  1350. padding: 60rpx 0;
  1351. display: flex;
  1352. justify-content: center;
  1353. align-items: center;
  1354. }
  1355. .empty-text {
  1356. font-size: 28rpx;
  1357. color: #999999;
  1358. }
  1359. </style>