monitor.vue 31 KB

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