123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492 |
- var _this, dataObj = [],nowYsy = null;
- var _Player = null,loading = null;
- new Vue({
- el: '#app',
- data: function() {
- return {
- dataLi: [],
- nowTab: {},
- playSucc: false,
- pauseSucc: true,
- videoTape: false,
- audioSucc: false,
- talkSucc: false,
- cotrSucc: false,
- textContent: "",
- dialogVisible: false
- }
- },
- 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(){
- // checkNuuid();
- loading = this.$loading({
- background: 'rgba(0, 0, 0, 0.4)'
- })
- 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) => {
- let res = {
- data: [{
- "deviceSerial": "K61426288",
- "ipcSerial": "7L04B43PAG4A724",
- "channelNo": 1,
- "deviceName": "振浮6 DS-7916N-R4(K61426288)",
- "localName": "振浮6 DS-7916N-R4(K61426288)",
- "channelName": "驾驶室",
- "status": 1,
- "isShared": "0",
- "picUrl": "https://statics.ys7.com/device/assets/imgs/public/homeDevice.jpeg",
- "isEncrypt": 0,
- "videoLevel": 0,
- "relatedIpc": true,
- "isAdd": 1,
- "devType": "DH-IPC-HDW2433T-A-V4"
- },
- {
- "deviceSerial": "K61426288",
- "ipcSerial": "8H0970BPHAE80BC",
- "channelNo": 10,
- "deviceName": "振浮6 DS-7916N-R4(K61426288)",
- "localName": "振浮6 DS-7916N-R4(K61426288)",
- "channelName": "船尾右舷向前",
- "status": 1,
- "isShared": "0",
- "picUrl": "https://statics.ys7.com/device/assets/imgs/public/homeDevice.jpeg",
- "isEncrypt": 0,
- "videoLevel": 0,
- "relatedIpc": true,
- "isAdd": 1,
- "devType": "IPC-HFW2433F-ZSA"
- },
- {
- "deviceSerial": "K61426288",
- "ipcSerial": "8H0970BPHAE0950",
- "channelNo": 11,
- "deviceName": "振浮6 DS-7916N-R4(K61426288)",
- "localName": "振浮6 DS-7916N-R4(K61426288)",
- "channelName": "船尾左向后",
- "status": 1,
- "isShared": "0",
- "picUrl": "https://statics.ys7.com/device/assets/imgs/public/homeDevice.jpeg",
- "isEncrypt": 0,
- "videoLevel": 0,
- "relatedIpc": true,
- "isAdd": 1,
- "devType": "IPC-HFW2433F-ZSA"
- },
- {
- "deviceSerial": "K61426288",
- "ipcSerial": "7M027F6PAG30481",
- "channelNo": 12,
- "deviceName": "振浮6 DS-7916N-R4(K61426288)",
- "localName": "振浮6 DS-7916N-R4(K61426288)",
- "channelName": "船尾右向后",
- "status": 1,
- "isShared": "0",
- "picUrl": "https://statics.ys7.com/device/assets/imgs/public/homeDevice.jpeg",
- "isEncrypt": 0,
- "videoLevel": 0,
- "relatedIpc": true,
- "isAdd": 1,
- "devType": "IPC-HFW2433F-ZSA"
- },
- {
- "deviceSerial": "K61426288",
- "ipcSerial": "8H0D67FPAG4C400",
- "channelNo": 13,
- "deviceName": "振浮6 DS-7916N-R4(K61426288)",
- "localName": "振浮6 DS-7916N-R4(K61426288)",
- "channelName": "前大桅向后",
- "status": 1,
- "isShared": "0",
- "picUrl": "https://statics.ys7.com/device/assets/imgs/public/homeDevice.jpeg",
- "isEncrypt": 0,
- "videoLevel": 0,
- "relatedIpc": true,
- "isAdd": 1,
- "devType": "DH-IPC-HFW1430M-A-I1"
- }],
- code: 200
- };
- let sfg = { status: 1 };
- 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(key){
- _this.dataLi.forEach(item=>{
- if((item.deviceSerial+''+item.channelNo) == key){
- if(item.status == 1&&item.fatSat == 1){
- _this.nowTab = item;
- _this.playEzopen();
- }else{
- _this.$message({
- showClose: true,
- message: '设备离线中!!!',
- type: 'warning'
- });
- }
- }
- })
-
- // let ind = _this.dataLi.findIndex((it,ind) => {return it.deviceSerial+''+it.channelNo == id});
- // console.log(ind)
- // if(ind != -1){
- // _this.closeVid();
- // if(_this.dataLi[ind].channelNo != _this.nowTab.channelNo){
- // _this.nowTab = _this.dataLi[ind];
- // if(_this.nowTab.status == 0){
- // _this.$message({
- // showClose: true,
- // message: '设备离线中!!!',
- // type: 'warning'
- // });
- // }else{
- // _this.playEzopen();
- // }
- // }
- // }
- },
- playEzopen(){
- if(_Player != null){
- _Player.stop();
- }
- let _wid = $(".videobox").width();
- let _hie = $(".videobox").height();
- 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:_hie,
- audio:false,
- plugin: ['talk'],
- decoderPath: staticUrl,
- handleError: _this.handleError,
- handleSuccess: _this.handleSuccess,
- });
- },
- handleError(){
- _this.closeVid()
- _this.$message({
- showClose: true,
- message: '视频播放失败!!!',
- type: 'error'
- });
- },
- closeVid(){
- if(_Player != null){
- _Player.stop();
- }
- _this.playSucc = false;
- _Player = null;
- _this.nowTab = {};
- _this.pauseSucc = true;
- _this.videoTape = false;
- _this.audioSucc = false;
- _this.talkSucc = false;
- _this.cotrSucc = false;
- },
- handleSuccess(){
- _this.playSucc = true;
- },
- // 截图
- capPic() {
- if(_Player != null){
- var capPictProm = _Player.capturePicture();
- capPictProm.then((data) => {
- // console.log("promise 获取 数据", data)
- })
- }
- },
- // 关闭
- closePla(){
- _this.closeVid();
- },
- // 暂停、播放
- changPause(){
- if(_Player != null){
- if(_this.pauseSucc){
- _Player.stop();
- _this.pauseSucc = false;
- }else{
- _Player.play();
- _this.pauseSucc = true;
- }
- }
- },
- // 录像
- changTape(){
- if(_Player != null){
- if(_this.videoTape){
- let tapeProm = _Player.stopSave();
- tapeProm.then((data) => {
- _this.$message({
- showClose: true,
- message: '录制结束!!!',
- type: 'success'
- });
- _this.videoTape = false;
- })
- }else{
- let tapeProm = _Player.startSave();
- tapeProm.then((data) => {
- _this.$message({
- showClose: true,
- message: '开始录制!!!',
- type: 'success'
- });
- _this.videoTape = true;
- })
- }
- }
- },
- // 全屏
- fullScreen() {
- if(_Player != null){
- // var fullProm = playr.fullScreen();
- let ele = document.getElementById("playWind");
- if (ele.requestFullscreen) {
- ele.requestFullscreen();
- } else if (ele.mozRequestFullScreen) {
- ele.mozRequestFullScreen();
- } else if (ele.webkitRequestFullscreen) {
- ele.webkitRequestFullscreen();
- } else if (ele.msRequestFullscreen) {
- ele.msRequestFullscreen();
- }
- // fullProm.then((data) => {
- // // console.log("promise 获取 数据", data)
- // })
- }
-
- },
- // 关开声音
- changAudio(){
- if(_Player != null){
- if(_this.audioSucc){
- _Player.closeSound();
- _this.audioSucc = false;
- }else{
- _Player.openSound();
- _this.audioSucc = true;
- }
- }
- },
- // 打开对讲
- openTalk(){
- if(_Player != null){
- if(_this.nowTab.channelNo == 4&&_this.nowTab.deviceSerial == "J93363609"){
- if(_this.talkSucc){
- _Player.stopTalk();
- _this.$message({
- showClose: true,
- message: '对讲关闭!!!',
- type: 'success'
- });
- _this.talkSucc = false;
- }else{
- _Player.startTalk();
- _this.$message({
- showClose: true,
- message: '对讲开始!!!',
- type: 'success'
- });
- _this.talkSucc = true;
- }
- }else{
- _this.$message({
- showClose: true,
- message: "该摄像头不支持语音对讲功能!",
- type: 'error'
- });
- }
- }
- },
- showCotr(){
- if(_Player != null){
- if(!_this.cotrSucc){
- if(_this.nowTab.channelName.indexOf("PTZ") != -1){
- _this.cotrSucc = true;
- }else{
- _this.$message({
- showClose: true,
- message: "该摄像头不支持云台控制功能!",
- type: 'error'
- });
- }
- }else{
- _this.cotrSucc = false;
- }
- }
- },
- // 云台控制
- setCotr(_dire){
- let _opts = {
- url: ys7Url + "/api/lapp/device/ptz/start",
- type:"POST"
- };
- let _data = {
- "accessToken": getCookie("ylToken"),
- "deviceSerial": _this.nowTab.deviceSerial,
- "channelNo": _this.nowTab.channelNo,
- "direction": _dire,
- "speed": 1
- };
- let _hea = {
- "Content-Type": "application/x-www-form-urlencoded"
- };
- postAxios(_opts, _data, _hea).then((res) => {
- if(res.code != 200){
- _this.$message({
- showClose: true,
- message: res.msg,
- type: 'error'
- });
- }
- })
- },
- stopCotr(_dire){
- let _opts = {
- url: ys7Url + "/api/lapp/device/ptz/stop",
- type:"POST"
- };
- let _data = {
- "accessToken": getCookie("ylToken"),
- "deviceSerial": _this.nowTab.deviceSerial,
- "channelNo": _this.nowTab.channelNo,
- "direction": _dire,
- "speed": 1
- };
- let _hea = {
- "Content-Type": "application/x-www-form-urlencoded"
- };
- postAxios(_opts, _data, _hea).then((res) => {
- if(res.code != 200){
- _this.$message({
- showClose: true,
- message: res.msg,
- type: 'error'
- });
-
- }
- })
-
- },
- setFirst(){
- let _opts = {
- url: ys7Url + "/api/lapp/device/preset/move",
- type:"POST"
- };
- let _data = {
- "accessToken": getCookie("ylToken"),
- "deviceSerial": _this.nowTab.deviceSerial,
- "channelNo": _this.nowTab.channelNo,
- "index": it.channelName.split("PTZ")[1]
- };
- let _hea = {
- "Content-Type": "application/x-www-form-urlencoded"
- };
- postAxios(_opts, _data, _hea).then((res) => {
- if(res.code != 200){
- _this.$message({
- showClose: true,
- message: res.msg,
- type: 'error'
- });
-
- }
- })
- },
- //
- showSend(){
- _this.textContent = "";
- _this.dialogVisible = true;
- },
- // 文本语音下发
- confirmSend(){
- if(!_this.textContent.length){
- _this.$message({
- showClose: true,
- message: '请先填写需要下发的内容!!!',
- type: 'error'
- });
- return;
- }
- let _obj = {
- "cmd":{
- "id":"501",
- "cmd":"CmdSendText",
- "name":"文本信息下发",
- "pid":"50",
- "seq":501,
- "support":",HS_1,BB_1,",
- "exclude":"",
- "timeOut":60,
- "offline":"0",
- "isShow":true,
- "pname":"信息指令",
- "module":"MsgText",
- },
- "cmd2":"CmdSendText",
- "carIds":["2166624"],
- "params":{
- "signBit":"00010000",
- "textMsg":"123",
- }
- };
- sendTxt(_obj).then(res => {
- console.log(res)
- })
- }
- }
- })
|