videoBack.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. var _this, dataObj = [],nowYsy = null,_pageStart = 0;
  2. var _Player = null,loading = null;
  3. new Vue({
  4. el: '#app',
  5. data: function() {
  6. return {
  7. dataLi: [],
  8. nowTab: {},
  9. playSucc: false,
  10. fatSat: 0
  11. }
  12. },
  13. created() {
  14. _this = this;
  15. nowYsy = JSON.parse(localStorage.getItem("nowShip"));
  16. _this.initAjax();
  17. },
  18. mounted(){
  19. window.addEventListener('message',(data)=>{
  20. nowYsy = JSON.parse(localStorage.getItem("nowShip"));
  21. _this.initAjax();
  22. })
  23. },
  24. methods: {
  25. initAjax(){
  26. loading = this.$loading({
  27. background: 'rgba(0, 0, 0, 0.4)'
  28. })
  29. _pageStart = 0;
  30. dataObj = [];
  31. _this.getList();
  32. },
  33. getList(){
  34. if(nowYsy !=null && nowYsy != "null"){
  35. getOneYsy(nowYsy.sn,function(sfg){
  36. let _opts = {
  37. url: ys7Url + "/api/lapp/device/camera/list",
  38. type:"POST"
  39. };
  40. let _data = {
  41. "deviceSerial": nowYsy.sn,
  42. "accessToken": getCookie("ylToken")
  43. };
  44. let _hea = {
  45. "Content-Type": "application/x-www-form-urlencoded"
  46. };
  47. postAxios(_opts, _data, _hea).then((res) => {
  48. if(res.code==200){
  49. dataObj = res.data;
  50. }else{
  51. dataObj = [];
  52. }
  53. _this.checkList(sfg.status);
  54. loading.close();
  55. })
  56. },true);
  57. }
  58. },
  59. checkList(_sta){
  60. let _arr = [];
  61. if(nowYsy.sn != ""&&dataObj.length){
  62. dataObj.forEach((it,ind) => {
  63. if(it.channelName.indexOf("@") == -1&&nowYsy.sn.indexOf(it.deviceSerial) != -1){
  64. it.name = it.channelName.split("PTZ")[0].split("_")[0];
  65. it.fatSat = _sta;
  66. _arr.push(it);
  67. }
  68. })
  69. }
  70. _this.closeVid();
  71. _this.dataLi = _arr;
  72. },
  73. changTab(id){
  74. let ind = _this.dataLi.findIndex((it,ind) => {return id == it.deviceSerial+''+it.channelNo});
  75. if(ind != -1){
  76. if(_this.dataLi[ind].status == 1&&_this.dataLi[ind].fatSat == 1){
  77. if(_Player != null){
  78. _Player.stop();
  79. }
  80. _this.nowTab = _this.dataLi[ind];
  81. if(_Player != null){
  82. _Player.play({
  83. // url: "ezopen://open.ys7.com/L18717217/7.rec?begin=20231205062000&end=20231205063000"
  84. url: "ezopen://open.ys7.com/"+(_this.nowTab.deviceSerial)+"/"+(_this.nowTab.channelNo)+".rec",
  85. })
  86. }else{
  87. _this.playEzopen();
  88. }
  89. }else{
  90. _this.$message({
  91. showClose: true,
  92. message: '设备离线中!!!',
  93. type: 'warning'
  94. });
  95. }
  96. }
  97. },
  98. playEzopen(){
  99. let _wid = $(".videobox").width();
  100. let _hie = $(".videobox").height();
  101. let _src = "ezopen://open.ys7.com/"+(_this.nowTab.deviceSerial)+"/"+(_this.nowTab.channelNo)+".rec";
  102. // let _src = "ezopen://open.ys7.com/L18717217/7.rec?begin=20231205062000&end=20231205063000"
  103. _Player = new EZUIKit.EZUIKitPlayer({
  104. id: 'playWind',
  105. autoplay: true,
  106. url: _src,
  107. accessToken: getCookie("ylToken"),
  108. width:_wid,
  109. height: parseFloat(_hie) - 50,
  110. audio:false,
  111. template: 'pcRec',
  112. plugin: ['talk'],
  113. decoderPath: staticUrl,
  114. handleError: _this.handleError,
  115. handleSuccess: _this.handleSuccess,
  116. handleClose: _this.closeVid
  117. });
  118. },
  119. handleError(){
  120. _this.closeVid()
  121. _this.$message({
  122. showClose: true,
  123. message: '视频播放失败!!!',
  124. type: 'error'
  125. });
  126. },
  127. closeVid(num){
  128. if(_Player != null){
  129. _Player.stop();
  130. // _Player.destroy();
  131. }
  132. _this.playSucc = false;
  133. // _Player = null;
  134. _this.nowTab = {};
  135. },
  136. handleSuccess(){
  137. _this.playSucc = true;
  138. }
  139. }
  140. })