var _this, dataObj = [],nowYsy = null,_pageStart = 0; var _Player = null,loading = null; new Vue({ el: '#app', data: function() { return { dataLi: [], nowTab: {}, playSucc: false, fatSat: 0 } }, created() { _this = this; nowYsy = JSON.parse(localStorage.getItem("nowShip")); _this.initAjax(); }, mounted(){ window.addEventListener('message',(data)=>{ nowYsy = JSON.parse(localStorage.getItem("nowShip")); _this.initAjax(); }) }, methods: { initAjax(){ loading = this.$loading({ background: 'rgba(0, 0, 0, 0.4)' }) _pageStart = 0; dataObj = []; _this.getList(); }, getList(){ if(nowYsy !=null && nowYsy != "null"){ getOneYsy(nowYsy.sn,function(sfg){ let _opts = { url: ys7Url + "/api/lapp/device/camera/list", type:"POST" }; let _data = { "deviceSerial": nowYsy.sn, "accessToken": getCookie("ylToken") }; let _hea = { "Content-Type": "application/x-www-form-urlencoded" }; postAxios(_opts, _data, _hea).then((res) => { if(res.code==200){ dataObj = res.data; }else{ dataObj = []; } _this.checkList(sfg.status); loading.close(); }) },true); } }, checkList(_sta){ let _arr = []; if(nowYsy.sn != ""&&dataObj.length){ dataObj.forEach((it,ind) => { if(it.channelName.indexOf("@") == -1&&nowYsy.sn.indexOf(it.deviceSerial) != -1){ it.name = it.channelName.split("PTZ")[0].split("_")[0]; it.fatSat = _sta; _arr.push(it); } }) } _this.closeVid(); _this.dataLi = _arr; }, changTab(id){ let ind = _this.dataLi.findIndex((it,ind) => {return id == it.deviceSerial+''+it.channelNo}); if(ind != -1){ if(_this.dataLi[ind].status == 1&&_this.dataLi[ind].fatSat == 1){ if(_Player != null){ _Player.stop(); } _this.nowTab = _this.dataLi[ind]; if(_Player != null){ _Player.play({ // url: "ezopen://open.ys7.com/L18717217/7.rec?begin=20231205062000&end=20231205063000" url: "ezopen://open.ys7.com/"+(_this.nowTab.deviceSerial)+"/"+(_this.nowTab.channelNo)+".rec", }) }else{ _this.playEzopen(); } }else{ _this.$message({ showClose: true, message: '设备离线中!!!', type: 'warning' }); } } }, playEzopen(){ let _wid = $(".videobox").width(); let _hie = $(".videobox").height(); let _src = "ezopen://open.ys7.com/"+(_this.nowTab.deviceSerial)+"/"+(_this.nowTab.channelNo)+".rec"; // let _src = "ezopen://open.ys7.com/L18717217/7.rec?begin=20231205062000&end=20231205063000" _Player = new EZUIKit.EZUIKitPlayer({ id: 'playWind', autoplay: true, url: _src, accessToken: getCookie("ylToken"), width:_wid, height: parseFloat(_hie) - 50, audio:false, template: 'pcRec', plugin: ['talk'], decoderPath: staticUrl, handleError: _this.handleError, handleSuccess: _this.handleSuccess, handleClose: _this.closeVid }); }, handleError(){ _this.closeVid() _this.$message({ showClose: true, message: '视频播放失败!!!', type: 'error' }); }, closeVid(num){ if(_Player != null){ _Player.stop(); // _Player.destroy(); } _this.playSucc = false; // _Player = null; _this.nowTab = {}; }, handleSuccess(){ _this.playSucc = true; } } })