resources.vue 30 KB

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