TVWall.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922
  1. <template>
  2. <div>
  3. <el-dialog :title="title + titleSuffix" :visible.sync="TVWallVisible" v-if="TVWallVisible"
  4. customClass="TVWallCustomWidth" @close="cancelEventLocationShow()">
  5. <!--<div class="forthis" style="width: 22%; position: absolute;left: 0;z-index: 9999999999999;">-->
  6. <!--&lt;!&ndash; <div class="this-title">-->
  7. <!--<span>林场</span>-->
  8. <!--<span>45</span>-->
  9. <!--</div> &ndash;&gt;-->
  10. <!--<div class="i-list-con" style="height: 46vh; overflow-y: scroll;">-->
  11. <!--<span v-for="(item,index) in cameraList" :key="index">-->
  12. <!--<div class="d-l-con" @click="playhk(item.channelCode)">-->
  13. <!--<div class="d-l-l-text">-->
  14. <!--<i class="i-small"></i>-->
  15. <!--<h4>{{ item.cameraName }}</h4>-->
  16. <!--</div>-->
  17. <!--</div>-->
  18. <!--</span>-->
  19. <!--</div>-->
  20. <!--</div>-->
  21. <!--<div style="width:70%;height:400px;position:absolute;">-->
  22. <!--&lt;!&ndash;视频窗口展示-&#45;&#45;大华&ndash;&gt;-->
  23. <!--<div id="dom1" class="dom1"></div>-->
  24. <!--&lt;!&ndash;视频窗口展示-&#45;&#45;海康&ndash;&gt;-->
  25. <!--<div id="playWnd" class="playWnd" style="left: 0px; top: 0px;"></div>-->
  26. <!--</div>-->
  27. <div id="dom1" class="dom1"></div>
  28. </el-dialog>
  29. </div>
  30. </template>
  31. <script>
  32. /** ----------------------------------摄像头预览开始------------------------------------- */
  33. import {
  34. getDahuaVideoServer,
  35. getTVWallList
  36. } from '@/api/dahua/dahua'
  37. import {
  38. tvCameraList
  39. } from '@/api/haikang/haikang'
  40. import DHWs from '@/dahua/lib/DHWs'
  41. import {
  42. rotation
  43. } from '@/api/monitor'
  44. import Cookies from "js-cookie"
  45. import {
  46. selectConfigKey
  47. } from "@/api/system/config";
  48. /** ----------------------------------摄像头预览结束------------------------------------- */
  49. export default {
  50. dicts: ['event_source'],
  51. components: {},
  52. data() {
  53. return {
  54. title: "电视墙",
  55. titleSuffix: "\u3000\u3000\u3000\u3000\u3000您的所有操作痕迹已被后台记录,请谨慎操作。部分摄像头处于敏感区域,已屏蔽操控权限,无法操控。",
  56. titleSuffix2: "\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000您的所有操作痕迹已被后台记录,请谨慎操作。部分摄像头处于敏感区域,已屏蔽操控权限,无法操控。",
  57. tvListJson: [{
  58. 'switchTab': '1',
  59. 'treeLabels': [{
  60. 'labelCode': '123456',
  61. 'labelName': '视频场景',
  62. 'parentLabelCode': null
  63. },
  64. {
  65. 'labelCode': '5a81d1bd499b4940a21fc63ca51f4dfa',
  66. 'labelName': '标签2',
  67. 'parentLabelCode': 123456
  68. },
  69. {
  70. 'labelCode': 'd941adbbd3e64dac92cc448dec5293cd',
  71. 'labelName': '标签1',
  72. 'parentLabelCode': 123456
  73. }
  74. ],
  75. 'labelChannels': [{
  76. 'channelDates': [{
  77. 'channelCode': '6044981090191552',
  78. 'channelName': '复兴大桥中段-交通事故',
  79. 'channelSn': null,
  80. 'cameraType': 0,
  81. 'online': 1
  82. },
  83. {
  84. 'channelCode': 'ZgVzqsjwA1DTF561VGHK5E',
  85. 'channelName': '北京7青羊东二路77号2通道1',
  86. 'channelSn': null,
  87. 'cameraType': 1,
  88. 'online': 1
  89. }
  90. ],
  91. 'labelCode': 'd941adbbd3e64dac92cc448dec5293cd'
  92. },
  93. {
  94. 'channelDates': [{
  95. 'channelCode': 'ZgVzqsjwA1DTF561VGHKK7',
  96. 'channelName': '北京7青羊东二路77号2通道2',
  97. 'channelSn': null,
  98. 'cameraType': 2,
  99. 'online': 0
  100. }],
  101. 'labelCode': '5a81d1bd499b4940a21fc63ca51f4dfa'
  102. }
  103. ]
  104. },
  105. {
  106. 'switchTab': '2',
  107. 'labelChannels': [{
  108. 'channelDates': [{
  109. 'channelCode': 'ZgVzqsjwA1DTF561VGHK5E',
  110. 'channelName': '北京7青羊东二路77号2通道1',
  111. 'channelSn': null,
  112. 'cameraType': 1,
  113. 'online': 1
  114. },
  115. {
  116. 'channelCode': 'ZgVzqsjwA1DTF561VGHKK7',
  117. 'channelName': '北京7青羊东二路77号2通道2',
  118. 'channelSn': null,
  119. 'cameraType': 2,
  120. 'online': 0
  121. }
  122. ]
  123. }]
  124. }
  125. ],
  126. TVWallVisible: false,
  127. activeName: 'tv',
  128. channelId: ['ZgVzqsjwA1DTF561VHG69F'],
  129. /** ----------------------------------摄像头预览开始------------------------------------- */
  130. showModal: true,
  131. activePanel: 'key1',
  132. isLogin: false,
  133. loginType: '1',
  134. token: '',
  135. ctrlType: 'playerWin',
  136. https: 1,
  137. httpsList: [{
  138. value: 0,
  139. label: 0
  140. },
  141. {
  142. value: 1,
  143. label: 1
  144. }
  145. ],
  146. ctrlTypeList: [{
  147. value: 'playerWin',
  148. label: '播放控件'
  149. }, {
  150. value: 'realMonitorUI',
  151. label: '带设备树实时预览控件'
  152. }, {
  153. value: 'playbackUI',
  154. label: '带设备树视频回放控件'
  155. }, {
  156. value: 'TVWallUI',
  157. label: '视频上墙'
  158. }],
  159. ctrlList: [{
  160. value: 'ctrl1',
  161. label: '控件1'
  162. },
  163. {
  164. value: 'ctrl2',
  165. label: '控件2'
  166. },
  167. {
  168. value: 'ctrl3',
  169. label: '控件3'
  170. }
  171. ],
  172. splitList: [{
  173. value: 1,
  174. label: '1 * 1'
  175. },
  176. {
  177. value: 4,
  178. label: '2 * 2'
  179. },
  180. {
  181. value: 9,
  182. label: '3 * 3'
  183. }
  184. ],
  185. displayModeList: [{
  186. value: 1,
  187. label: '播放器预览模式'
  188. },
  189. {
  190. value: 2,
  191. label: '播放器回放模式'
  192. }
  193. ],
  194. mixedVideoDisplayModeList: [{
  195. value: 1,
  196. label: '播放实时视频'
  197. },
  198. {
  199. value: 2,
  200. label: '播放回放视频'
  201. }
  202. ],
  203. ctrl: 'ctrl1',
  204. splitNum: 1,
  205. displayMode: 1,
  206. displayTimeRange: [],
  207. modalDisplayTimeRange: [],
  208. mixedVideoTime: null,
  209. recordPath: 'C:\\DSS LightWeight\\DSS LightWeight Client\\Record\\',
  210. downloadName: '',
  211. downTimeRange: [],
  212. downloadFormat: 0,
  213. downloadFormatList: [{
  214. value: 0,
  215. label: 'dav'
  216. },
  217. {
  218. value: 1,
  219. label: 'avi'
  220. }, {
  221. value: 2,
  222. label: 'mp4'
  223. }
  224. ],
  225. downloadSource: 3,
  226. downloadSourceList: [{
  227. value: 3,
  228. label: '中心录像'
  229. }, {
  230. value: 2,
  231. label: '设备录像'
  232. }],
  233. showDownloadStreamType: false,
  234. downloadStreamType: 1,
  235. downloadStreamTypeList: [{
  236. value: 1,
  237. label: '主码流'
  238. },
  239. {
  240. value: 2,
  241. label: '辅码流'
  242. },
  243. {
  244. value: 3,
  245. label: '三码流'
  246. }
  247. ],
  248. downloadIsShow: true,
  249. downloadIsShowList: [{
  250. value: true,
  251. label: '是'
  252. },
  253. {
  254. value: false,
  255. label: '否'
  256. }
  257. ],
  258. crtPosX: 0,
  259. crtPosY: 0,
  260. crtWidth: 1150,
  261. crtHeight: 700,
  262. domId: 'dom1',
  263. mixedVideoDisplayMode: 2,
  264. isShowTipe: true,
  265. /** ----------------------------------摄像头预览结束------------------------------------- */
  266. cameraList: [],
  267. initCount: 0,
  268. pubKey: '',
  269. oWebControl: null
  270. }
  271. },
  272. created() {
  273. const DHWsInstance = DHWs.getInstance()
  274. this.ws = DHWsInstance
  275. },
  276. methods: {
  277. cancelEventLocationShow() {
  278. // this.activeName = 'tv'
  279. this.TVWallVisible = false
  280. this.destroy()
  281. if (this.oWebControl != null) {
  282. this.oWebControl.JS_HideWnd() // 先让窗口隐藏,规避可能的插件窗口滞后于浏览器消失问题
  283. this.oWebControl.JS_Disconnect().then(function() { // 断开与插件服务连接成功
  284. },
  285. function() { // 断开与插件服务连接失败
  286. })
  287. }
  288. },
  289. //火点联动电视墙调用
  290. showTVWall1(longitude, latitude, tvListJson) {
  291. selectConfigKey("DssVersion").then(res => {
  292. if (this.ws.getLocalDssVersion() != res.data) {
  293. this.$modal.confirm('系统检测到新客户端版本,请更新后使用', '系统提示', {
  294. confirmButtonText: '确定',
  295. cancelButtonText: '取消',
  296. type: 'warning'
  297. }).then(() => {
  298. selectConfigKey('video_plugin_url').then(response => {
  299. window.open(response.data);
  300. })
  301. }).catch(() => {
  302. return
  303. });
  304. return
  305. } else {
  306. // let that=this;
  307. /** ----------------------------------大华摄像头预览开始------------------------------------- */
  308. this.ws.addEventListener('connectStateChange', data => {
  309. if (data) {
  310. console.log('连接成功')
  311. } else {
  312. console.log('连接失败,下载客户端')
  313. this.alertReinstall()
  314. }
  315. })
  316. getDahuaVideoServer().then(newResponse => {
  317. this.ws.detectConnectQt().then(res => {
  318. if (res) { // 连接客户端成功
  319. this.alertLogin()
  320. this.ws.login({
  321. loginIp: newResponse.loginIp,
  322. loginPort: newResponse.loginPort,
  323. userName: newResponse.userName,
  324. userPwd: newResponse.userPwd,
  325. // loginIp: '192.168.100.100',
  326. // loginPort: 8314,
  327. // userName: 'system',
  328. // userPwd: 'Admin@123',
  329. token: '',
  330. https: 1
  331. })
  332. this.ws.on('loginState', (res) => {
  333. this.isLogin = res
  334. console.log('---res-----', res)
  335. if (res) {
  336. this.alertLoginSuccess()
  337. this.activePanel = 'key2'
  338. console.log(tvListJson)
  339. const array = []
  340. const array1 = []
  341. if (tvListJson != null) {
  342. tvListJson[0].treeLabels.forEach((item, index) => {
  343. if (index != 0) {
  344. const param = Object.assign({})
  345. param.channelId = item.labelCode
  346. array.push(param)
  347. array1.push(item.labelCode)
  348. }
  349. })
  350. }
  351. this.create1(longitude, latitude, tvListJson, array, array1)
  352. // var obj=JSON.parse(tvListJson)
  353. } else {
  354. this.alertLoginFailed()
  355. }
  356. })
  357. } else { // 连接客户端失败
  358. this.alertReinstall()
  359. }
  360. })
  361. })
  362. /** ----------------------------------大华摄像头预览结束------------------------------------- */
  363. /** ----------------------------------海康摄像头预览开始------------------------------------- */
  364. // tvCameraList().then(response => {
  365. // this.cameraList=response.data
  366. // })
  367. // that.initPlugin()
  368. // setTimeout(function() {
  369. // that.playhk();
  370. // }, 5000)
  371. // /** ----------------------------------海康摄像头预览结束------------------------------------- */
  372. this.TVWallVisible = true
  373. }
  374. })
  375. },
  376. realTimeVideoDialog(cameraParams) {
  377. // 调用弹窗实时播放接口
  378. if (!this.isLogin) {
  379. this.$Message.info("正在登陆客户端,请稍等......");
  380. return false;
  381. }
  382. this.ws.openVideo(cameraParams);
  383. },
  384. create1(longitude, latitude, tvListJson, array, array1) { // 调用创建控件接口
  385. let _this = this
  386. const params = [{
  387. 'ctrlType': 'realMonitorUI',
  388. 'ctrlCode': 'ctrl1',
  389. 'ctrlProperty': {
  390. 'displayMode': 1,
  391. 'splitNum': 4,
  392. 'channelList': [{
  393. 'channelId': ''
  394. }]
  395. },
  396. 'visible': true,
  397. 'domId': 'dom1'
  398. }]
  399. if (array1 != undefined && array1 != null) {
  400. params[0].ctrlProperty.splitNum = (array1.length == 1 ? 1 : 4)
  401. }
  402. this.setPos()
  403. this.customizeTree(tvListJson);
  404. // if(array1.length == 1){
  405. // _this.realTimeVideoDialog(array1);
  406. // }else{
  407. _this.ws.createCtrl(params);
  408. _this.playRealMonitorVideo(array)
  409. // }
  410. setTimeout(() => {
  411. _this.rotation(longitude, latitude, array1)
  412. }, 5000)
  413. },
  414. playRealMonitorVideo(array) { // 自定义设备树自动播放指定通道编码视频
  415. const config = this.ws.config
  416. const {
  417. loginIp,
  418. userCode
  419. } = config
  420. this.ws.postMessage('playRealMonitorVideo', {
  421. loginIp,
  422. userCode,
  423. params: {
  424. ctrlCode: "ctrl1",
  425. array: array
  426. }
  427. })
  428. },
  429. rotation(lng, lat, list) {
  430. console.log(list)
  431. rotation(lng, lat, list).then(res => {})
  432. },
  433. showTVWall(tvListJson, bfArray) {
  434. selectConfigKey("DssVersion").then(res => {
  435. if (this.ws.getLocalDssVersion() != res.data) {
  436. this.$modal.confirm('系统检测到新客户端版本,请更新后使用', '系统提示', {
  437. confirmButtonText: '确定',
  438. cancelButtonText: '取消',
  439. type: 'warning'
  440. }).then(() => {
  441. selectConfigKey('video_plugin_url').then(response => {
  442. window.open(response.data);
  443. })
  444. }).catch(() => {
  445. return
  446. });
  447. return
  448. } else {
  449. if (tvListJson) {
  450. this.preview(tvListJson, bfArray);
  451. this.TVWallVisible = true;
  452. return;
  453. }
  454. // let that=this;
  455. /** ----------------------------------大华摄像头预览开始------------------------------------- */
  456. this.ws.addEventListener('connectStateChange', data => {
  457. if (data) {
  458. console.log('连接成功')
  459. } else {
  460. console.log('连接失败,下载客户端')
  461. this.alertReinstall()
  462. }
  463. })
  464. this.preview()
  465. /** ----------------------------------大华摄像头预览结束------------------------------------- */
  466. /** ----------------------------------海康摄像头预览开始------------------------------------- */
  467. // tvCameraList().then(response => {
  468. // this.cameraList=response.data
  469. // })
  470. // that.initPlugin()
  471. // setTimeout(function() {
  472. // that.playhk();
  473. // }, 5000)
  474. // /** ----------------------------------海康摄像头预览结束------------------------------------- */
  475. this.TVWallVisible = true
  476. }
  477. })
  478. },
  479. /** ----------------------------------大华摄像头预览开始------------------------------------- */
  480. alertLogin: function() {
  481. this.$modal.msg('登录中....')
  482. },
  483. alertLoginSuccess: function() {
  484. this.$modal.msgSuccess('登录成功!')
  485. },
  486. alertLoginFailed: function() {
  487. this.$modal.msgError('登陆失败!')
  488. },
  489. alertReinstall: function() {
  490. this.$modal.msgWarning('请重新安装客户端')
  491. },
  492. /** 预览按钮操作 */
  493. preview(tvListJson, bfArray) {
  494. getTVWallList().then(newres => {
  495. getDahuaVideoServer().then(newResponse => {
  496. this.ws.detectConnectQt().then(res => {
  497. if (res) { // 连接客户端成功
  498. this.alertLogin()
  499. this.ws.login({
  500. loginIp: newResponse.loginIp,
  501. loginPort: newResponse.loginPort,
  502. userName: newResponse.userName,
  503. userPwd: newResponse.userPwd,
  504. // loginIp: '192.168.100.100',
  505. // loginPort: 8314,
  506. // userName: 'system',
  507. // userPwd: 'Admin@123',
  508. token: '',
  509. https: 1
  510. })
  511. this.ws.on('loginState', (res) => {
  512. this.isLogin = res
  513. console.log('---res-----', res)
  514. if (res) {
  515. this.alertLoginSuccess()
  516. this.activePanel = 'key2'
  517. this.create(tvListJson ? tvListJson : newres.data, bfArray)
  518. } else {
  519. this.alertLoginFailed()
  520. }
  521. })
  522. } else { // 连接客户端失败
  523. this.alertReinstall()
  524. }
  525. })
  526. })
  527. })
  528. },
  529. create(tvListJson, bfArray) { // 调用创建控件接口
  530. debugger
  531. let _this = this
  532. const params = [{
  533. 'ctrlType': 'realMonitorUI',
  534. 'ctrlCode': 'ctrl1',
  535. 'ctrlProperty': {
  536. 'displayMode': 1,
  537. /*以下为新增字段*/
  538. "splitNum": 4,
  539. /*以上为新增字段*/
  540. 'channelList': [{
  541. 'channelId': ''
  542. }]
  543. },
  544. 'visible': true,
  545. 'domId': 'dom1'
  546. }]
  547. if (bfArray != undefined && bfArray != null) {
  548. params[0].ctrlProperty.splitNum = (bfArray.length == 1 ? 1 : 4)
  549. }
  550. this.setPos()
  551. this.customizeTree(tvListJson);
  552. let length = tvListJson[0].treeLabels.length > 4 ? 5 : tvListJson[0].treeLabels.length;
  553. bfArray = [];
  554. for (let i = 1; i < length; i++) {
  555. bfArray.push({
  556. "channelId": tvListJson[0].treeLabels[i].labelCode
  557. })
  558. }
  559. // if(bfArray.length == 1){
  560. // _this.realTimeVideoDialog([tvListJson[0].treeLabels[1].labelCode]);
  561. // }else{
  562. _this.ws.createCtrl(params);
  563. console.log("playRealMonitorVideo", bfArray)
  564. console.log("params", params)
  565. _this.playRealMonitorVideo(bfArray)
  566. // }
  567. },
  568. setPos() {
  569. let target = document.getElementById(this.domId)
  570. console.log(target, 'target')
  571. target.style.right = `${this.crtPosX}px`
  572. target.style.top = `${this.crtPosY}px`
  573. target.style.width = `${this.crtWidth}px`
  574. target.style.height = `${this.crtHeight}px`
  575. if (document.createEvent) {
  576. var event = document.createEvent('HTMLEvents')
  577. event.initEvent('resize', true, true)
  578. window.dispatchEvent(event)
  579. } else if (document.createEventObject) {
  580. window.fireEvent('onresize')
  581. }
  582. },
  583. destroy() { // 调用销毁控件接口
  584. if (!this.isLogin) {
  585. this.$modal.msgWarning('正在登陆客户端,请稍等......')
  586. return false
  587. }
  588. const ctrls = this.ws.ctrls.map(i => {
  589. if (i.ctrlCode === this.ctrl) {
  590. return i.ctrlCode
  591. }
  592. })
  593. this.ws.destroyCtrl(ctrls)
  594. },
  595. customizeTree(tvListJson) { // 调用控件接口树
  596. const config = this.ws.config
  597. const {
  598. loginIp,
  599. userCode
  600. } = config
  601. this.ws.postMessage('customizeTree', {
  602. loginIp,
  603. userCode,
  604. params: {
  605. array: tvListJson
  606. }
  607. })
  608. },
  609. /** ----------------------------------大华摄像头预览结束------------------------------------- */
  610. /** ----------------------------------海康摄像头预览开始------------------------------------- */
  611. // 创建播放实例
  612. initPlugin() {
  613. let that = this
  614. that.oWebControl = new WebControl({
  615. szPluginContainer: 'playWnd', // 指定容器id
  616. iServicePortStart: 15900, // 指定起止端口号,建议使用该值
  617. iServicePortEnd: 15909,
  618. szClassId: '23BF3B0A-2C56-4D97-9C03-0CB103AA8F11', // 用于IE10使用ActiveX的clsid
  619. cbConnectSuccess: function() { // 创建WebControl实例成功
  620. that.oWebControl.JS_StartService('window', { // WebControl实例创建成功后需要启动服务
  621. dllPath: './VideoPluginConnect.dll' // 值"./VideoPluginConnect.dll"写死
  622. }).then(function() { // 启动插件服务成功
  623. that.oWebControl.JS_SetWindowControlCallback({ // 设置消息回调
  624. cbIntegrationCallBack: cbIntegrationCallBack
  625. })
  626. that.oWebControl.JS_CreateWnd('playWnd', 850, 615).then(
  627. function() { //JS_CreateWnd创建视频播放窗口,宽高可设定
  628. that.init() // 创建播放实例成功后初始化
  629. })
  630. }, function() { // 启动插件服务失败
  631. })
  632. },
  633. cbConnectError: function() { // 创建WebControl实例失败
  634. that.oWebControl = null
  635. $('#playWnd').html('插件未启动,正在尝试启动,请稍候...<a href="./hk/VideoWebPlugin.exe">点击下载插件</a>')
  636. WebControl.JS_WakeUp('VideoWebPlugin://') // 程序未启动时执行error函数,采用wakeup来启动程序
  637. initCount++
  638. if (initCount < 3) {
  639. setTimeout(function() {
  640. that.initPlugin()
  641. }, 3000)
  642. } else {
  643. $('#playWnd').html('插件启动失败,请检查插件是否安装!<a href="./hk/VideoWebPlugin.exe">点击下载插件</a>')
  644. }
  645. },
  646. cbConnectClose: function(bNormalClose) {
  647. // 异常断开:bNormalClose = false
  648. // JS_Disconnect正常断开:bNormalClose = true
  649. console.log('cbConnectClose')
  650. that.oWebControl = null
  651. }
  652. })
  653. },
  654. //初始化
  655. init() {
  656. let that = this
  657. this.getPubKey(function() {
  658. ////////////////////////////////// 请自行修改以下变量值 ////////////////////////////////////
  659. var appkey = '24699060' //综合安防管理平台提供的appkey,必填
  660. var secret = that.setEncrypt('tt1pMbsrlwGZUWucdAPw') //综合安防管理平台提供的secret,必填
  661. var ip = '36.49.108.22' //综合安防管理平台IP地址,必填
  662. var playMode = 0 //初始播放模式:0-预览,1-回放
  663. var port = 1443 //综合安防管理平台端口,若启用HTTPS协议,默认443
  664. var snapDir = 'D:\\SnapDir' //抓图存储路径
  665. var videoDir = 'D:\\VideoDir' //紧急录像或录像剪辑存储路径
  666. var layout = '3x3' //playMode指定模式的布局
  667. var enableHTTPS = 1 //是否启用HTTPS协议与综合安防管理平台交互,这里总是填1
  668. var encryptedFields = 'secret' //加密字段,默认加密领域为secret
  669. var showToolbar = 1 //是否显示工具栏,0-不显示,非0-显示
  670. var showSmart = 1 //是否显示智能信息(如配置移动侦测后画面上的线框),0-不显示,非0-显示
  671. var buttonIDs = '0,16,256,257,258,259,260,512,513,514,515,516,517,768,769' //自定义工具条按钮
  672. ////////////////////////////////// 请自行修改以上变量值 ////////////////////////////////////
  673. that.oWebControl.JS_RequestInterface({
  674. funcName: 'init',
  675. argument: JSON.stringify({
  676. appkey: appkey, //API网关提供的appkey
  677. secret: secret, //API网关提供的secret
  678. ip: ip, //API网关IP地址
  679. playMode: playMode, //播放模式(决定显示预览还是回放界面)
  680. port: port, //端口
  681. snapDir: snapDir, //抓图存储路径
  682. videoDir: videoDir, //紧急录像或录像剪辑存储路径
  683. layout: layout, //布局
  684. enableHTTPS: enableHTTPS, //是否启用HTTPS协议
  685. encryptedFields: encryptedFields, //加密字段
  686. showToolbar: showToolbar, //是否显示工具栏
  687. showSmart: showSmart, //是否显示智能信息
  688. buttonIDs: buttonIDs //自定义工具条按钮
  689. })
  690. }).then(function(oData) {
  691. that.oWebControl.JS_Resize(850, 615) // 初始化后resize一次,规避firefox下首次显示窗口后插件窗口未与DIV窗口重合问题
  692. })
  693. })
  694. },
  695. //获取公钥
  696. getPubKey(callback) {
  697. let that = this
  698. that.oWebControl.JS_RequestInterface({
  699. funcName: 'getRSAPubKey',
  700. argument: JSON.stringify({
  701. keyLength: 1024
  702. })
  703. }).then(function(oData) {
  704. console.log(oData)
  705. if (oData.responseMsg.data) {
  706. that.pubKey = oData.responseMsg.data
  707. callback()
  708. }
  709. 125
  710. })
  711. },
  712. //RSA加密
  713. setEncrypt(value) {
  714. var encrypt = new JSEncrypt()
  715. encrypt.setPublicKey(this.pubKey)
  716. return encrypt.encrypt(value)
  717. },
  718. //播放海康摄像头
  719. playhk(channelCode) {
  720. var cameraIndexCode = channelCode //获取输入的监控点编号值,必填
  721. var streamMode = 0 //主子码流标识:0-主码流,1-子码流
  722. var transMode = 1 //传输协议:0-UDP,1-TCP
  723. var gpuMode = 0 //是否启用GPU硬解,0-不启用,1-启用
  724. var wndId = -1 //播放窗口序号(在2x2以上布局下可指定播放窗口)
  725. cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, '')
  726. cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, '')
  727. this.oWebControl.JS_RequestInterface({
  728. funcName: 'startPreview',
  729. argument: JSON.stringify({
  730. cameraIndexCode: cameraIndexCode, //监控点编号
  731. streamMode: streamMode, //主子码流标识
  732. transMode: transMode, //传输协议
  733. gpuMode: gpuMode, //是否开启GPU硬解
  734. wndId: wndId //可指定播放窗口
  735. })
  736. })
  737. }
  738. /** ----------------------------------海康摄像头预览结束------------------------------------- */
  739. }
  740. }
  741. // 推送消息
  742. function cbIntegrationCallBack(oData) {
  743. console.log(JSON.stringify(oData.responseMsg))
  744. }
  745. </script>
  746. <style rel="stylesheet/scss" lang="scss" scoped>
  747. @import '@/assets/styles/base.scss';
  748. .event-info-con {
  749. width: 100%;
  750. display: flex;
  751. .e-left {
  752. width: 32%;
  753. }
  754. .e-center {
  755. width: 30%;
  756. margin-left: 1%;
  757. .img-company {
  758. width: 100%;
  759. height: 18.3vh;
  760. img {}
  761. }
  762. }
  763. .e-right {
  764. margin-left: 1%;
  765. width: 45%;
  766. }
  767. .e-location-left {
  768. width: 28%;
  769. margin-top: 1rem;
  770. }
  771. .e-location-right {
  772. width: 71%;
  773. margin-top: 1.3rem;
  774. margin-left: 1rem;
  775. }
  776. }
  777. .el-dialog:not(.is-fullscreen) {
  778. margin-top: 5.5vh !important;
  779. }
  780. .bottom-menu-normal {
  781. max-width: 90%;
  782. padding: 0 3rem;
  783. position: absolute;
  784. left: 50%;
  785. transform: translateX(-50%);
  786. bottom: 0;
  787. z-index: 100000;
  788. border-radius: 5px;
  789. display: flex;
  790. justify-content: center;
  791. align-items: center;
  792. background: url(../assets/images/integrated/btm-menu.png) center no-repeat;
  793. background-size: cover;
  794. overflow: hidden;
  795. .btm-m-con {
  796. position: relative;
  797. color: $inBlue;
  798. font-size: .5rem;
  799. padding: 1rem 1.5rem;
  800. display: flex;
  801. align-items: center;
  802. justify-content: center;
  803. -webkit-transform: translateY(0);
  804. transform: translateY(0);
  805. transition: all 0.2s ease-in-out;
  806. cursor: pointer;
  807. white-space: nowrap;
  808. i {
  809. font-size: 1rem;
  810. color: $inBlue;
  811. text-shadow: 0 0 10px rgba($color: $inBlue, $alpha: .6);
  812. margin-right: 0.2rem;
  813. }
  814. }
  815. .btm-m-con:hover {
  816. text-shadow: 0 0 20px rgba($color: $inBlueHover, $alpha: 1.0);
  817. filter: brightness(2.3);
  818. -webkit-transform: translateX(0.2rem);
  819. transform: translateX(0.2rem);
  820. transition: all 0.2s ease-in-out;
  821. i {
  822. color: $inBlueHover;
  823. text-shadow: 0 0 20px rgba($color: $inBlueHover, $alpha: 1.0);
  824. }
  825. }
  826. .m-l-none {
  827. .el-input__inner {
  828. margin-left: 0 !important;
  829. }
  830. }
  831. }
  832. /*海康*/
  833. html,
  834. body {
  835. padding: 0;
  836. margin: 0;
  837. }
  838. .playWnd {
  839. margin: -13px 0 0 255px;
  840. width: 850px;
  841. /*播放容器的宽和高设定*/
  842. height: 615px;
  843. border: 1px solid red;
  844. }
  845. .operate {
  846. margin-top: 24px;
  847. }
  848. .operate::after {
  849. content: '';
  850. display: block;
  851. clear: both;
  852. }
  853. .module {
  854. float: left;
  855. width: 340px;
  856. /*min-height: 320px;*/
  857. margin-left: 16px;
  858. padding: 16px 8px;
  859. box-sizing: border-box;
  860. border: 1px solid #e5e5e5;
  861. }
  862. .module .item {
  863. margin-bottom: 4px;
  864. }
  865. .module input[type="text"] {
  866. box-sizing: border-box;
  867. display: inline-block;
  868. vertical-align: middle;
  869. margin-left: 0;
  870. width: 150px;
  871. min-height: 20px;
  872. }
  873. .module .btn {
  874. min-width: 80px;
  875. min-height: 24px;
  876. margin-top: 100px;
  877. margin-left: 80px;
  878. }
  879. </style>