detail-camera.vue 43 KB

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