video.vue 15 KB

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