video.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <div class="app-container">
  3. <headerdiv ref="headerDiv" :currentindexP="currentindexNew" :menuNameP="itemName"></headerdiv>
  4. <div style="display: inline-flex">
  5. <div class="leftTree">
  6. <el-input placeholder="输入关键字进行过滤" v-model="filterText" style="margin-top: 1rem">
  7. </el-input>
  8. <div style="height: 83vh">
  9. <el-scrollbar style="height: 110%">
  10. <el-tree :data="treedata" :load="loadNode" lazy :expand-on-click-node="false" node-key="id"
  11. :default-expanded-keys="expandedKeys" :default-checked-keys="[5]" :props="defaultProps"
  12. :filter-node-method="filterNode" ref="tree" @node-click="treeChange"
  13. style="background-color: #04283c; color: #c5d0d4">
  14. </el-tree>
  15. </el-scrollbar>
  16. </div>
  17. </div>
  18. <div style="width: 82vw;margin-left: 1vw;">
  19. <div style="padding-top:1vh">
  20. <el-form ref="form" :inline="true" :model="form" label-width="100px">
  21. <!-- <el-form-item label="所属航段" prop="航段">
  22. <el-select v-model="form.hangdaoName" placeholder="请选择" @change="initVideoData()">
  23. <el-option v-for="item in hangdaoList" :key="item" :label="item" :value="item">
  24. </el-option>
  25. </el-select>
  26. </el-form-item> -->
  27. <el-form-item label="宫格数量" prop="航段">
  28. <el-select v-model="form.type" placeholder="请选择">
  29. <el-option v-for="item in typeList" :key="item" :label="item" :value="item">
  30. </el-option>
  31. </el-select>
  32. </el-form-item>
  33. </el-form>
  34. </div>
  35. <div style="width: 100%;" v-if="form.type == '单视频'">
  36. <liveqing videoElementId="videoId1" style="width: 80vw;height: 80vh;"></liveqing>
  37. <!-- </div> -->
  38. </div>
  39. <div style="width: 100%;display: flex;flex-direction: row;flex-wrap: wrap;" v-if="form.type == '四宫格'">
  40. <!-- <div v-for="item in 9"> -->
  41. <!-- <video v-for="item in 4" style="width: 49%;margin-left:0.5%" :src="videoList[item - 1]" controls="controls"
  42. :autoplay="false" muted="muted" :ref="`videoref${item}`"></video> -->
  43. <!-- </div> -->
  44. <div v-for="item in 4"
  45. style="width: 40vw;height: 40vh;margin-left: 0.5vw;margin-top: 0.5vh;position: relative;">
  46. <div
  47. style="cursor: pointer;color: #ffffff;font-size: 1.5rem;top:10px;right: 10px; position: absolute;z-index: 999;"
  48. @click="deleteVideo(item)">
  49. <i class="el-icon-close"></i>
  50. </div>
  51. <LivePlayer v-if="displayList[item - 1]" :videoUrl="videoList[item - 1]" fluent autoplay live stretch
  52. style="width:100%;height:100%;">
  53. </LivePlayer>
  54. </div>
  55. <!-- <div style="width: 35vw;margin-left:1vw" class='video_content' v-for="(item, index) in 4">
  56. <liveqing :videoElementId="videoId+index" style="width:40vw;height: 40vh;"></liveqing>
  57. </div> -->
  58. </div>
  59. <div style="width: 100%;display: flex;flex-direction: row;flex-wrap: wrap;" v-if="form.type == '九宫格'">
  60. <div v-for="item in 9"
  61. style="width: 26vw;height: 26vh;margin-left: 0.5vw;margin-top: 0.5vh;position: relative;">
  62. <div
  63. style="cursor: pointer;color: #ffffff;font-size: 1.5rem;top:10px;right: 10px; position: absolute;z-index: 999;"
  64. @click="deleteVideo(item)">
  65. <i class="el-icon-close"></i>
  66. </div>
  67. <LivePlayer v-if="displayList[item - 1]" :videoUrl="videoList[item - 1]" fluent autoplay live stretch
  68. style="width:100%;height:100%;">
  69. </LivePlayer>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </template>
  76. <script>
  77. import { listVideo, queryCamera, editCamera } from "@/api/qdtl/video";
  78. import { getSinglePawns } from "@/api/qdtl/data";
  79. import { httpRequest } from "@/api/data/http";
  80. import videodiv from "@/components/Videoplayer/index.vue";
  81. import headerdiv from "@/components/HeaderDiv/index.vue";
  82. import LivePlayer from '@liveqing/liveplayer' // vue2
  83. import liveqing from "@/components/livePlayer.vue";
  84. let player;
  85. export default {
  86. data() {
  87. return {
  88. typeList: ['单视频', '四宫格', '九宫格'],
  89. displayList: [true, true, true, true, true, true, true, true, true],
  90. videoList: [
  91. ],
  92. form: { type: '四宫格' },
  93. timer: null,
  94. itemName: "视频监测",
  95. videoMap: new Map(),
  96. nameObj: {
  97. channel: "",
  98. name: "",
  99. },
  100. videoplaysrc: "",
  101. treedata: [
  102. {
  103. id: 1,
  104. label: "监控视频",
  105. children: [],
  106. },
  107. {
  108. id: 100,
  109. label: "单兵",
  110. children: [],
  111. },
  112. ],
  113. dbdata: [],
  114. videoData: [],
  115. videoCodeList: [],
  116. isvideo: true,
  117. // videoMap:new Map(),
  118. expandedKeys: [],
  119. videoIndex: 1,
  120. currentindexNew: 2,
  121. remarkName: false,
  122. data: [
  123. {
  124. id: 1,
  125. label: "一级 1",
  126. children: [
  127. {
  128. id: 4,
  129. label: "二级 1-1",
  130. children: [
  131. {
  132. id: 9,
  133. label: "三级 1-1-1",
  134. },
  135. {
  136. id: 10,
  137. label: "三级 1-1-2",
  138. },
  139. ],
  140. },
  141. ],
  142. },
  143. {
  144. id: 2,
  145. label: "一级 2",
  146. children: [
  147. {
  148. id: 5,
  149. label: "二级 2-1",
  150. },
  151. {
  152. id: 6,
  153. label: "二级 2-2",
  154. },
  155. ],
  156. },
  157. {
  158. id: 3,
  159. label: "一级 3",
  160. children: [
  161. {
  162. id: 7,
  163. label: "二级 3-1",
  164. },
  165. {
  166. id: 8,
  167. label: "二级 3-2",
  168. },
  169. ],
  170. },
  171. ],
  172. defaultProps: {
  173. children: "children",
  174. label: "label",
  175. },
  176. filterText: "",
  177. ccode: "",
  178. jsonArry: [],
  179. creamData: [],
  180. pointIdArry: [],
  181. regionIndexCode: "",
  182. queryParams: {
  183. url: "http://2.90.220.252:9017/artemis-web/debug",
  184. params:
  185. '{"httpMethod":"POST","path":"/api/resource/v1/regions","headers":{},"query":{},"parameter":{},"body":{"pageNo": 1,"pageSize": 200,"treeCode": "0"},"contentType":"application/json;charset=UTF-8","mock":false,"appKey":"27794545","appSecret":"5Xi27Gl7JrbHHF1MpdaB"}',
  186. },
  187. videoParams: {
  188. url: "http://2.90.220.252:9017/artemis-web/debug",
  189. // params:'{"httpMethod":"POST","path":"/api/resource/v1/regions/regionIndexCode/cameras","headers":{},"query":{},"parameter":{},"body":{"pageNo": 1,"pageSize": 200,"regionIndexCode": "'+this.regionIndexCode+'"},"contentType":"application/json;charset=UTF-8","mock":false,"appKey":"27794545","appSecret":"5Xi27Gl7JrbHHF1MpdaB"}'
  190. },
  191. hlsParams: {
  192. url: "http://2.90.220.252:9017/artemis-web/debug",
  193. }
  194. };
  195. },
  196. components: {
  197. videodiv,
  198. headerdiv,
  199. liveqing,
  200. LivePlayer
  201. },
  202. watch: {
  203. filterText(val) {
  204. this.$refs.tree.filter(val);
  205. },
  206. videoData(val) {
  207. this.treedata[0].children = val;
  208. },
  209. dbdata(val) {
  210. this.treedata[1].children = val;
  211. },
  212. },
  213. created() {
  214. this.getvideo();
  215. var that = this
  216. this.timer = setInterval(() => {
  217. that.initVideoList();
  218. }, 60000);
  219. },
  220. mounted() {
  221. this.queryCamera();
  222. getSinglePawns().then((res) => {
  223. this.dbdata = res.data.map((res) => {
  224. return { id: res.code, label: res.name, playaddr: res.playaddr };
  225. });
  226. });
  227. },
  228. beforeDestroy() {
  229. window.clearInterval(this.timer)
  230. // window.videosize = "1x1";
  231. // closevideo();
  232. },
  233. methods: {
  234. selectVideo(item) {
  235. },
  236. addVideo() {
  237. this.videoList.push('https://yunqivedio.alicdn.com/2017yq/v2/0x0/96d79d3f5400514a6883869399708e11/96d79d3f5400514a6883869399708e11.m3u8');
  238. },
  239. openName(node, data) {
  240. if (this.nameObj.name.length > 0) {
  241. this.nameObj.channel = data.id;
  242. editCamera(this.nameObj).then((response) => {
  243. });
  244. }
  245. },
  246. editCamera() {
  247. editCamera().then((data) => { });
  248. },
  249. queryCamera() {
  250. queryCamera().then((data) => {
  251. this.videoMap = data.data;
  252. });
  253. },
  254. loadNode(node, resolve) {
  255. // if (node.level > 4) return resolve([]);
  256. if (node.level === 0) {
  257. return resolve(this.treedata);
  258. }
  259. if (node.id === 1 && node.level === 1) {
  260. return resolve(this.treedata[0].children);
  261. }
  262. if (node.id != 1 && node.level === 1) {
  263. return resolve(this.treedata[1].children);
  264. }
  265. if (node.id === 1 && node.level === 1) {
  266. var childrens = [];
  267. for (var index in this.videoData) {
  268. if (node.data.id == this.jsonArry[index].parentIndexCode) {
  269. childrens.push(this.jsonArry[index]);
  270. }
  271. }
  272. return resolve(childrens);
  273. }
  274. if (node.level < 4) {
  275. var childrens = [];
  276. for (var index in this.jsonArry) {
  277. if (node.data.id == this.jsonArry[index].parentIndexCode) {
  278. childrens.push(this.jsonArry[index]);
  279. }
  280. }
  281. return resolve(childrens);
  282. }
  283. if (node.level >= 4) {
  284. this.videoParams.params =
  285. '{"httpMethod":"POST","path":"/api/resource/v1/regions/regionIndexCode/cameras","headers":{},"query":{},"parameter":{},"body":{"pageNo": 1,"pageSize": 200,"regionIndexCode": "' +
  286. node.data.indexCode +
  287. '"},"contentType":"application/json;charset=UTF-8","mock":false,"appKey":"27794545","appSecret":"5Xi27Gl7JrbHHF1MpdaB"}';
  288. var childrens = [];
  289. for (var index in this.jsonArry) {
  290. if (node.data.id == this.jsonArry[index].parentIndexCode) {
  291. //console.log(childerns);
  292. childrens.push(this.jsonArry[index]);
  293. }
  294. }
  295. httpRequest(this.videoParams).then((data) => {
  296. var json = JSON.parse(data.data);
  297. // console.log(json);
  298. for (var index in json.data.list) {
  299. // console.log();\
  300. var obj = json.data.list[index];
  301. obj.id = obj.cameraIndexCode;
  302. // remarkName
  303. if (this.videoMap[obj.id]) {
  304. obj.label = this.videoMap[obj.id];
  305. } else {
  306. obj.label = obj.name;
  307. }
  308. obj.data = obj;
  309. obj.lnglat = obj.longitude + "," + obj.latitude;
  310. childrens.push(obj);
  311. }
  312. resolve(childrens);
  313. });
  314. }
  315. //return resolve([]);
  316. },
  317. getvideo() {
  318. httpRequest(this.queryParams).then((response) => {
  319. try {
  320. // console.log(response);
  321. var json = JSON.parse(response.data);
  322. for (var index in json.data.list) {
  323. // obj = json.data.list[index]
  324. // obj.id = obj.indexCode;
  325. // obj.label = obj.name;
  326. // obj.data = obj;
  327. var obj = json.data.list[index];
  328. obj.id = obj.indexCode;
  329. obj.label = obj.name;
  330. obj.data = obj;
  331. this.jsonArry.push(obj);
  332. if (obj.parentIndexCode == -1) {
  333. this.videoData.push(obj);
  334. this.expandedKeys.push(obj.id);
  335. }
  336. // this.expandedKeys.push(obj.id);
  337. if (this.videoData.length > 0) {
  338. if (obj.parentIndexCode == this.videoData[0].id) {
  339. this.expandedKeys.push(obj.id);
  340. }
  341. }
  342. }
  343. } catch (error) { }
  344. });
  345. },
  346. getList() {
  347. listVideo().then((response) => {
  348. this.videoData = response.data;
  349. for (var index in this.videoData) {
  350. var obj = this.videoData[index];
  351. obj.label = obj.areaName;
  352. obj.children = [];
  353. for (var i in obj.monitors) {
  354. var monitor = obj.monitors[i];
  355. monitor.data = monitor;
  356. monitor.label = monitor.name;
  357. obj.children.push(monitor);
  358. }
  359. }
  360. });
  361. },
  362. filterNode(value, data) {
  363. if (!value) return true;
  364. return data.label.indexOf(value) !== -1;
  365. },
  366. deleteVideo(item) {
  367. this.videoCodeList.splice(item - 1,1);
  368. this.videoList.splice(item - 1, 1);
  369. },
  370. initVideoList() {
  371. this.videoList = [];
  372. for (var index in this.videoCodeList) {
  373. console.log(this.videoCodeList)
  374. this.hlsParams.params =
  375. '{"httpMethod":"POST","path":"/api/video/v1/cameras/previewURLs","headers":{},"query":{},"parameter":{},"body":{"streamType":0,"protocol":"hls","transmode":0,"expand":"transcode=0","cameraIndexCode": "' +
  376. this.videoCodeList[index] +
  377. '"},"contentType":"application/json;charset=UTF-8","mock":false,"appKey":"27794545","appSecret":"5Xi27Gl7JrbHHF1MpdaB"}';
  378. httpRequest(this.hlsParams).then((data) => {
  379. var videoData = JSON.parse(data.data);
  380. var url = videoData.data.url
  381. url = url.replace('http://2.90.220.252:83', 'https://qd.liaochengde.com:9001');
  382. console.log(url)
  383. // console.log(window.location.host+window.location.port)
  384. this.videoList.push(url);
  385. })
  386. }
  387. },
  388. treeChange(data, node) {
  389. var arry = this.$refs.tree.getCheckedNodes();
  390. if (data.cameraIndexCode != null) {
  391. this.hlsParams.params =
  392. '{"httpMethod":"POST","path":"/api/video/v1/cameras/previewURLs","headers":{},"query":{},"parameter":{},"body":{"streamType":0,"protocol":"hls","transmode":0,"expand":"transcode=0","cameraIndexCode": "' +
  393. data.cameraIndexCode +
  394. '"},"contentType":"application/json;charset=UTF-8","mock":false,"appKey":"27794545","appSecret":"5Xi27Gl7JrbHHF1MpdaB"}';
  395. httpRequest(this.hlsParams).then((res) => {
  396. var videoData = JSON.parse(res.data);
  397. var dataList = [];
  398. if (this.form.type == '四宫格') {
  399. if (this.videoList.length < 4) {
  400. var url = 'https://yunqivedio.alicdn.com/2017yq/v2/0x0/96d79d3f5400514a6883869399708e11/96d79d3f5400514a6883869399708e11.m3u8'
  401. // var url = videoData.data.url
  402. // this.videoCodeList.push(data.cameraIndexCode);
  403. // console.log(this.videoCodeList)
  404. // url = url.replace('http://2.90.220.252:83', 'https://qd.liaochengde.com:9001');
  405. // // console.log(window.location.host+window.location.port)
  406. // console.log(url)
  407. this.videoList.push(url);
  408. } else {
  409. this.$message('摄像机已满');
  410. }
  411. } else if (this.form.type == '九宫格') {
  412. if (this.videoList.length < 9) {
  413. // var url = 'https://yunqivedio.alicdn.com/2017yq/v2/0x0/96d79d3f5400514a6883869399708e11/96d79d3f5400514a6883869399708e11.m3u8'
  414. var url = videoData.data.url
  415. this.videoCodeList.push(data.cameraIndexCode);
  416. url = url.replace('http://2.90.220.252:83', 'https://qd.liaochengde.com:9001');
  417. // console.log(window.location.host+window.location.port)
  418. this.videoList.push(url);
  419. } else {
  420. this.$message('摄像机已满');
  421. }
  422. }
  423. })
  424. }
  425. // if (data.cameraIndexCode != null) {
  426. // console.log(data.cameraIndexCode);
  427. // this.isvideo = true;
  428. // window.startPreview(data.cameraIndexCode, -1);
  429. // } else {
  430. // if (data.playaddr != null) {
  431. // this.isvideo = false;
  432. // this.videoplaysrc = "/webLive.html?url=" + data.playaddr;
  433. // }
  434. // }
  435. },
  436. },
  437. };
  438. </script>
  439. <style>
  440. .leftTree {
  441. /* float:left; */
  442. width: 16vw;
  443. background-color: #04283c;
  444. padding: 10px;
  445. padding-top: 0;
  446. min-height: 95vh;
  447. z-index: 1001;
  448. }
  449. .app-container {
  450. width: 100vw;
  451. height: 100vh;
  452. padding: 0;
  453. }
  454. .selectVideo {
  455. border-style: solid;
  456. border-color: #98bf21;
  457. }
  458. </style>