diff --git a/src/views/map/index.vue b/src/views/map/index.vue index 7151670..8e27a78 100644 --- a/src/views/map/index.vue +++ b/src/views/map/index.vue @@ -250,7 +250,14 @@ var tiandituTk = 'e8a16137fd226a62a23cc7ba5c9c78ce' var subdomains = ['0', '1', '2', '3', '4', '5', '6', '7'] const Cesium = window.Cesium Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkOWQ0MGYwMy0yODUwLTQ1YzktOGM4OC02MTMwY2UyZjNlMzQiLCJpZCI6MTY0NTUwLCJpYXQiOjE2OTM4OTU1Mjd9.1cC0sSzyj79LZv0ILNCcl0Mabw6hl8TNngFNFr7H8f4' +// ys使用 +import axios from 'axios' +// md5加密 +import md5 from 'md5' +const imosPlayer = window.imosPlayer + +const iframeObj = null export default { components: { AnquanCfd, @@ -1071,15 +1078,171 @@ export default { iniOne: 0, /* 一公司人员定位 结束*/ - bottomClickDisable: false + bottomClickDisable: false, + + // 宇视视频播放 + dialogVideoYs: true, + ysVideoInfo: { + vmip: '10.30.20.54', + name: 'loadmin', + passwd: '_Ab54321', + vmport: '7010', + linkPort: '8093', + VIIDPort: '8088' + } } }, mounted() { this.initMap() this.pointBoxCfd = loadMapBoxCfd() this.pointBox = loadMapBox() + this.ysVideoInit() }, methods: { + getRandom() { + function S4() { + return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1) + } + return S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4() + }, + // keepalive(token) { + // // 第二套方案 + // requestFN( + // '/map/loginOrKeepAlive', + // { + // } + // ).then((data) => { + // + // }) + // }, + // ysVideoInit() { + // // 第二套方案 + // var _this = this + // requestFN( + // '/map/loginOrKeepAlive', + // { + // } + // ).then((data) => { + // const token = data.token + // var nbsp = String.fromCharCode(160) + // var arr = [] + // arr.length = 40 + // const str = arr.fill(nbsp).join('') + // const voidPath = imosPlayer.getUniqueID() + // window.voidPath = voidPath + // document.title = document.title + str + new Date().getTime() + // _this.keepalive(token) + // setInterval(_this.keepalive, 30000, token) + // console.info('-----------1-------------------') + // window.videoWindow = 0 + // imosPlayer.setLinkPort('8093') + // imosPlayer + // .init({ + // ip: '10.30.20.54', + // token: token, + // title: document.title, + // voidListenerPath: '\\' + voidPath + // }) + // .then(async(resr) => { + // console.info('-----------2-------------------') + // if (resr.ErrCode === 0) { + // console.info('-----------3-------------------') + // // imosPlayer.setLiveNetLinkMode(liveNetProtocol, liveByMS) + // // imosPlayer.setReplayNetLinkMode(replayNetProtocol, replayByMS) + // + // // eslint-disable-next-line no-alert + // console.info('登录成功') + // } else { + // + // console.info('-----------4-------------------') + // // eslint-disable-next-line no-alert + // console.info(resr.ErrMsg) + // } + // }) + // .catch((err) => { + // + // console.info('-----------5-------------------') + // console.error(err) + // }) + // }) + // }, + keepalive(token) { + axios({ + method: 'POST', + url: config.ysurl + '/VIID/hadesadapter/user/keepalive', + headers: { + 'Content-Type': 'application/json; charset=utf8', + Authorization: token + }, + responseType: 'json' + }).then((res) => { }) + }, + ysVideoInit() { + var _this = this + axios({ + method: 'POST', + url: config.ysurl + '/VIID/login/v2', // protocol改为http:// + headers: { + 'Content-Type': 'application/json; charset=utf8' + }, + responseType: 'json' + }).then((res) => { + const AccessCode = res.data.AccessCode// res.body改为res.data + const LoginSignature = md5(btoa(_this.ysVideoInfo.name) + AccessCode + md5(_this.ysVideoInfo.passwd)) + axios({ + method: 'POST', + url: config.ysurl + '/VIID/login/v2', + headers: { + 'Content-Type': 'application/json; charset=utf8' + }, + responseType: 'json', + data: { + UserName: _this.ysVideoInfo.name, + AccessCode, + LoginSignature + } + + }).then((res) => { + var nbsp = String.fromCharCode(160) + var arr = [] + arr.length = 40 + const str = arr.fill(nbsp).join('') + const voidPath = imosPlayer.getUniqueID() + window.voidPath = voidPath + document.title = document.title + str + new Date().getTime() + var token = res.data.AccessToken + window.token = res.data.AccessToken + console.log(res) + _this.keepalive(token) + setInterval(_this.keepalive, 30000, token) + + window.videoWindow = 0 + imosPlayer.setLinkPort('8093') + imosPlayer + .init({ + ip: '10.30.20.54', + token: token, + title: document.title, + voidListenerPath: '\\' + voidPath + }) + .then(async(resr) => { + if (resr.ErrCode === 0) { + // imosPlayer.setLiveNetLinkMode(liveNetProtocol, liveByMS) + // imosPlayer.setReplayNetLinkMode(replayNetProtocol, replayByMS) + + // eslint-disable-next-line no-alert + console.info('登录成功') + } else { + // eslint-disable-next-line no-alert + console.info(resr.ErrMsg) + } + }) + .catch((err) => { + console.error(err) + }) + }) + }) + }, initMap() { viewer = new Cesium.Viewer('cesiumContainer', { // terrainProvider: Cesium.createWorldTerrain() diff --git a/static/config.js b/static/config.js index 486543a..37a691f 100644 --- a/static/config.js +++ b/static/config.js @@ -1,6 +1,6 @@ const config = { weburl: 'http://192.168.0.45:8082/', // 前台地址 - httpurl: 'http://192.168.151.56:8092/', // 后台地址 + httpurl: 'http://192.168.151.43:8092/', // 后台地址 qyurl: 'http://192.168.0.45:8080/', // 企业前台 fileUrl: 'http://192.168.192.201:8991/file/', // 附件服务器地址 publicKey: 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2zCyUYSD0pNrbtaYdvGfHfWoRV+fo/2N9O2PLLz/jZvMkigkq4eAq4JO+Ek0wDHI9WxP6iTSLYCHhIOs9CQTPvyldJFm8riZtQZlBTD8Plkb3rjrgwTqbBi3w3+HKYdkSvGFXJIdSOPbpXnj5BzN8vlVaybs24R/vpUzG9178lwIDAQAB', @@ -12,5 +12,6 @@ const config = { perRealTimeLocUrl: '192.168.210.32:8084/netty/test.io', cfdfileUrl: 'http://60.2.209.238:8991/file', xfgUrl: 'https://skqhdg.porthebei.com:9006/static/qrcode/views/xgf_hgz/index.html', - messageUrl: 'http://192.168.151.56:8082/static/qrcode/views/xgf_hgz/index.html' + messageUrl: 'http://192.168.151.56:8082/static/qrcode/views/xgf_hgz/index.html', + ysurl:'/ysapi' }