monitor.vue 30 KB

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