detail-camera.vue 40 KB

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