123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- var _this, baseTok = null, shipForm = null;
- var _Player = null, dataObj = [];
- var loading;
- var timeId;
- new Vue({
- el: '#app',
- data: function() {
- return {
- alertList: [],
- playSucc: false,
- audioSucc: false,
- pauseSucc: false,
- nowTab: {},
- nowTabVal: "",
- dataLi: [],
- carmPicker: false,
- authorLive: {}
- }
- },
- created:function(){
- _this = this;
- shipForm = JSON.parse(localStorage.getItem("nowShip"));
- _this.authorLive = JSON.parse(localStorage.getItem("authorArr"));
- _this.getList(true);
- clearInterval(timeId);
- timeId = setInterval(() => {
- _this.getList(false);
- },30*1000)
- _this.getTypeArr();
- },
- mounted(){
- window.addEventListener('message',(data)=>{
- shipForm = JSON.parse(localStorage.getItem("nowShip"));
- _this.closeVid();
- _this.nowTab = {};
- _this.getList(true);
- })
- },
- methods:{
- getTypeArr(){
- _this.alertList = [[{
- "name": "区域警戒",
- "icon": "area",
- "type": (_this.authorLive['P03_1']?"jjjc":"qycr")
- },{
- "name": "离岗检测",
- "icon": "leave",
- "type": "lgjc"
- },{
- "name": "抽烟检测",
- "icon": "smoke",
- "type": (_this.authorLive['P03_1']?"xyjc":"cyjs")
- },{
- "name": "打电话检测",
- "icon": "iphone",
- "type": (_this.authorLive['P03_1']?"ddhjc":"ddhjc")
- }],[{
- "name": "口罩检测",
- "icon": "facial",
- "type": (_this.authorLive['P03_1']?"kzjc":"kzjc")
- },{
- "name": "安全帽检测",
- "icon": "hat",
- "type": (_this.authorLive['P03_1']?"tkjc":"aqmjc")
- },{
- "name": "工作服检测",
- "icon": "clothes",
- "type": (_this.authorLive['P03_1']?"gzfjc":"gzfjc")
- }]]
- },
- getList(_laod){
- if(shipForm !=null && shipForm != "null"){
- if(_laod){
- loading = _this.$toast({
- type: 'loading',
- loadingType: 'spinner',
- duration: 0
- });
- }
- getOneYsy(shipForm.sn,function(sfg){
- let _opts = {
- url: ys7Url + "/api/lapp/device/camera/list",
- type:"POST"
- };
- let _data = {
- "deviceSerial": shipForm.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 = [];
- }
- if(_laod) loading.close();
- _this.checkList(sfg.status);
- })
- },true)
- }
- },
- checkList(_sta){
- if(dataObj.length){
- let _arr = [];
- if(shipForm.sn != "" && dataObj.length){
- dataObj.forEach((it,ind) => {
- if(it.channelName.indexOf("@") == -1&&shipForm.sn.indexOf(it.deviceSerial) != -1){
- it.text = it.channelName.split("PTZ")[0];
- it.value = it.deviceSerial+"-"+it.channelNo;
- it.fatSat = _sta;
- _arr.push(it);
- }
- })
- }
- _this.dataLi = _arr;
- if(_this.nowTab.deviceSerial == undefined){
- _this.nowTab = _arr[0];
- _this.nowTabVal = _arr[0].value;
- };
- }else{
- _this.dataLi = [];
- _this.nowTab = {};
- _this.nowTabVal = "";
- }
-
- },
- jumpToSee(key){
- top.location.href = `./videoAlret.html?type=${key}&sn=1`;
- },
- cahngeTabVal(val){
- let _sji = _this.dataLi.filter(item => item.value == val);
- if(_sji.length&&_sji[0].value != _this.nowTab.value){
- _this.nowTab = _sji[0];
- _this.nowTabVal = _sji[0].value;
- if(_this.nowTab.status == 1&&_this.nowTab.fatSat == 1){
- _this.playEzopen();
- }else{
- this.$toast({
- type: 'fail',
- message: '设备离线中!!!'
- });
- }
- }
- },
- playEzopen(){
- if(_Player != null){
- _Player.stop();
- }
- let _wid = $(".videoBox").width();
- let _src = "ezopen://open.ys7.com/"+(_this.nowTab.deviceSerial)+"/"+(_this.nowTab.channelNo)+".live";
- _Player = new EZUIKit.EZUIKitPlayer({
- id: 'playWind',
- autoplay: true,
- url: _src,
- accessToken: getCookie("ylToken"),
- width: _wid,
- height: 240,
- audio: _this.audioSucc,
- plugin: ['talk'],
- decoderPath: "http://121.37.6.200/Zgcy",
- handleError: _this.handleError,
- handleSuccess: _this.handleSuccess,
- });
- },
- handleError(){
- _this.closeVid();
- this.$toast({
- type: 'fail',
- message: '视频播放失败!!!'
- });
- },
- closeVid(){
- if(_Player != null){
- _Player.stop();
- }
- _this.playSucc = false;
- _Player = null;
- _this.pauseSucc = false;
- },
- handleSuccess(){
- _this.playSucc = true;
- _this.pauseSucc = true;
- },
- // 截图
- capPic() {
- if(_Player != null){
- var capPictProm = _Player.capturePicture();
- capPictProm.then((data) => {
- // console.log("promise 获取 数据", data)
- })
- }
- },
- // 关闭
- closePla(){
- _this.closeVid();
- },
- // 暂停、播放
- changPause(){
- if(_Player == null&&!_this.playSucc){
- _this.playEzopen();
- }else{
- if(_Player != null){
- if(_this.pauseSucc){
- _Player.stop();
- _this.pauseSucc = false;
- }else{
- _Player.play();
- _this.pauseSucc = true;
- }
- }
- }
- },
- // 关开声音
- changAudio(){
- if(_Player != null){
- if(_this.audioSucc){
- _Player.closeSound();
- _this.audioSucc = false;
- }else{
- _Player.openSound();
- _this.audioSucc = true;
- }
- }
- },
- }
- })
|