monitor.vue 32 KB

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