vLiveManage.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. var _this, baseTok = null, shipForm = null;
  2. var _Player = null, dataObj = [];
  3. var loading;
  4. var timeId;
  5. new Vue({
  6. el: '#app',
  7. data: function() {
  8. return {
  9. alertList: [],
  10. playSucc: false,
  11. audioSucc: false,
  12. pauseSucc: false,
  13. nowTab: {},
  14. nowTabVal: "",
  15. dataLi: [],
  16. carmPicker: false,
  17. authorLive: {}
  18. }
  19. },
  20. created:function(){
  21. _this = this;
  22. shipForm = JSON.parse(localStorage.getItem("nowShip"));
  23. _this.authorLive = JSON.parse(localStorage.getItem("authorArr"));
  24. _this.getList(true);
  25. clearInterval(timeId);
  26. timeId = setInterval(() => {
  27. _this.getList(false);
  28. },30*1000)
  29. _this.getTypeArr();
  30. },
  31. mounted(){
  32. window.addEventListener('message',(data)=>{
  33. shipForm = JSON.parse(localStorage.getItem("nowShip"));
  34. _this.closeVid();
  35. _this.nowTab = {};
  36. _this.getList(true);
  37. })
  38. },
  39. methods:{
  40. getTypeArr(){
  41. _this.alertList = [[{
  42. "name": "区域警戒",
  43. "icon": "area",
  44. "type": (_this.authorLive['P03_1']?"jjjc":"qycr")
  45. },{
  46. "name": "离岗检测",
  47. "icon": "leave",
  48. "type": "lgjc"
  49. },{
  50. "name": "抽烟检测",
  51. "icon": "smoke",
  52. "type": (_this.authorLive['P03_1']?"xyjc":"cyjs")
  53. },{
  54. "name": "打电话检测",
  55. "icon": "iphone",
  56. "type": (_this.authorLive['P03_1']?"ddhjc":"ddhjc")
  57. }],[{
  58. "name": "口罩检测",
  59. "icon": "facial",
  60. "type": (_this.authorLive['P03_1']?"kzjc":"kzjc")
  61. },{
  62. "name": "安全帽检测",
  63. "icon": "hat",
  64. "type": (_this.authorLive['P03_1']?"tkjc":"aqmjc")
  65. },{
  66. "name": "工作服检测",
  67. "icon": "clothes",
  68. "type": (_this.authorLive['P03_1']?"gzfjc":"gzfjc")
  69. }]]
  70. },
  71. getList(_laod){
  72. if(shipForm !=null && shipForm != "null"){
  73. if(_laod){
  74. loading = _this.$toast({
  75. type: 'loading',
  76. loadingType: 'spinner',
  77. duration: 0
  78. });
  79. }
  80. getOneYsy(shipForm.sn,function(sfg){
  81. let _opts = {
  82. url: ys7Url + "/api/lapp/device/camera/list",
  83. type:"POST"
  84. };
  85. let _data = {
  86. "deviceSerial": shipForm.sn,
  87. "accessToken": getCookie("ylToken")
  88. };
  89. let _hea = {
  90. "Content-Type": "application/x-www-form-urlencoded"
  91. };
  92. postAxios(_opts, _data, _hea).then((res) => {
  93. if(res.code==200){
  94. dataObj = res.data;
  95. }else{
  96. dataObj = [];
  97. }
  98. if(_laod) loading.close();
  99. _this.checkList(sfg.status);
  100. })
  101. },true)
  102. }
  103. },
  104. checkList(_sta){
  105. if(dataObj.length){
  106. let _arr = [];
  107. if(shipForm.sn != "" && dataObj.length){
  108. dataObj.forEach((it,ind) => {
  109. if(it.channelName.indexOf("@") == -1&&shipForm.sn.indexOf(it.deviceSerial) != -1){
  110. it.text = it.channelName.split("PTZ")[0];
  111. it.value = it.deviceSerial+"-"+it.channelNo;
  112. it.fatSat = _sta;
  113. _arr.push(it);
  114. }
  115. })
  116. }
  117. _this.dataLi = _arr;
  118. if(_this.nowTab.deviceSerial == undefined){
  119. _this.nowTab = _arr[0];
  120. _this.nowTabVal = _arr[0].value;
  121. };
  122. }else{
  123. _this.dataLi = [];
  124. _this.nowTab = {};
  125. _this.nowTabVal = "";
  126. }
  127. },
  128. jumpToSee(key){
  129. top.location.href = `./videoAlret.html?type=${key}&sn=1`;
  130. },
  131. cahngeTabVal(val){
  132. let _sji = _this.dataLi.filter(item => item.value == val);
  133. if(_sji.length&&_sji[0].value != _this.nowTab.value){
  134. _this.nowTab = _sji[0];
  135. _this.nowTabVal = _sji[0].value;
  136. if(_this.nowTab.status == 1&&_this.nowTab.fatSat == 1){
  137. _this.playEzopen();
  138. }else{
  139. this.$toast({
  140. type: 'fail',
  141. message: '设备离线中!!!'
  142. });
  143. }
  144. }
  145. },
  146. playEzopen(){
  147. if(_Player != null){
  148. _Player.stop();
  149. }
  150. let _wid = $(".videoBox").width();
  151. let _src = "ezopen://open.ys7.com/"+(_this.nowTab.deviceSerial)+"/"+(_this.nowTab.channelNo)+".live";
  152. _Player = new EZUIKit.EZUIKitPlayer({
  153. id: 'playWind',
  154. autoplay: true,
  155. url: _src,
  156. accessToken: getCookie("ylToken"),
  157. width: _wid,
  158. height: 240,
  159. audio: _this.audioSucc,
  160. plugin: ['talk'],
  161. decoderPath: "http://121.37.6.200/Zgcy",
  162. handleError: _this.handleError,
  163. handleSuccess: _this.handleSuccess,
  164. });
  165. },
  166. handleError(){
  167. _this.closeVid();
  168. this.$toast({
  169. type: 'fail',
  170. message: '视频播放失败!!!'
  171. });
  172. },
  173. closeVid(){
  174. if(_Player != null){
  175. _Player.stop();
  176. }
  177. _this.playSucc = false;
  178. _Player = null;
  179. _this.pauseSucc = false;
  180. },
  181. handleSuccess(){
  182. _this.playSucc = true;
  183. _this.pauseSucc = true;
  184. },
  185. // 截图
  186. capPic() {
  187. if(_Player != null){
  188. var capPictProm = _Player.capturePicture();
  189. capPictProm.then((data) => {
  190. // console.log("promise 获取 数据", data)
  191. })
  192. }
  193. },
  194. // 关闭
  195. closePla(){
  196. _this.closeVid();
  197. },
  198. // 暂停、播放
  199. changPause(){
  200. if(_Player == null&&!_this.playSucc){
  201. _this.playEzopen();
  202. }else{
  203. if(_Player != null){
  204. if(_this.pauseSucc){
  205. _Player.stop();
  206. _this.pauseSucc = false;
  207. }else{
  208. _Player.play();
  209. _this.pauseSucc = true;
  210. }
  211. }
  212. }
  213. },
  214. // 关开声音
  215. changAudio(){
  216. if(_Player != null){
  217. if(_this.audioSucc){
  218. _Player.closeSound();
  219. _this.audioSucc = false;
  220. }else{
  221. _Player.openSound();
  222. _this.audioSucc = true;
  223. }
  224. }
  225. },
  226. }
  227. })