resources.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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="d-l-con-icon">
  15. <div class="i-list-con h-65" v-show="showSearch == true">
  16. <div class="head-container">
  17. <el-input
  18. v-model="searchName"
  19. placeholder="请输入名称"
  20. @blur="searchByName()"
  21. clearable
  22. size="small"
  23. prefix-icon="el-icon-search"
  24. style="margin-bottom: 20px"
  25. />
  26. </div>
  27. </div>
  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. <supermap ref="supermap" style="width: 100%;height: 100vh;" :mapDiv="'forestMap'" class="indexSupermapClass"
  71. :mapSite="{doubleClickZoom:false}" :codes="['9fa5']" :isSideBySide="false" @preview="preview" @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' //超图
  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. },
  179. //初始化所有资源并落点
  180. selectResources(){
  181. selectResources(this.labelList).then(res => {
  182. this.resourcesList = res.data;
  183. this.initMarkers(this.resourcesList);
  184. })
  185. },
  186. //点击左侧某资源,将该资源进行落点
  187. selectResourcesByLabel(label, name){
  188. // 搜索框
  189. // if(name == 'undefined' && this.showSearch == false){
  190. // if(name == '所有' && this.showSearch == false){
  191. if(name == '所有'){
  192. name = undefined;
  193. }else {
  194. this.showSearch = true;
  195. }
  196. // 搜索类型
  197. this.searchType = label;
  198. console.log(label)
  199. let that = this;
  200. //每次点击,先将原有点位清空后重新落点
  201. this.markersList = [];
  202. this.resourcesList = [];
  203. that.$refs.supermap.clearM(false);
  204. that.$refs.supermap.clearM(true);
  205. selectResourcesByLabel(label, name).then(res => {
  206. console.log("res.data=", res.data)
  207. // this.resourcesList = res.data;
  208. this.resourcesList = res.data.resourceList;
  209. this.initMarkers(this.resourcesList, label.split('_').slice(-1));
  210. // this.initMarkers(this.resourcesList);
  211. })
  212. },
  213. showResourcesDialog(param) {
  214. //资源信息弹出
  215. this.$refs.resourcesdialog.showResourcesDialog(param);
  216. },
  217. initMarkers(list, type){
  218. console.log("list=", list)
  219. if (list != null && list.length > 0) {
  220. for (let i = 0; i < list.length; i++) {
  221. let markersMap = {
  222. lng: 124.59,
  223. lat: 43.02,
  224. icon: 'marker',
  225. bindPopupHtml: '',
  226. click: '',
  227. parameter: '',
  228. keepBindPopup: false,
  229. isAggregation: false
  230. }
  231. if (list.length > 200) {
  232. markersMap.isAggregation = true;
  233. }
  234. //根据标签确定资源的图标
  235. // markersMap.icon = 'traffic-resources-' + type;
  236. // alert(type+"=type")
  237. // alert(this.resourcesList[i].label+"=this.resourcesList[i].label")
  238. markersMap.icon = 'traffic-resources-' + this.resourcesList[i].label;
  239. markersMap.icon = 'traffic-resources-' + (type?type=="sign"?"warning_sign":type:this.resourcesList[i].label);
  240. markersMap.parameter = this.resourcesList[i].id + "," + this.resourcesList[i].label;
  241. markersMap.parameter = this.resourcesList[i].id + "," + (type?type:this.resourcesList[i].label);
  242. markersMap.click = 'showResourcesDialog';
  243. markersMap.lng = list[i].longitude;
  244. markersMap.lat = list[i].latitude;
  245. //POP的通用部分
  246. markersMap.bindPopupHtml = '<div class="map-tip">' +
  247. '<span>' +
  248. ' <div class="d-l-con">' +
  249. ' <div class="d-l-l-text">' +
  250. ' <h4>名称:' + (list[i].name?list[i].name:"") + '</h4>' +
  251. ' </div>' +
  252. ' </div>' +
  253. '</span>';
  254. if(list[i].label == this.labelList[0] || this.labelList[0].indexOf(type) != -1){//警示牌的POP
  255. markersMap.bindPopupHtml += ''+
  256. '<span>' +
  257. ' <div class="d-l-con">' +
  258. ' <div class="d-l-l-text">' +
  259. ' <h4>设置日期:' + ((list[i].setTime?list[i].setTime:list[i].set_time)?(list[i].setTime?list[i].setTime:list[i].set_time):"") + '</h4>' +
  260. ' </div>' +
  261. ' </div>' +
  262. '</span>' +
  263. '<span>' +
  264. ' <div class="d-l-con">' +
  265. ' <div class="d-l-l-text">' +
  266. ' <h4>用途:' + (list[i].effect?list[i].effect:"") + '</h4>' +
  267. ' </div>' +
  268. ' </div>' +
  269. '</span>';
  270. }
  271. 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
  272. markersMap.bindPopupHtml += '' +
  273. '<span>' +
  274. ' <div class="d-l-con">' +
  275. ' <div class="d-l-l-text">' +
  276. ' <h4>竣工日期:' + ((list[i].completionDate?list[i].completionDate:list[i].completion_date)?(list[i].completionDate?list[i].completionDate:list[i].completion_date):"") + '</h4>' +
  277. ' </div>' +
  278. ' </div>' +
  279. '</span>' +
  280. '<span>' +
  281. '<span>' +
  282. ' <div class="d-l-con">' +
  283. ' <div class="d-l-l-text">' +
  284. ' <h4>管理单位:' + ((list[i].managementUnit?list[i].managementUnit:list[i].management_unit)?(list[i].managementUnit?list[i].managementUnit:list[i].management_unit):"") + '</h4>' +
  285. ' </div>' +
  286. ' </div>' +
  287. '</span>' +
  288. '<span>' +
  289. ' <div class="d-l-con">' +
  290. ' <div class="d-l-l-text">' +
  291. ' <h4>联系电话:' + ((list[i].manaTel?list[i].manaTel:list[i].phone)?(list[i].manaTel?list[i].manaTel:list[i].phone):"") + '</h4>' +
  292. ' </div>' +
  293. ' </div>' +
  294. '</span>' +
  295. '<span>' +
  296. ' <div class="d-l-con">' +
  297. ' <div class="d-l-l-text">' +
  298. ' <h4>养护单位:' + ((list[i].maintenanceUnit?list[i].maintenanceUnit:list[i].maintenance_unit)?(list[i].maintenanceUnit?list[i].maintenanceUnit:list[i].maintenance_unit):"") + '</h4>' +
  299. ' </div>' +
  300. ' </div>' +
  301. '</span>' +
  302. '<span>' +
  303. ' <div class="d-l-con">' +
  304. ' <div class="d-l-l-text">' +
  305. ' <h4>联系电话:' + ((list[i].mainTel?list[i].mainTel:list[i].phone)?(list[i].mainTel?list[i].mainTel:list[i].phone):"") + '</h4>' +
  306. ' </div>' +
  307. ' </div>' +
  308. '</span>';
  309. }
  310. if(list[i].remark !="" && list[i].remark !=null){//POP的备注部分
  311. markersMap.bindPopupHtml += ''+
  312. '<span>' +
  313. ' <div class="d-l-con">' +
  314. ' <div class="d-l-l-text">' +
  315. ' <h4>备注:' + (list[i].remark?list[i].remark:"") + '</h4>' +
  316. ' </div>' +
  317. ' </div>' +
  318. '</span>' ;
  319. }
  320. markersMap.bindPopupHtml += '</div>'
  321. this.markersList.push(markersMap)
  322. }
  323. setTimeout(() => {
  324. // return
  325. this.$refs.supermap.setMarkers(this.markersList)
  326. }, 2000)
  327. }
  328. },
  329. /** ----------------------------------底部按钮公用组件开始------------------------------------- */
  330. bottomMenuList() {
  331. // this.$refs.bottomMenu.selectTaskList()//获取任务列表
  332. this.$refs.bottomMenu.selectMessageList()//获取消息列表
  333. },
  334. showDialog(click) {
  335. if (click == 'eventLocation') {
  336. this.$refs.eventLocation.showEventLocation()
  337. this.$refs.supermap.isEditableLayers = false
  338. this.$refs.bottomMenu.showChild = false
  339. this.$refs.bottomMenu.showBanChild = false
  340. this.$refs.bottomMenu.showChangChild = false
  341. } else if (click == 'editableLayers') {
  342. this.$refs.bottomMenu.showChild = false
  343. this.$refs.bottomMenu.showBanChild = false
  344. this.$refs.bottomMenu.showChangChild = false
  345. if (!this.$refs.supermap.isEditableLayers) {
  346. this.$refs.supermap.isEditableLayers = true
  347. } else {
  348. this.$refs.supermap.isEditableLayers = false
  349. }
  350. } else if (click == 'layerSwitching') {
  351. this.$refs.supermap.isEditableLayers = false
  352. this.$refs.bottomMenu.showBanChild = false
  353. this.$refs.bottomMenu.showChangChild = false
  354. if (!this.$refs.bottomMenu.showChild) {
  355. this.$refs.bottomMenu.showChild = true
  356. } else {
  357. this.$refs.bottomMenu.showChild = false
  358. }
  359. } else if (click == 'TVWall') {
  360. this.$refs.TVWall.showTVWall()
  361. this.$refs.supermap.isEditableLayers = false
  362. this.$refs.bottomMenu.showChild = false
  363. this.$refs.bottomMenu.showBanChild = false
  364. this.$refs.bottomMenu.showChangChild = false
  365. } else if (click == 'forestban') {
  366. this.$refs.supermap.isEditableLayers = false
  367. this.$refs.bottomMenu.showChild = false
  368. this.$refs.bottomMenu.showChangChild = false
  369. if (!this.$refs.bottomMenu.showBanChild) {
  370. this.$refs.bottomMenu.showBanChild = true
  371. } else {
  372. this.$refs.bottomMenu.showBanChild = false
  373. }
  374. } else if (click == 'forestchang') {
  375. this.$refs.supermap.isEditableLayers = false
  376. this.$refs.bottomMenu.showBanChild = false
  377. this.$refs.bottomMenu.showChild = false
  378. if (!this.$refs.bottomMenu.showChangChild) {
  379. this.$refs.bottomMenu.showChangChild = true
  380. } else {
  381. this.$refs.bottomMenu.showChangChild = false
  382. }
  383. }
  384. },
  385. //选择图层
  386. choseLayerSwitching(url, isClear) {
  387. this.$refs.supermap.layerSwitching(url, isClear)
  388. },
  389. //选择图层(传递数组)
  390. choseLayerSwitchingList(urlList) {
  391. this.$refs.supermap.layerSwitchingList(urlList)
  392. },
  393. /** ----------------------------------底部按钮公用组件结束------------------------------------- */
  394. /** ----------------------------------摄像头预览开始------------------------------------- */
  395. alertLogin: function() {
  396. this.$modal.msg('登录中....')
  397. },
  398. alertLoginSuccess: function() {
  399. this.$modal.msgSuccess('登录成功!')
  400. },
  401. alertLoginFailed: function() {
  402. this.$modal.msgError('登陆失败!')
  403. },
  404. alertReinstall: function() {
  405. this.$modal.msgWarning('请重新安装客户端')
  406. },
  407. cancelEventLocationShow() {
  408. if (this.oWebControl != null) {
  409. this.oWebControl.JS_HideWnd() // 先让窗口隐藏,规避可能的插件窗口滞后于浏览器消失问题
  410. this.oWebControl.JS_Disconnect().then(function() { // 断开与插件服务连接成功
  411. },
  412. function() { // 断开与插件服务连接失败
  413. })
  414. }
  415. },
  416. /** 预览按钮操作 */
  417. preview(cameraCode) {
  418. let that = this
  419. that.cameraVisible = true
  420. getHaiKangVideoServer({cameraCode:cameraCode}).then(newResponse => {
  421. that.cameraTitle = '摄像头-'+newResponse.data.cameraName
  422. that.initPlugin(newResponse.data.appkey,newResponse.data.loginIp,newResponse.data.secret,newResponse.data.loginPort)
  423. setTimeout(function() {
  424. that.playhk(newResponse.data.channelCode)
  425. }, 5000)
  426. })
  427. },
  428. realTimeVideoDialog(cameraParams) { // 调用弹窗实时播放接口
  429. if (!this.isLogin) {
  430. this.$Message.info('正在登陆客户端,请稍等......')
  431. return false
  432. }
  433. this.ws.openVideo(cameraParams)
  434. },
  435. /** ----------------------------------摄像头预览结束------------------------------------- */
  436. /** ----------------------------------海康摄像头预览开始------------------------------------- */
  437. // 创建播放实例
  438. initPlugin(newappkey,newloginIp,newsecret,newloginPort) {
  439. let that=this
  440. that.oWebControl = new WebControl({
  441. szPluginContainer: 'playWnd', // 指定容器id
  442. iServicePortStart: 15900, // 指定起止端口号,建议使用该值
  443. iServicePortEnd: 15909,
  444. szClassId: '23BF3B0A-2C56-4D97-9C03-0CB103AA8F11', // 用于IE10使用ActiveX的clsid
  445. cbConnectSuccess: function() { // 创建WebControl实例成功
  446. that.oWebControl.JS_StartService('window', { // WebControl实例创建成功后需要启动服务
  447. dllPath: './VideoPluginConnect.dll' // 值"./VideoPluginConnect.dll"写死
  448. }).then(function() { // 启动插件服务成功
  449. that.oWebControl.JS_SetWindowControlCallback({ // 设置消息回调
  450. cbIntegrationCallBack: cbIntegrationCallBack
  451. })
  452. that.oWebControl.JS_CreateWnd('playWnd', 1020, 600).then(function() { //JS_CreateWnd创建视频播放窗口,宽高可设定
  453. that.init(newappkey,newloginIp,newsecret,newloginPort) // 创建播放实例成功后初始化
  454. })
  455. }, function() { // 启动插件服务失败
  456. })
  457. },
  458. cbConnectError: function() { // 创建WebControl实例失败
  459. that.oWebControl = null
  460. $('#playWnd').html('插件未启动,正在尝试启动,请稍候...')
  461. WebControl.JS_WakeUp('VideoWebPlugin://') // 程序未启动时执行error函数,采用wakeup来启动程序
  462. initCount++
  463. if (initCount < 3) {
  464. setTimeout(function() {
  465. that.initPlugin(newappkey,newloginIp,newsecret,newloginPort)
  466. }, 3000)
  467. } else {
  468. $('#playWnd').html('插件启动失败,请检查插件是否安装!')
  469. }
  470. },
  471. cbConnectClose: function(bNormalClose) {
  472. // 异常断开:bNormalClose = false
  473. // JS_Disconnect正常断开:bNormalClose = true
  474. console.log('cbConnectClose')
  475. that.oWebControl = null
  476. }
  477. })
  478. },
  479. //播放海康摄像头
  480. playhk(channelCode) {
  481. var cameraIndexCode = channelCode //获取输入的监控点编号值,必填
  482. var streamMode = 0 //主子码流标识:0-主码流,1-子码流
  483. var transMode = 1 //传输协议:0-UDP,1-TCP
  484. var gpuMode = 0 //是否启用GPU硬解,0-不启用,1-启用
  485. var wndId = -1 //播放窗口序号(在2x2以上布局下可指定播放窗口)
  486. cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, '')
  487. cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, '')
  488. this.oWebControl.JS_RequestInterface({
  489. funcName: 'startPreview',
  490. argument: JSON.stringify({
  491. cameraIndexCode: cameraIndexCode, //监控点编号
  492. streamMode: streamMode, //主子码流标识
  493. transMode: transMode, //传输协议
  494. gpuMode: gpuMode, //是否开启GPU硬解
  495. wndId: wndId //可指定播放窗口
  496. })
  497. })
  498. },
  499. //初始化
  500. init(newappkey,newloginIp,newsecret,newloginPort) {
  501. let that = this
  502. that.getPubKey(function() {
  503. ////////////////////////////////// 请自行修改以下变量值 ////////////////////////////////////
  504. var appkey = newappkey //综合安防管理平台提供的appkey,必填
  505. var secret = that.setEncrypt(newsecret) //综合安防管理平台提供的secret,必填
  506. var ip = newloginIp //综合安防管理平台IP地址,必填
  507. var playMode = 0 //初始播放模式:0-预览,1-回放
  508. var port = Number(newloginPort) //综合安防管理平台端口,若启用HTTPS协议,默认443
  509. var snapDir = 'D:\\SnapDir' //抓图存储路径
  510. var videoDir = 'D:\\VideoDir' //紧急录像或录像剪辑存储路径
  511. var layout = '1x1' //playMode指定模式的布局
  512. var enableHTTPS = 1 //是否启用HTTPS协议与综合安防管理平台交互,这里总是填1
  513. var encryptedFields = 'secret' //加密字段,默认加密领域为secret
  514. var showToolbar = 1 //是否显示工具栏,0-不显示,非0-显示
  515. var showSmart = 1 //是否显示智能信息(如配置移动侦测后画面上的线框),0-不显示,非0-显示
  516. var buttonIDs = '0,16,256,257,258,259,260,512,513,514,515,516,517,768,769' //自定义工具条按钮
  517. ////////////////////////////////// 请自行修改以上变量值 ////////////////////////////////////
  518. that.oWebControl.JS_RequestInterface({
  519. funcName: 'init',
  520. argument: JSON.stringify({
  521. appkey: appkey, //API网关提供的appkey
  522. secret: secret, //API网关提供的secret
  523. ip: ip, //API网关IP地址
  524. playMode: playMode, //播放模式(决定显示预览还是回放界面)
  525. port: port, //端口
  526. snapDir: snapDir, //抓图存储路径
  527. videoDir: videoDir, //紧急录像或录像剪辑存储路径
  528. layout: layout, //布局
  529. enableHTTPS: enableHTTPS, //是否启用HTTPS协议
  530. encryptedFields: encryptedFields, //加密字段
  531. showToolbar: showToolbar, //是否显示工具栏
  532. showSmart: showSmart, //是否显示智能信息
  533. buttonIDs: buttonIDs //自定义工具条按钮
  534. })
  535. }).then(function(oData) {
  536. that.oWebControl.JS_Resize(1020, 600) // 初始化后resize一次,规避firefox下首次显示窗口后插件窗口未与DIV窗口重合问题
  537. })
  538. })
  539. },
  540. //获取公钥
  541. getPubKey(callback) {
  542. let that = this
  543. that.oWebControl.JS_RequestInterface({
  544. funcName: 'getRSAPubKey',
  545. argument: JSON.stringify({
  546. keyLength: 1024
  547. })
  548. }).then(function(oData) {
  549. console.log(oData)
  550. if (oData.responseMsg.data) {
  551. that.pubKey = oData.responseMsg.data
  552. callback()
  553. }
  554. })
  555. },
  556. //RSA加密
  557. setEncrypt(value) {
  558. var encrypt = new JSEncrypt()
  559. encrypt.setPublicKey(this.pubKey)
  560. return encrypt.encrypt(value)
  561. },
  562. /** ----------------------------------海康摄像头预览结束------------------------------------- */
  563. }
  564. }
  565. </script>
  566. <style rel="stylesheet/scss" lang="scss" scoped>
  567. @import '@/assets/styles/base.scss';
  568. .playWnd {
  569. margin: 4px 0 0 8px;
  570. width: 1020px; /*播放容器的宽和高设定*/
  571. height: 600px;
  572. border: 1px solid red;
  573. }
  574. </style>