resources.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. <!-- 交通资源 -->
  2. <template>
  3. <div class="visual-con">
  4. <!--头部-->
  5. <vheader></vheader>
  6. <!--主体-->
  7. <div class="visual-body">
  8. <!-- 左侧 -->
  9. <div class="leftbar w-10" ref="left">
  10. <div class="forthis">
  11. <dv-border-box-13 backgroundColor="#09140e" style="padding-bottom: 1rem;">
  12. <img src="../assets/images/integrated/light.png" style="width: 100%; margin-top: .4rem;"/>
  13. <div class="i-list-con h-78">
  14. <div class="i-list-con h-65" v-show="showSearch == true">
  15. <div class="head-container">
  16. <el-input
  17. v-model="searchName"
  18. placeholder="请输入名称"
  19. @blur="searchByName()"
  20. clearable
  21. size="small"
  22. prefix-icon="el-icon-search"
  23. style="margin-bottom: 20px"
  24. />
  25. </div>
  26. </div>
  27. <div class="d-l-con-icon">
  28. <div class="icon-con" :class="{on:iconCurrentIndex==item.resourceTable}"
  29. v-for="(item,index) in resourcesCountList"
  30. v-on:click="selectResourcesByLabel(item.type, searchName)">
  31. <!--v-on:click="selectResourcesByLabel(item.label)">-->
  32. <!--v-on:click="indentleftSetMarkers(item.resourceTable)">-->
  33. <div class="iconfont icon icon-normal" :class="item.icon"></div>
  34. <div class="icon-text">
  35. <h6>{{ item.num }}</h6>
  36. <!--<h6>{{ item.count }}</h6>-->
  37. <h5>{{ item.name }}</h5>
  38. <!--<h5>{{ item.resourceName }}</h5>-->
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </dv-border-box-13>
  44. </div>
  45. </div>
  46. <!--<div class="leftbar" ref="left">-->
  47. <!--<div class="forthis">-->
  48. <!--<dv-border-box-13 backgroundColor="rgba(12, 19, 38, .90)" style="padding-bottom: 1rem;">-->
  49. <!--<img src="../assets/images/integrated/light.png" style="width: 100%; margin-top: .4rem;"/>-->
  50. <!--<div class="i-list-con h-80" style="padding-left: 1rem;">-->
  51. <!--<el-collapse accordion>-->
  52. <!--<el-collapse-item v-for="(item,index) in resourcesCountList" :key="index">-->
  53. <!--<template slot="title">-->
  54. <!--<div class="d-l-con sj-collapse" v-on:click="selectResourcesByLabel(item.label)">-->
  55. <!--<div class="d-l-l-text">-->
  56. <!--<h4 class="collapse-title">{{ item.name }}</h4>-->
  57. <!--</div>-->
  58. <!--<div class="d-l-l-count">{{item.value}}</div>-->
  59. <!--</div>-->
  60. <!--</template>-->
  61. <!--</el-collapse-item>-->
  62. <!--</el-collapse>-->
  63. <!--<div class="i-list-con small-bottom-margin h-30">-->
  64. <!--</div>-->
  65. <!--</div>-->
  66. <!--</dv-border-box-13>-->
  67. <!--</div>-->
  68. <!--</div>-->
  69. <!-- 地图 -->
  70. <!-- @preview="preview"-->
  71. <supermap ref="supermap" style="width: 100%;height: 100vh;" @showResourcesDialog="showResourcesDialog">
  72. </supermap>
  73. <vBottomMenu ref="bottomMenu"></vBottomMenu>
  74. </div>
  75. <resourcesdialog ref="resourcesdialog"></resourcesdialog>
  76. <eventLocation ref="eventLocation"></eventLocation>
  77. <TVWall ref="TVWall"></TVWall>
  78. <el-dialog :title="cameraTitle" :visible.sync="cameraVisible" v-if="cameraVisible" customClass="videoCustomWidth"
  79. @close="cancelEventLocationShow()">
  80. <div style="width:1020px;height:625px;position:relative;">
  81. <!--视频窗口展示---海康-->
  82. <div id="playWnd" class="playWnd" style="left: 0px; top: 0px;"></div>
  83. </div>
  84. </el-dialog>
  85. </div>
  86. </template>
  87. <script>
  88. import {
  89. getResourcesCount,
  90. selectResources,
  91. selectResourcesByLabel
  92. } from '@/api/resources'
  93. import supermap from '@/components/supermap-2.5d' //超图
  94. import vheader from '@/components/v-header.vue' //一体化共用头部
  95. import vBottomMenu from '@/components/vBottomMenu.vue' //一体化公共底部菜单
  96. import eventLocation from '@/components/eventLocation.vue' //事件定位弹窗
  97. import TVWall from '@/components/TVWall.vue' //电视墙弹窗
  98. import resourcesdialog from '@/views/resourcesdialog.vue' //事件详情弹窗
  99. /** ----------------------------------摄像头预览开始------------------------------------- */
  100. import {
  101. getHaiKangVideoServer
  102. } from '@/api/haikang/haikang'
  103. /** ----------------------------------摄像头预览结束------------------------------------- */
  104. export default {
  105. components: {
  106. resourcesdialog,
  107. supermap,
  108. vheader,
  109. vBottomMenu,
  110. eventLocation,
  111. TVWall
  112. },
  113. created() {
  114. /** ----------------------------------底部按钮公用组件开始------------------------------------- */
  115. window.showDialog = this.showDialog
  116. window.choseLayerSwitching = this.choseLayerSwitching
  117. window.choseLayerSwitchingList = this.choseLayerSwitchingList
  118. /** ----------------------------------底部按钮公用组件结束------------------------------------- */
  119. },
  120. mounted() {
  121. this.getResourcesCount();
  122. this.selectResources();
  123. this.bottomMenuList() //获取底部公共组件消息和任务
  124. },
  125. data() {
  126. return {
  127. // 搜索框
  128. showSearch: false,
  129. // 搜索名称
  130. searchName: undefined,
  131. // 搜索类型
  132. searchType: undefined,
  133. iconCurrentIndex: '',
  134. /** ----------------------------------摄像头预览开始------------------------------------- */
  135. //海康
  136. cameraTitle: '',
  137. cameraVisible: false,
  138. initCount: 0,
  139. pubKey: '',
  140. oWebControl: null,
  141. /** ----------------------------------摄像头预览结束------------------------------------- */
  142. /** ----------------------------------资源展示用字段------------------------------------- */
  143. labelList: ['warning_sign','bridge','culvert'], //资源类型数组,用于资源判断 和资源初始化传参
  144. markersList: [], //点位列表
  145. resourcesCountList: [],
  146. resourcesList: []
  147. }
  148. },
  149. methods: {
  150. // 根据名称筛选资源点位
  151. searchByName() {
  152. this.$modal.msgSuccess("正在查询,请稍后...");
  153. this.selectResourcesByLabel(this.searchType, this.searchName);
  154. },
  155. //查询各类资源的数量
  156. getResourcesCount(){
  157. let that = this
  158. getResourcesCount().then(res => {
  159. console.log("res=", res)
  160. console.log("res.data=", res.data)
  161. this.resourcesCountList = res.data;
  162. this.resourcesCountList.forEach(function(data, index) {
  163. // // that.$set(that.resourcesList[index], 'icon', 'sj' + '-' + 'icon' + '-' + data.resourceTable.split('_').slice(-1))
  164. // console.log("data.type.split('_').slice(-1)", data.type.split('_').slice(-1));
  165. // that.$set(that.resourcesList[index], 'icon', 'sj' + '-' + 'icon' + '-' + data.type.replaceAll("_", "-"));
  166. let icon ='sj' + '-' + 'icon' + '-' + data.type.replaceAll("_", "-").replaceAll("@", "-");
  167. console.log("icon_" + (index + 1) + "=", icon);
  168. that.$set(that.resourcesCountList[index], 'icon', icon);
  169. // alert(resourcesCountList[i])
  170. // console.log("data resourcesCountList[index]=", data.type)
  171. // console.log("resourcesCountList[index]=", that.resourcesCountList[index])
  172. // if(index < 5){
  173. // // that.fireControlViewPoint(data.type, 'undefined');
  174. // that.selectResourcesByLabel(data.type, '所有');
  175. // }
  176. })
  177. //数据自动落点开始
  178. let maxCount = 100;//落点数超过这个数的资源不落点
  179. let list = res.data;
  180. let counts = [];
  181. let points = [];
  182. let types = [];
  183. for(let i = 0; i < list.length; i++){//获取符合要求的类型及数量
  184. if(list[i].num <= maxCount){
  185. counts.push(list[i].num);
  186. points.push({
  187. "type": list[i].type,
  188. "count": list[i].num
  189. });
  190. }
  191. }
  192. for(let i = 0; i < points.length; i++){
  193. if(points[i].count == Math.max(...counts)){
  194. types.push(points[i].type);
  195. let countsTemp = [];
  196. for (let j = 0; j < counts.length; j++) {
  197. if(counts[j] != Math.max(...counts)){
  198. countsTemp.push(counts[j]);
  199. }
  200. }
  201. counts = countsTemp;
  202. break;
  203. }
  204. }
  205. for(let i = 0; i < points.length; i++){
  206. if(points[i].count == Math.max(...counts)){
  207. types.push(points[i].type);
  208. break;
  209. }
  210. }
  211. for(let i = 0; i < types.length; i++){
  212. that.selectResourcesByLabel(types[i], '所有');
  213. }
  214. //数据自动落点结束
  215. })
  216. },
  217. //初始化所有资源并落点
  218. selectResources(){
  219. selectResources(this.labelList).then(res => {
  220. this.resourcesList = res.data;
  221. // this.initMarkers(this.resourcesList);
  222. })
  223. },
  224. //点击左侧某资源,将该资源进行落点
  225. selectResourcesByLabel(label, name){
  226. // 搜索框
  227. // if(name == 'undefined' && this.showSearch == false){
  228. // if(name == '所有' && this.showSearch == false){
  229. if(name == '所有'){
  230. name = undefined;
  231. }else {
  232. this.showSearch = true;
  233. }
  234. // 搜索类型
  235. this.searchType = label;
  236. console.log(label)
  237. let that = this;
  238. //每次点击,先将原有点位清空后重新落点
  239. this.markersList = [];
  240. this.resourcesList = [];
  241. that.$refs.supermap.clearM(false);
  242. that.$refs.supermap.clearM(true);
  243. selectResourcesByLabel(label, name).then(res => {
  244. console.log("res.data=", res.data)
  245. // this.resourcesList = res.data;
  246. this.resourcesList = res.data.resourceList;
  247. this.initMarkers(this.resourcesList, label.split('_').slice(-1));
  248. // this.initMarkers(this.resourcesList);
  249. })
  250. },
  251. showResourcesDialog(param) {
  252. //资源信息弹出
  253. this.$refs.resourcesdialog.showResourcesDialog(param);
  254. },
  255. initMarkers(list, type){
  256. console.log("list=", list)
  257. if (list != null && list.length > 0) {
  258. for (let i = 0; i < list.length; i++) {
  259. let markersMap = {
  260. lng: 124.59,
  261. lat: 43.02,
  262. icon: 'marker',
  263. bindPopupHtml: '',
  264. click: '',
  265. parameter: '',
  266. keepBindPopup: false,
  267. isAggregation: false
  268. }
  269. if (list.length > 200) {
  270. markersMap.isAggregation = true;
  271. }
  272. //根据标签确定资源的图标
  273. // markersMap.icon = 'traffic-resources-' + type;
  274. // alert(type+"=type")
  275. // alert(this.resourcesList[i].label+"=this.resourcesList[i].label")
  276. markersMap.icon = 'traffic-resources-' + this.resourcesList[i].label;
  277. markersMap.icon = 'traffic-resources-' + (type?type=="sign"?"warning_sign":type:this.resourcesList[i].label);
  278. markersMap.parameter = this.resourcesList[i].id + "," + this.resourcesList[i].label;
  279. markersMap.parameter = this.resourcesList[i].id + "," + (type?type:this.resourcesList[i].label);
  280. markersMap.click = '';
  281. markersMap.lng = list[i].longitude;
  282. markersMap.lat = list[i].latitude;
  283. //POP的通用部分
  284. markersMap.bindPopupHtml = '<div class="map-tip">' +
  285. '<span>' +
  286. ' <div class="d-l-con">' +
  287. ' <div class="d-l-l-text">' +
  288. ' <h4>名称:' + (list[i].name?list[i].name:"") + '</h4>' +
  289. ' </div>' +
  290. ' </div>' +
  291. '</span>';
  292. if(list[i].label == this.labelList[0] || this.labelList[0].indexOf(type) != -1){//警示牌的POP
  293. markersMap.bindPopupHtml += ''+
  294. '<span>' +
  295. ' <div class="d-l-con">' +
  296. ' <div class="d-l-l-text">' +
  297. ' <h4>设置日期:' + ((list[i].setTime?list[i].setTime:list[i].set_time)?(list[i].setTime?list[i].setTime:list[i].set_time):"") + '</h4>' +
  298. ' </div>' +
  299. ' </div>' +
  300. '</span>' +
  301. '<span>' +
  302. ' <div class="d-l-con">' +
  303. ' <div class="d-l-l-text">' +
  304. ' <h4>用途:' + (list[i].effect?list[i].effect:"") + '</h4>' +
  305. ' </div>' +
  306. ' </div>' +
  307. '</span>';
  308. }
  309. if(list[i].label == this.labelList[1] || list[i].label == this.labelList[2] || this.labelList[1].indexOf(type) != -1 || this.labelList[2].indexOf(type) != -1){//桥梁涵洞的POP
  310. markersMap.bindPopupHtml += '' +
  311. '<span>' +
  312. ' <div class="d-l-con">' +
  313. ' <div class="d-l-l-text">' +
  314. ' <h4>竣工日期:' + ((list[i].completionDate?list[i].completionDate:list[i].completion_date)?(list[i].completionDate?list[i].completionDate:list[i].completion_date):"") + '</h4>' +
  315. ' </div>' +
  316. ' </div>' +
  317. '</span>' +
  318. '<span>' +
  319. '<span>' +
  320. ' <div class="d-l-con">' +
  321. ' <div class="d-l-l-text">' +
  322. ' <h4>管理单位:' + ((list[i].managementUnit?list[i].managementUnit:list[i].management_unit)?(list[i].managementUnit?list[i].managementUnit:list[i].management_unit):"") + '</h4>' +
  323. ' </div>' +
  324. ' </div>' +
  325. '</span>' +
  326. '<span>' +
  327. ' <div class="d-l-con">' +
  328. ' <div class="d-l-l-text">' +
  329. ' <h4>联系电话:' + ((list[i].manaTel?list[i].manaTel:list[i].phone)?(list[i].manaTel?list[i].manaTel:list[i].phone):"") + '</h4>' +
  330. ' </div>' +
  331. ' </div>' +
  332. '</span>' +
  333. '<span>' +
  334. ' <div class="d-l-con">' +
  335. ' <div class="d-l-l-text">' +
  336. ' <h4>养护单位:' + ((list[i].maintenanceUnit?list[i].maintenanceUnit:list[i].maintenance_unit)?(list[i].maintenanceUnit?list[i].maintenanceUnit:list[i].maintenance_unit):"") + '</h4>' +
  337. ' </div>' +
  338. ' </div>' +
  339. '</span>' +
  340. '<span>' +
  341. ' <div class="d-l-con">' +
  342. ' <div class="d-l-l-text">' +
  343. ' <h4>联系电话:' + ((list[i].mainTel?list[i].mainTel:list[i].phone)?(list[i].mainTel?list[i].mainTel:list[i].phone):"") + '</h4>' +
  344. ' </div>' +
  345. ' </div>' +
  346. '</span>';
  347. }
  348. if(list[i].remark !="" && list[i].remark !=null){//POP的备注部分
  349. markersMap.bindPopupHtml += ''+
  350. '<span>' +
  351. ' <div class="d-l-con">' +
  352. ' <div class="d-l-l-text">' +
  353. ' <h4>备注:' + (list[i].remark?list[i].remark:"") + '</h4>' +
  354. ' </div>' +
  355. ' </div>' +
  356. '</span>' ;
  357. }
  358. markersMap.bindPopupHtml += '</div>'
  359. this.markersList.push(markersMap)
  360. }
  361. setTimeout(() => {
  362. // return
  363. this.$refs.supermap.clearM()
  364. this.$refs.supermap.setMarkers(this.markersList)
  365. }, 2000)
  366. }
  367. },
  368. /** ----------------------------------底部按钮公用组件开始------------------------------------- */
  369. bottomMenuList() {
  370. // this.$refs.bottomMenu.selectTaskList()//获取任务列表
  371. this.$refs.bottomMenu.selectMessageList()//获取消息列表
  372. },
  373. showDialog(click) {
  374. if (click == 'eventLocation') {
  375. this.$refs.eventLocation.showEventLocation()
  376. this.$refs.supermap.isEditableLayers = false
  377. this.$refs.bottomMenu.showChild = false
  378. this.$refs.bottomMenu.showBanChild = false
  379. this.$refs.bottomMenu.showChangChild = false
  380. } else if (click == 'editableLayers') {
  381. this.$refs.bottomMenu.showChild = false
  382. this.$refs.bottomMenu.showBanChild = false
  383. this.$refs.bottomMenu.showChangChild = false
  384. if (!this.$refs.supermap.isEditableLayers) {
  385. this.$refs.supermap.isEditableLayers = true
  386. } else {
  387. this.$refs.supermap.isEditableLayers = false
  388. }
  389. } else if (click == 'layerSwitching') {
  390. this.$refs.supermap.isEditableLayers = false
  391. this.$refs.bottomMenu.showBanChild = false
  392. this.$refs.bottomMenu.showChangChild = false
  393. if (!this.$refs.bottomMenu.showChild) {
  394. this.$refs.bottomMenu.showChild = true
  395. } else {
  396. this.$refs.bottomMenu.showChild = false
  397. }
  398. } else if (click == 'TVWall') {
  399. this.$refs.TVWall.showTVWall()
  400. this.$refs.supermap.isEditableLayers = false
  401. this.$refs.bottomMenu.showChild = false
  402. this.$refs.bottomMenu.showBanChild = false
  403. this.$refs.bottomMenu.showChangChild = false
  404. } else if (click == 'forestban') {
  405. this.$refs.supermap.isEditableLayers = false
  406. this.$refs.bottomMenu.showChild = false
  407. this.$refs.bottomMenu.showChangChild = false
  408. if (!this.$refs.bottomMenu.showBanChild) {
  409. this.$refs.bottomMenu.showBanChild = true
  410. } else {
  411. this.$refs.bottomMenu.showBanChild = false
  412. }
  413. } else if (click == 'forestchang') {
  414. this.$refs.supermap.isEditableLayers = false
  415. this.$refs.bottomMenu.showBanChild = false
  416. this.$refs.bottomMenu.showChild = false
  417. if (!this.$refs.bottomMenu.showChangChild) {
  418. this.$refs.bottomMenu.showChangChild = true
  419. } else {
  420. this.$refs.bottomMenu.showChangChild = false
  421. }
  422. }
  423. },
  424. //选择图层
  425. choseLayerSwitching(url, isClear) {
  426. this.$refs.supermap.layerSwitching(url, isClear)
  427. },
  428. //选择图层(传递数组)
  429. choseLayerSwitchingList(urlList) {
  430. this.$refs.supermap.layerSwitchingList(urlList)
  431. },
  432. /** ----------------------------------底部按钮公用组件结束------------------------------------- */
  433. /** ----------------------------------摄像头预览开始------------------------------------- */
  434. alertLogin: function() {
  435. this.$modal.msg('登录中....')
  436. },
  437. alertLoginSuccess: function() {
  438. this.$modal.msgSuccess('登录成功!')
  439. },
  440. alertLoginFailed: function() {
  441. this.$modal.msgError('登陆失败!')
  442. },
  443. alertReinstall: function() {
  444. this.$modal.msgWarning('请重新安装客户端')
  445. },
  446. cancelEventLocationShow() {
  447. if (this.oWebControl != null) {
  448. this.oWebControl.JS_HideWnd() // 先让窗口隐藏,规避可能的插件窗口滞后于浏览器消失问题
  449. this.oWebControl.JS_Disconnect().then(function() { // 断开与插件服务连接成功
  450. },
  451. function() { // 断开与插件服务连接失败
  452. })
  453. }
  454. },
  455. /** 预览按钮操作 */
  456. preview(cameraCode) {
  457. let that = this
  458. that.cameraVisible = true
  459. getHaiKangVideoServer({cameraCode:cameraCode}).then(newResponse => {
  460. that.cameraTitle = '摄像头-'+newResponse.data.cameraName
  461. that.initPlugin(newResponse.data.appkey,newResponse.data.loginIp,newResponse.data.secret,newResponse.data.loginPort)
  462. setTimeout(function() {
  463. that.playhk(newResponse.data.channelCode)
  464. }, 5000)
  465. })
  466. },
  467. realTimeVideoDialog(cameraParams) { // 调用弹窗实时播放接口
  468. if (!this.isLogin) {
  469. this.$Message.info('正在登陆客户端,请稍等......')
  470. return false
  471. }
  472. this.ws.openVideo(cameraParams)
  473. },
  474. /** ----------------------------------摄像头预览结束------------------------------------- */
  475. /** ----------------------------------海康摄像头预览开始------------------------------------- */
  476. // 创建播放实例
  477. initPlugin(newappkey,newloginIp,newsecret,newloginPort) {
  478. let that=this
  479. that.oWebControl = new WebControl({
  480. szPluginContainer: 'playWnd', // 指定容器id
  481. iServicePortStart: 15900, // 指定起止端口号,建议使用该值
  482. iServicePortEnd: 15909,
  483. szClassId: '23BF3B0A-2C56-4D97-9C03-0CB103AA8F11', // 用于IE10使用ActiveX的clsid
  484. cbConnectSuccess: function() { // 创建WebControl实例成功
  485. that.oWebControl.JS_StartService('window', { // WebControl实例创建成功后需要启动服务
  486. dllPath: './VideoPluginConnect.dll' // 值"./VideoPluginConnect.dll"写死
  487. }).then(function() { // 启动插件服务成功
  488. that.oWebControl.JS_SetWindowControlCallback({ // 设置消息回调
  489. cbIntegrationCallBack: cbIntegrationCallBack
  490. })
  491. that.oWebControl.JS_CreateWnd('playWnd', 1020, 600).then(function() { //JS_CreateWnd创建视频播放窗口,宽高可设定
  492. that.init(newappkey,newloginIp,newsecret,newloginPort) // 创建播放实例成功后初始化
  493. })
  494. }, function() { // 启动插件服务失败
  495. })
  496. },
  497. cbConnectError: function() { // 创建WebControl实例失败
  498. that.oWebControl = null
  499. $('#playWnd').html('插件未启动,正在尝试启动,请稍候...')
  500. WebControl.JS_WakeUp('VideoWebPlugin://') // 程序未启动时执行error函数,采用wakeup来启动程序
  501. initCount++
  502. if (initCount < 3) {
  503. setTimeout(function() {
  504. that.initPlugin(newappkey,newloginIp,newsecret,newloginPort)
  505. }, 3000)
  506. } else {
  507. $('#playWnd').html('插件启动失败,请检查插件是否安装!')
  508. }
  509. },
  510. cbConnectClose: function(bNormalClose) {
  511. // 异常断开:bNormalClose = false
  512. // JS_Disconnect正常断开:bNormalClose = true
  513. console.log('cbConnectClose')
  514. that.oWebControl = null
  515. }
  516. })
  517. },
  518. //播放海康摄像头
  519. playhk(channelCode) {
  520. var cameraIndexCode = channelCode //获取输入的监控点编号值,必填
  521. var streamMode = 0 //主子码流标识:0-主码流,1-子码流
  522. var transMode = 1 //传输协议:0-UDP,1-TCP
  523. var gpuMode = 0 //是否启用GPU硬解,0-不启用,1-启用
  524. var wndId = -1 //播放窗口序号(在2x2以上布局下可指定播放窗口)
  525. cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, '')
  526. cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, '')
  527. this.oWebControl.JS_RequestInterface({
  528. funcName: 'startPreview',
  529. argument: JSON.stringify({
  530. cameraIndexCode: cameraIndexCode, //监控点编号
  531. streamMode: streamMode, //主子码流标识
  532. transMode: transMode, //传输协议
  533. gpuMode: gpuMode, //是否开启GPU硬解
  534. wndId: wndId //可指定播放窗口
  535. })
  536. })
  537. },
  538. //初始化
  539. init(newappkey,newloginIp,newsecret,newloginPort) {
  540. let that = this
  541. that.getPubKey(function() {
  542. ////////////////////////////////// 请自行修改以下变量值 ////////////////////////////////////
  543. var appkey = newappkey //综合安防管理平台提供的appkey,必填
  544. var secret = that.setEncrypt(newsecret) //综合安防管理平台提供的secret,必填
  545. var ip = newloginIp //综合安防管理平台IP地址,必填
  546. var playMode = 0 //初始播放模式:0-预览,1-回放
  547. var port = Number(newloginPort) //综合安防管理平台端口,若启用HTTPS协议,默认443
  548. var snapDir = 'D:\\SnapDir' //抓图存储路径
  549. var videoDir = 'D:\\VideoDir' //紧急录像或录像剪辑存储路径
  550. var layout = '1x1' //playMode指定模式的布局
  551. var enableHTTPS = 1 //是否启用HTTPS协议与综合安防管理平台交互,这里总是填1
  552. var encryptedFields = 'secret' //加密字段,默认加密领域为secret
  553. var showToolbar = 1 //是否显示工具栏,0-不显示,非0-显示
  554. var showSmart = 1 //是否显示智能信息(如配置移动侦测后画面上的线框),0-不显示,非0-显示
  555. var buttonIDs = '0,16,256,257,258,259,260,512,513,514,515,516,517,768,769' //自定义工具条按钮
  556. ////////////////////////////////// 请自行修改以上变量值 ////////////////////////////////////
  557. that.oWebControl.JS_RequestInterface({
  558. funcName: 'init',
  559. argument: JSON.stringify({
  560. appkey: appkey, //API网关提供的appkey
  561. secret: secret, //API网关提供的secret
  562. ip: ip, //API网关IP地址
  563. playMode: playMode, //播放模式(决定显示预览还是回放界面)
  564. port: port, //端口
  565. snapDir: snapDir, //抓图存储路径
  566. videoDir: videoDir, //紧急录像或录像剪辑存储路径
  567. layout: layout, //布局
  568. enableHTTPS: enableHTTPS, //是否启用HTTPS协议
  569. encryptedFields: encryptedFields, //加密字段
  570. showToolbar: showToolbar, //是否显示工具栏
  571. showSmart: showSmart, //是否显示智能信息
  572. buttonIDs: buttonIDs //自定义工具条按钮
  573. })
  574. }).then(function(oData) {
  575. that.oWebControl.JS_Resize(1020, 600) // 初始化后resize一次,规避firefox下首次显示窗口后插件窗口未与DIV窗口重合问题
  576. })
  577. })
  578. },
  579. //获取公钥
  580. getPubKey(callback) {
  581. let that = this
  582. that.oWebControl.JS_RequestInterface({
  583. funcName: 'getRSAPubKey',
  584. argument: JSON.stringify({
  585. keyLength: 1024
  586. })
  587. }).then(function(oData) {
  588. console.log(oData)
  589. if (oData.responseMsg.data) {
  590. that.pubKey = oData.responseMsg.data
  591. callback()
  592. }
  593. })
  594. },
  595. //RSA加密
  596. setEncrypt(value) {
  597. var encrypt = new JSEncrypt()
  598. encrypt.setPublicKey(this.pubKey)
  599. return encrypt.encrypt(value)
  600. },
  601. /** ----------------------------------海康摄像头预览结束------------------------------------- */
  602. }
  603. }
  604. </script>
  605. <style rel="stylesheet/scss" lang="scss" scoped>
  606. @import '@/assets/styles/base.scss';
  607. .playWnd {
  608. margin: 4px 0 0 8px;
  609. width: 1020px; /*播放容器的宽和高设定*/
  610. height: 600px;
  611. border: 1px solid red;
  612. }
  613. </style>