TVWall.vue 29 KB

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