monitor.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  1. <!--监控中心-->
  2. <template>
  3. <div class="visual-con">
  4. <!--头部-->
  5. <vheader></vheader>
  6. <!--主体-->
  7. <div class="visual-body">
  8. <!-- 左侧 -->
  9. <div class="leftbar" ref="left">
  10. <div class="forthis">
  11. <dv-border-box-13 :color="['#0e7957', '#0da24c']" backgroundColor="#09140e" style="padding-bottom: 1rem;">
  12. <img src="../assets/images/integrated/light.png" style="width: 100%; margin-top: .4rem;"/>
  13. <div class="this-title">
  14. <span>事态感知</span>
  15. <dv-decoration-3 style="width:150px;height:15px;margin-right: 1rem;"/>
  16. </div>
  17. <div class="i-list-con h-73">
  18. <div class="d-l-con-icon">
  19. <div class="icon-con w-33 m-btm-no" :class="{on:iconCurrentIndex1==index}"
  20. v-for="(item,index) in visuForestCloudMapDeviceBOList"
  21. v-on:click="selectDeviceType(index)">
  22. <!-- -->
  23. <div class="icon icon-dot"></div>
  24. <div class="icon-text">
  25. <h6>{{ item.deviceCount }}</h6>
  26. <h5>{{ item.deviceName }}</h5>
  27. </div>
  28. </div>
  29. <div class="icon-con w-33 m-btm-no">
  30. <div class="icon icon-dot"></div>
  31. <div class="icon-text">
  32. <h6>0</h6>
  33. <h5>传感器</h5>
  34. </div>
  35. </div>
  36. <div class="icon-con w-33 m-btm-no">
  37. <div class="icon icon-dot"></div>
  38. <div class="icon-text">
  39. <h6>0</h6>
  40. <h5>大喇叭</h5>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="overflow-y" style="height: 33vh;">
  45. <div class="d-l-con sj-collapse" v-for="(item,index) in region" :class="{on:listCurrentIndex1==item.deptId}"
  46. v-on:click="selectCameraByDeptId(item.deptId)">
  47. <div class="d-l-l-text">
  48. <h4 class="collapse-title">{{ item.deptName }}</h4>
  49. </div>
  50. <div class="d-l-l-count">{{ item.deptCount }}</div>
  51. </div>
  52. </div>
  53. <!-- 横向柱状 echart -->
  54. <div class="overflow-y" style="height: 33vh;">
  55. <div id="camera-chart" style="width: 100%;height:33vh;"></div>
  56. </div>
  57. </div>
  58. </dv-border-box-13>
  59. </div>
  60. </div>
  61. <!-- 地图 -->
  62. <supermap ref="supermap" style="width: 100%;height: 100vh;" :mapDiv="'forestMap'" class="indexSupermapClass"
  63. :mapSite="{doubleClickZoom:false}" :codes="['9fa5']" :isSideBySide="false" @preview="preview">
  64. </supermap>
  65. <!-- 右侧 -->
  66. <div class="rightbar" ref="right">
  67. <div class="forthis">
  68. <dv-border-box-13 :color="['#0e7957', '#0da24c']" backgroundColor="#09140e" style="padding-bottom: 1rem;">
  69. <img src="../assets/images/integrated/light.png" style="width: 100%; margin-top: .4rem;"/>
  70. <div class="this-title">
  71. <span>列表</span>
  72. <dv-decoration-3 style="width:150px;height:15px;margin-right: 1rem;"/>
  73. </div>
  74. <div class="i-list-con h-43">
  75. <div class="d-l-con" v-for="(item,index) in visuForestCloudCameraBOList"
  76. :class="{on:listCurrentIndex2 == index}"
  77. v-on:click="dropLocation(item.latitude,item.longitude,index)">
  78. <div class="d-l-l-text">
  79. <i class="iconfont sj-icon-jkzx icon-sxt"></i>
  80. <h4>{{ item.cameraName }}</h4>
  81. </div>
  82. </div>
  83. </div>
  84. </dv-border-box-13>
  85. </div>
  86. <div class="forthis">
  87. <dv-border-box-13 :color="['#0e7957', '#0da24c']" backgroundColor="#09140e" style="padding-bottom: 1rem;">
  88. <img src="../assets/images/integrated/light.png" style="width: 100%; margin-top: .4rem;"/>
  89. <div class="this-title">
  90. <span>重点区域</span>
  91. <dv-decoration-3 style="width:150px;height:15px;margin-right: 1rem;"/>
  92. </div>
  93. <div class="i-list-con h-25">
  94. <div class="d-l-con" v-for="(item,index) in keyAreaList" :class="{on:listCurrentIndex3 == index}" @click="getRegionalFlag(item.id)">
  95. <div class="d-l-l-text">
  96. <i class="i-small"></i>
  97. <h4>{{ item.areaName }}</h4>
  98. </div>
  99. </div>
  100. </div>
  101. </dv-border-box-13>
  102. </div>
  103. </div>
  104. <vBottomMenu ref="bottomMenu"></vBottomMenu>
  105. </div>
  106. <eventLocation ref="eventLocation"></eventLocation>
  107. <TVWall ref="TVWall"></TVWall>
  108. <el-dialog :title="cameraTitle" :visible.sync="cameraVisible" v-if="cameraVisible" customClass="videoCustomWidth"
  109. @close="cancelEventLocationShow()">
  110. <div style="width:1020px;height:625px;position:relative;">
  111. <!--视频窗口展示---海康-->
  112. <div id="playWnd" class="playWnd" style="left: 0px; top: 0px;"></div>
  113. </div>
  114. </el-dialog>
  115. </div>
  116. </template>
  117. <script>
  118. import {
  119. selectDeviceType,
  120. selectCameraByDeptId,
  121. selectKeyAreaList,
  122. getRegionalFlag
  123. } from '@/api/monitor'
  124. import supermap from '@/components/supermap' //超图
  125. import vheader from '@/components/v-header.vue' //一体化共用头部
  126. import vBottomMenu from '@/components/vBottomMenu.vue' //一体化公共底部菜单
  127. import eventLocation from '@/components/eventLocation.vue' //事件定位弹窗
  128. import TVWall from '@/components/TVWall.vue' //电视墙弹窗
  129. /** ----------------------------------摄像头预览开始------------------------------------- */
  130. import {
  131. getDahuaVideoServer
  132. } from '@/api/dahua/dahua'
  133. import {
  134. getHaiKangVideoServer
  135. } from '@/api/haikang/haikang'
  136. // import DHWs from '@/dahua/lib/DHWs'
  137. /** ----------------------------------摄像头预览结束------------------------------------- */
  138. // import echarts from 'echarts'
  139. let echarts = require('echarts')
  140. export default {
  141. components: {
  142. supermap,
  143. vheader,
  144. vBottomMenu,
  145. eventLocation,
  146. TVWall
  147. },
  148. created() {
  149. /** ----------------------------------摄像头预览开始------------------------------------- */
  150. // const DHWsInstance = DHWs.getInstance()
  151. // this.ws = DHWsInstance
  152. /** ----------------------------------摄像头预览结束------------------------------------- */
  153. /** ----------------------------------底部按钮公用组件开始------------------------------------- */
  154. window.showDialog = this.showDialog
  155. window.choseLayerSwitching = this.choseLayerSwitching
  156. window.choseLayerSwitchingList = this.choseLayerSwitchingList
  157. /** ----------------------------------底部按钮公用组件结束------------------------------------- */
  158. },
  159. mounted() {
  160. this.selectDeviceType(-1)
  161. this.selectKeyAreaList()
  162. },
  163. data() {
  164. return {
  165. iconCurrentIndex1: '-1',
  166. listCurrentIndex1: '-1',
  167. listCurrentIndex2: '-1',
  168. listCurrentIndex3: '-1',
  169. /** ----------------------------------摄像头预览开始------------------------------------- */
  170. //大华
  171. activePanel: 'key1',
  172. isLogin: false,
  173. cameraParams: [],
  174. ws: null,
  175. //海康
  176. cameraTitle: '',
  177. cameraVisible: false,
  178. initCount: 0,
  179. pubKey: '',
  180. oWebControl: null,
  181. /** ----------------------------------摄像头预览结束------------------------------------- */
  182. visuForestCloudMapDeviceBOList: [],
  183. visuForestCloudCameraBOList: [],
  184. cameraMarkersList: [],
  185. sourceData: [],
  186. keyAreaList: [],//重点区域
  187. iframeBoo: true,
  188. open: false,
  189. iframeVue: null,
  190. activeName: 'info',
  191. radio: '1',
  192. region: [],
  193. }
  194. },
  195. methods: {
  196. selectKeyAreaList() {
  197. this.keyAreaList=[]
  198. //获取重点区域列表
  199. let that = this
  200. selectKeyAreaList().then(res => {
  201. that.keyAreaList = res.data
  202. })
  203. },
  204. getRegionalFlag(id){
  205. //获取重点区域
  206. this.listCurrentIndex3=id
  207. let that = this
  208. getRegionalFlag(id).then(res => {
  209. that.graphicsList=[]
  210. //地图标记
  211. if (res.data != null && res.data.length > 0) {
  212. for (let i = 0; i < res.data.length; i++) {
  213. let latlng = {
  214. lat: res.data[i].lat,
  215. lng: res.data[i].lng
  216. }
  217. that.graphicsList.push(latlng)
  218. }
  219. setTimeout(() => {
  220. that.$refs.supermap.clearG()
  221. that.$refs.supermap.setGraphicsList(this.graphicsList, 'red')
  222. }, 1000)
  223. } else {
  224. that.$refs.supermap.clearG()
  225. }
  226. })
  227. },
  228. /** ----------------------------------底部按钮公用组件开始------------------------------------- */
  229. showDialog(click) {
  230. if (click == 'eventLocation') {
  231. this.$refs.eventLocation.showEventLocation()
  232. this.$refs.supermap.isEditableLayers = false
  233. this.$refs.bottomMenu.showChild = false
  234. this.$refs.bottomMenu.showBanChild = false
  235. this.$refs.bottomMenu.showChangChild = false
  236. } else if (click == 'editableLayers') {
  237. this.$refs.bottomMenu.showChild = false
  238. this.$refs.bottomMenu.showBanChild = false
  239. this.$refs.bottomMenu.showChangChild = false
  240. if (!this.$refs.supermap.isEditableLayers) {
  241. this.$refs.supermap.isEditableLayers = true
  242. } else {
  243. this.$refs.supermap.isEditableLayers = false
  244. }
  245. } else if (click == 'layerSwitching') {
  246. this.$refs.supermap.isEditableLayers = false
  247. this.$refs.bottomMenu.showBanChild = false
  248. this.$refs.bottomMenu.showChangChild = false
  249. if (!this.$refs.bottomMenu.showChild) {
  250. this.$refs.bottomMenu.showChild = true
  251. } else {
  252. this.$refs.bottomMenu.showChild = false
  253. }
  254. } else if (click == 'TVWall') {
  255. this.$refs.TVWall.showTVWall()
  256. this.$refs.supermap.isEditableLayers = false
  257. this.$refs.bottomMenu.showChild = false
  258. this.$refs.bottomMenu.showBanChild = false
  259. this.$refs.bottomMenu.showChangChild = false
  260. } else if (click == 'forestban') {
  261. this.$refs.supermap.isEditableLayers = false
  262. this.$refs.bottomMenu.showChild = false
  263. this.$refs.bottomMenu.showChangChild = false
  264. if (!this.$refs.bottomMenu.showBanChild) {
  265. this.$refs.bottomMenu.showBanChild = true
  266. } else {
  267. this.$refs.bottomMenu.showBanChild = false
  268. }
  269. } else if (click == 'forestchang') {
  270. this.$refs.supermap.isEditableLayers = false
  271. this.$refs.bottomMenu.showBanChild = false
  272. this.$refs.bottomMenu.showChild = false
  273. if (!this.$refs.bottomMenu.showChangChild) {
  274. this.$refs.bottomMenu.showChangChild = true
  275. } else {
  276. this.$refs.bottomMenu.showChangChild = false
  277. }
  278. }
  279. },
  280. //选择图层
  281. choseLayerSwitching(url, isClear) {
  282. this.$refs.supermap.layerSwitching(url, isClear)
  283. },
  284. //选择图层(传递数组)
  285. choseLayerSwitchingList(urlList) {
  286. this.$refs.supermap.layerSwitchingList(urlList)
  287. },
  288. /** ----------------------------------底部按钮公用组件结束------------------------------------- */
  289. cameraChat() {
  290. // 基于准备好的dom,初始化echarts实例
  291. let myChart = echarts.init(document.getElementById('camera-chart'))
  292. // 绘制图表
  293. const dfColor = ['#92E1FF', '#0097FB', '#30ECA6', '#FFC227', '#FF4848']
  294. myChart.setOption({
  295. dataset: {
  296. source: this.sourceData
  297. },
  298. tooltip: {
  299. trigger: 'item'
  300. },
  301. grid: {
  302. top: '5%',
  303. left: '5%',
  304. // right: "4%",
  305. bottom: '0%',
  306. width: '75%',
  307. containLabel: true
  308. },
  309. dataZoom: [{
  310. show:true,
  311. type: 'slider',
  312. yAxisIndex:0,
  313. left:10,
  314. start: 0,
  315. end: this.sourceData.length > 10 ? 40 : 100,
  316. width:15
  317. }],
  318. xAxis: {
  319. show: false,
  320. type: 'value'
  321. },
  322. yAxis: {
  323. type: 'category', // 不设置类目轴,抽离的dataset数据展示不出来
  324. inverse: true,
  325. axisLabel: {
  326. show: true,
  327. textStyle: {
  328. color: '#5deaff',
  329. fontSize: '12'
  330. }
  331. },
  332. splitLine: {
  333. show: false
  334. },
  335. axisTick: {
  336. show: false
  337. },
  338. axisLine: {
  339. show: false
  340. }
  341. },
  342. series: [{
  343. type: 'bar',
  344. animationCurve: 'easeOutBack',
  345. barWidth: 5,
  346. label: {
  347. show: true,
  348. position: 'right',
  349. offset: [0, 0],
  350. color: '#88dfd5',
  351. // fontSize: "12",
  352. style: {
  353. fill: '#fff'
  354. }
  355. },
  356. backgroundBar: {
  357. show: true,
  358. style: {
  359. fill: 'rgba(97,152,255,0.20)'
  360. }
  361. },
  362. barStyle: {
  363. stroke: 'rgba(41,244,236,1)'
  364. },
  365. gradient: {
  366. color: ['rgba(41,244,236,1)', 'rgba(41,244,236,0)']
  367. },
  368. itemStyle: {
  369. label: {
  370. show: true
  371. },
  372. labelLine: {
  373. show: false
  374. },
  375. color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
  376. offset: 0,
  377. color: 'rgba(41,244,236,0)'
  378. },
  379. {
  380. offset: 1,
  381. color: 'rgba(41,244,236,.5)'
  382. }
  383. ]),
  384. borderColor: '#a2f9f7',
  385. shadowBlur: 16,
  386. shadowColor: '#a2f9f7'
  387. }
  388. }]
  389. })
  390. },
  391. selectDeviceType(index) {
  392. this.iconCurrentIndex1 = index
  393. //获取左侧动态感知设备
  394. let that = this
  395. selectDeviceType().then(res => {
  396. that.cameraMarkersList=[]
  397. that.visuForestCloudMapDeviceBOList = res.data.visuForestCloudMapDeviceBOList
  398. that.region = res.data.visuForestCloudTodaySjfbBOList
  399. if (res.data.visuForestCloudTodaySjfbBOList != null && res.data.visuForestCloudTodaySjfbBOList
  400. .length > 0) {
  401. for (let i = 0; i < res.data.visuForestCloudTodaySjfbBOList.length; i++) {
  402. let aa = []
  403. aa.push(res.data.visuForestCloudTodaySjfbBOList[i].deptName)
  404. aa.push(Number(res.data.visuForestCloudTodaySjfbBOList[i].deptCount))
  405. this.sourceData.push(aa)
  406. }
  407. }
  408. that.visuForestCloudCameraBOList = res.data.visuForestCloudCameraBOList
  409. this.cameraChat()
  410. if (res.data.visuForestCloudCameraBOList != null && res.data.visuForestCloudCameraBOList
  411. .length > 0) {
  412. for (let i = 0; i < res.data.visuForestCloudCameraBOList.length; i++) {
  413. let markersMap = {
  414. lng: 124.59,
  415. lat: 43.02,
  416. icon: 'camera',
  417. bindPopupHtml: '',
  418. click: 'preview',
  419. parameter: '',
  420. keepBindPopup: false,
  421. isAggregation: false
  422. }
  423. if (res.data.visuForestCloudCameraBOList[i].channelCode != null) {
  424. markersMap.parameter = res.data.visuForestCloudCameraBOList[i].cameraCode
  425. } else {
  426. markersMap.parameter = []
  427. }
  428. markersMap.lng = res.data.visuForestCloudCameraBOList[i].longitude
  429. markersMap.lat = res.data.visuForestCloudCameraBOList[i].latitude
  430. markersMap.radius = res.data.visuForestCloudCameraBOList[i].cameraRadius
  431. markersMap.bindPopupHtml = '<div class="map-tip">' +
  432. '<span>' +
  433. ' <div class="d-l-con">' +
  434. ' <div class="d-l-l-text">' +
  435. ' <h4>经纬度:' + res.data.visuForestCloudCameraBOList[i].longitude +
  436. ',' + res.data.visuForestCloudCameraBOList[i].latitude + '</h4>' +
  437. ' </div>' +
  438. ' </div>' +
  439. ' </span>' +
  440. '<span>' +
  441. ' <div class="d-l-con">' +
  442. ' <div class="d-l-l-text">' +
  443. ' <h4>摄像头名称:' + res.data.visuForestCloudCameraBOList[i]
  444. .cameraName + '</h4>' +
  445. ' </div>' +
  446. ' </div>' +
  447. ' </span>' +
  448. '<span>' +
  449. ' <div class="d-l-con">' +
  450. ' <div class="d-l-l-text">' +
  451. ' <h4>摄像头类型:' + res.data.visuForestCloudCameraBOList[i]
  452. .cameraFactory + '</h4>' +
  453. ' </div>' +
  454. ' </div>' +
  455. ' </span>' +
  456. '<span>' +
  457. ' <div class="d-l-con">' +
  458. ' <div class="d-l-l-text">' +
  459. ' <h4>摄像头半径:' + res.data.visuForestCloudCameraBOList[i]
  460. .cameraRadius + '米</h4>' +
  461. ' </div>' +
  462. ' </div>' +
  463. ' </span>' +
  464. '</div>'
  465. that.cameraMarkersList.push(markersMap)
  466. // cameraAccount: "1"
  467. // cameraCode: "1000010"
  468. // cameraFactory: "2"
  469. // cameraIp: "1"
  470. // cameraName: "2"
  471. // cameraPasword: "2"
  472. // cameraPort: 2
  473. // cameraRadius: 20
  474. // cameraRegion: "3"
  475. // dataDeptId: null
  476. // dataStatus: null
  477. // eventType: null
  478. // height: "11"
  479. // id: "0d165fc362514f79b12a899ea66295fd"
  480. // latitude: "49.325625"
  481. // longitude: "125.3333"
  482. }
  483. setTimeout(() => {
  484. that.$refs.supermap.clearM(true)
  485. that.$refs.supermap.clearM(false)
  486. that.$refs.supermap.setMarkersRadius(that.cameraMarkersList)
  487. }, 1000)
  488. }
  489. })
  490. },
  491. dropLocation(lat, lng, index) {
  492. this.listCurrentIndex2 = index
  493. this.$refs.supermap.dropLocation(lat, lng)
  494. },
  495. selectCameraByDeptId(depId) {
  496. this.listCurrentIndex1 = depId
  497. let that = this
  498. that.cameraMarkersList = []
  499. that.visuForestCloudCameraBOList = []
  500. selectCameraByDeptId(depId).then(res => {
  501. //根据设备类型查看列表
  502. that.visuForestCloudCameraBOList = res.data
  503. if (res.data != null && res.data.length > 0) {
  504. for (let i = 0; i < res.data.length; i++) {
  505. let markersMap = {
  506. lng: 124.59,
  507. lat: 43.02,
  508. icon: 'camera',
  509. bindPopupHtml: '',
  510. click: 'preview',
  511. parameter: '',
  512. keepBindPopup: false,
  513. isAggregation: false
  514. }
  515. if (res.data.length > 50) {
  516. markersMap.isAggregation = true
  517. }
  518. if (res.data[i].channelCode != null) {
  519. markersMap.parameter = res.data[i].cameraCode
  520. } else {
  521. markersMap.parameter = []
  522. }
  523. markersMap.lng = res.data[i].longitude
  524. markersMap.lat = res.data[i].latitude
  525. markersMap.radius = res.data[i].cameraRadius
  526. markersMap.bindPopupHtml = '<div class="map-tip">' +
  527. '<span>' +
  528. ' <div class="d-l-con">' +
  529. ' <div class="d-l-l-text">' +
  530. ' <h4>经纬度:' + res.data[i].longitude + ',' + res.data[i].latitude +
  531. '</h4>' +
  532. ' </div>' +
  533. ' </div>' +
  534. ' </span>' +
  535. '<span>' +
  536. ' <div class="d-l-con">' +
  537. ' <div class="d-l-l-text">' +
  538. ' <h4>摄像头名称:' + res.data[i].cameraName + '</h4>' +
  539. ' </div>' +
  540. ' </div>' +
  541. ' </span>' +
  542. '<span>' +
  543. ' <div class="d-l-con">' +
  544. ' <div class="d-l-l-text">' +
  545. ' <h4>摄像头类型:' + res.data[i]
  546. .cameraFactory + '</h4>' +
  547. ' </div>' +
  548. ' </div>' +
  549. ' </span>' +
  550. '<span>' +
  551. ' <div class="d-l-con">' +
  552. ' <div class="d-l-l-text">' +
  553. ' <h4>摄像头半径:' + res.data[i]
  554. .cameraRadius + '米</h4>' +
  555. ' </div>' +
  556. ' </div>' +
  557. ' </span>' +
  558. '</div>'
  559. that.cameraMarkersList.push(markersMap)
  560. // cameraAccount: "1"
  561. // cameraCode: "1000010"
  562. // cameraFactory: "2"
  563. // cameraIp: "1"
  564. // cameraName: "2"
  565. // cameraPasword: "2"
  566. // cameraPort: 2
  567. // cameraRadius: 20
  568. // cameraRegion: "3"
  569. // dataDeptId: null
  570. // dataStatus: null
  571. // eventType: null
  572. // height: "11"
  573. // id: "0d165fc362514f79b12a899ea66295fd"
  574. // latitude: "49.325625"
  575. // longitude: "125.3333"
  576. }
  577. setTimeout(() => {
  578. that.$refs.supermap.clearM(true)
  579. that.$refs.supermap.clearM(false)
  580. that.$refs.supermap.setMarkersRadius(that.cameraMarkersList)
  581. }, 1000)
  582. }
  583. })
  584. },
  585. /** ----------------------------------摄像头预览开始------------------------------------- */
  586. alertLogin: function() {
  587. this.$modal.msg('登录中....')
  588. },
  589. alertLoginSuccess: function() {
  590. this.$modal.msgSuccess('登录成功!')
  591. },
  592. alertLoginFailed: function() {
  593. this.$modal.msgError('登陆失败!')
  594. },
  595. alertReinstall: function() {
  596. this.$modal.msgWarning('请重新安装客户端')
  597. },
  598. cancelEventLocationShow() {
  599. if (this.oWebControl != null) {
  600. this.oWebControl.JS_HideWnd() // 先让窗口隐藏,规避可能的插件窗口滞后于浏览器消失问题
  601. this.oWebControl.JS_Disconnect().then(function() { // 断开与插件服务连接成功
  602. },
  603. function() { // 断开与插件服务连接失败
  604. })
  605. }
  606. },
  607. /** 预览按钮操作 */
  608. preview(cameraCode) {
  609. let that = this
  610. // getDahuaVideoServer().then(newResponse => {
  611. // console.log(newResponse)
  612. // this.ws.detectConnectQt().then(res => {
  613. // if (res) { // 连接客户端成功
  614. // this.alertLogin()
  615. // this.ws.login({
  616. // loginIp: newResponse.loginIp,
  617. // loginPort: newResponse.loginPort,
  618. // userName: newResponse.userName,
  619. // userPwd: newResponse.userPwd,
  620. // token: '',
  621. // https: 1
  622. // })
  623. // this.ws.on('loginState', (res) => {
  624. // this.isLogin = res
  625. // console.log('---res-----', res)
  626. // if (res) {
  627. // this.alertLoginSuccess()
  628. // this.activePanel = 'key2'
  629. // this.realTimeVideoDialog(channelCode)
  630. // } else {
  631. // this.alertLoginFailed()
  632. // }
  633. // })
  634. // } else { // 连接客户端失败
  635. // this.alertReinstall()
  636. // }
  637. // })
  638. // })
  639. that.cameraVisible = true
  640. getHaiKangVideoServer({cameraCode:cameraCode}).then(newResponse => {
  641. that.cameraTitle = '摄像头-'+newResponse.data.cameraName
  642. that.initPlugin(newResponse.data.appkey,newResponse.data.loginIp,newResponse.data.secret,newResponse.data.loginPort)
  643. setTimeout(function() {
  644. that.playhk(newResponse.data.channelCode)
  645. }, 5000)
  646. })
  647. },
  648. realTimeVideoDialog(cameraParams) { // 调用弹窗实时播放接口
  649. if (!this.isLogin) {
  650. this.$Message.info('正在登陆客户端,请稍等......')
  651. return false
  652. }
  653. this.ws.openVideo(cameraParams)
  654. },
  655. /** ----------------------------------摄像头预览结束------------------------------------- */
  656. /** ----------------------------------海康摄像头预览开始------------------------------------- */
  657. // 创建播放实例
  658. initPlugin(newappkey,newloginIp,newsecret,newloginPort) {
  659. let that=this
  660. that.oWebControl = new WebControl({
  661. szPluginContainer: 'playWnd', // 指定容器id
  662. iServicePortStart: 15900, // 指定起止端口号,建议使用该值
  663. iServicePortEnd: 15909,
  664. szClassId: '23BF3B0A-2C56-4D97-9C03-0CB103AA8F11', // 用于IE10使用ActiveX的clsid
  665. cbConnectSuccess: function() { // 创建WebControl实例成功
  666. that.oWebControl.JS_StartService('window', { // WebControl实例创建成功后需要启动服务
  667. dllPath: './VideoPluginConnect.dll' // 值"./VideoPluginConnect.dll"写死
  668. }).then(function() { // 启动插件服务成功
  669. that.oWebControl.JS_SetWindowControlCallback({ // 设置消息回调
  670. cbIntegrationCallBack: cbIntegrationCallBack
  671. })
  672. that.oWebControl.JS_CreateWnd('playWnd', 1020, 600).then(function() { //JS_CreateWnd创建视频播放窗口,宽高可设定
  673. that.init(newappkey,newloginIp,newsecret,newloginPort) // 创建播放实例成功后初始化
  674. })
  675. }, function() { // 启动插件服务失败
  676. })
  677. },
  678. cbConnectError: function() { // 创建WebControl实例失败
  679. that.oWebControl = null
  680. $('#playWnd').html('插件未启动,正在尝试启动,请稍候...<a href="./hk/VideoWebPlugin.exe">点击下载插件</a>')
  681. WebControl.JS_WakeUp('VideoWebPlugin://') // 程序未启动时执行error函数,采用wakeup来启动程序
  682. initCount++
  683. if (initCount < 3) {
  684. setTimeout(function() {
  685. that.initPlugin(newappkey,newloginIp,newsecret,newloginPort)
  686. }, 3000)
  687. } else {
  688. $('#playWnd').html('插件启动失败,请检查插件是否安装!<a href="./hk/VideoWebPlugin.exe">点击下载插件</a>')
  689. }
  690. },
  691. cbConnectClose: function(bNormalClose) {
  692. // 异常断开:bNormalClose = false
  693. // JS_Disconnect正常断开:bNormalClose = true
  694. console.log('cbConnectClose')
  695. that.oWebControl = null
  696. }
  697. })
  698. },
  699. //播放海康摄像头
  700. playhk(channelCode) {
  701. var cameraIndexCode = channelCode //获取输入的监控点编号值,必填
  702. var streamMode = 0 //主子码流标识:0-主码流,1-子码流
  703. var transMode = 1 //传输协议:0-UDP,1-TCP
  704. var gpuMode = 0 //是否启用GPU硬解,0-不启用,1-启用
  705. var wndId = -1 //播放窗口序号(在2x2以上布局下可指定播放窗口)
  706. cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, '')
  707. cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, '')
  708. this.oWebControl.JS_RequestInterface({
  709. funcName: 'startPreview',
  710. argument: JSON.stringify({
  711. cameraIndexCode: cameraIndexCode, //监控点编号
  712. streamMode: streamMode, //主子码流标识
  713. transMode: transMode, //传输协议
  714. gpuMode: gpuMode, //是否开启GPU硬解
  715. wndId: wndId //可指定播放窗口
  716. })
  717. })
  718. },
  719. //初始化
  720. init(newappkey,newloginIp,newsecret,newloginPort) {
  721. let that = this
  722. that.getPubKey(function() {
  723. ////////////////////////////////// 请自行修改以下变量值 ////////////////////////////////////
  724. var appkey = newappkey //综合安防管理平台提供的appkey,必填
  725. var secret = that.setEncrypt(newsecret) //综合安防管理平台提供的secret,必填
  726. var ip = newloginIp //综合安防管理平台IP地址,必填
  727. var playMode = 0 //初始播放模式:0-预览,1-回放
  728. var port = Number(newloginPort) //综合安防管理平台端口,若启用HTTPS协议,默认443
  729. var snapDir = 'D:\\SnapDir' //抓图存储路径
  730. var videoDir = 'D:\\VideoDir' //紧急录像或录像剪辑存储路径
  731. var layout = '1x1' //playMode指定模式的布局
  732. var enableHTTPS = 1 //是否启用HTTPS协议与综合安防管理平台交互,这里总是填1
  733. var encryptedFields = 'secret' //加密字段,默认加密领域为secret
  734. var showToolbar = 1 //是否显示工具栏,0-不显示,非0-显示
  735. var showSmart = 1 //是否显示智能信息(如配置移动侦测后画面上的线框),0-不显示,非0-显示
  736. var buttonIDs = '0,16,256,257,258,259,260,512,513,514,515,516,517,768,769' //自定义工具条按钮
  737. ////////////////////////////////// 请自行修改以上变量值 ////////////////////////////////////
  738. that.oWebControl.JS_RequestInterface({
  739. funcName: 'init',
  740. argument: JSON.stringify({
  741. appkey: appkey, //API网关提供的appkey
  742. secret: secret, //API网关提供的secret
  743. ip: ip, //API网关IP地址
  744. playMode: playMode, //播放模式(决定显示预览还是回放界面)
  745. port: port, //端口
  746. snapDir: snapDir, //抓图存储路径
  747. videoDir: videoDir, //紧急录像或录像剪辑存储路径
  748. layout: layout, //布局
  749. enableHTTPS: enableHTTPS, //是否启用HTTPS协议
  750. encryptedFields: encryptedFields, //加密字段
  751. showToolbar: showToolbar, //是否显示工具栏
  752. showSmart: showSmart, //是否显示智能信息
  753. buttonIDs: buttonIDs //自定义工具条按钮
  754. })
  755. }).then(function(oData) {
  756. that.oWebControl.JS_Resize(1020, 600) // 初始化后resize一次,规避firefox下首次显示窗口后插件窗口未与DIV窗口重合问题
  757. })
  758. })
  759. },
  760. //获取公钥
  761. getPubKey(callback) {
  762. let that = this
  763. that.oWebControl.JS_RequestInterface({
  764. funcName: 'getRSAPubKey',
  765. argument: JSON.stringify({
  766. keyLength: 1024
  767. })
  768. }).then(function(oData) {
  769. console.log(oData)
  770. if (oData.responseMsg.data) {
  771. that.pubKey = oData.responseMsg.data
  772. callback()
  773. }
  774. })
  775. },
  776. //RSA加密
  777. setEncrypt(value) {
  778. var encrypt = new JSEncrypt()
  779. encrypt.setPublicKey(this.pubKey)
  780. return encrypt.encrypt(value)
  781. },
  782. /** ----------------------------------海康摄像头预览结束------------------------------------- */
  783. }
  784. }
  785. // 推送消息
  786. function cbIntegrationCallBack(oData) {
  787. console.log(JSON.stringify(oData.responseMsg))
  788. }
  789. </script>
  790. <style rel="stylesheet/scss" lang="scss" scoped>
  791. @import '@/assets/styles/base.scss';
  792. .playWnd {
  793. margin: 4px 0 0 8px;
  794. width: 1020px; /*播放容器的宽和高设定*/
  795. height: 600px;
  796. border: 1px solid red;
  797. }
  798. </style>