<template>
|
<div>
|
<div id="divPlugin" class="plugin"></div>
|
</div>
|
</template>
|
<script>
|
export default {
|
props: {
|
type: ''
|
},
|
data() {
|
return {
|
g_iWndIndex: 0,
|
g_oLocalConfig: null,
|
ERROR_CODE_LOGIN_REPEATLOGIN: 2001,
|
version: 'V3.3.0build20230322',
|
g_szRecordType: "",
|
|
deviceList: [],
|
szDeviceIdentifyList: [],
|
deviceChannel: {},
|
devicePort: {},
|
}
|
},
|
mounted() {
|
this.init()
|
},
|
methods: {
|
init() {
|
let that = this
|
// 初始化插件参数及插入插件
|
WebVideoCtrl.I_InitPlugin({
|
bWndFull: true, //是否支持单窗口双击全屏,默认支持 true:支持 false:不支持
|
iWndowType: 1,
|
cbSelWnd: function (xmlDoc) {
|
this.g_iWndIndex = parseInt($(xmlDoc).find("SelectWnd").eq(0).text(), 10);
|
let szInfo = "当前选择的窗口编号:" + this.g_iWndIndex;
|
console.log(szInfo);
|
},
|
cbDoubleClickWnd: function (iWndIndex, bFullScreen) {
|
var szInfo = "当前放大的窗口编号:" + iWndIndex;
|
if (!bFullScreen) {
|
szInfo = "当前还原的窗口编号:" + iWndIndex;
|
}
|
// showCBInfo(szInfo);
|
},
|
cbEvent: function (iEventType, iParam1, iParam2) {
|
if (2 === iEventType) {// 回放正常结束
|
console.log("窗口" + iParam1 + "回放结束!");
|
} else if (-1 === iEventType) {
|
console.log("设备" + iParam1 + "网络错误!")
|
} else if (3001 === iEventType) {
|
// clickStopRecord(that.g_szRecordType, iParam1);
|
}
|
},
|
cbInitPluginComplete: function () {
|
WebVideoCtrl.I_InsertOBJECTPlugin("divPlugin").then(() => {
|
// 检查插件是否最新
|
WebVideoCtrl.I_CheckPluginVersion().then((bFlag) => {
|
if (bFlag) {
|
console.log("检测到新的插件版本,双击开发包目录里的HCWebSDKPlugin.exe升级!");
|
}
|
});
|
}, () => {
|
console.log("插件初始化失败,请确认是否已安装插件;如果未安装,请双击开发包目录里的HCWebSDKPlugin.exe安装!");
|
});
|
}
|
});
|
|
// 分割窗口
|
setTimeout(function () {
|
that.changeWndNum("3")
|
}, 1000)
|
|
// 获取设备列表
|
this.$http.get(`/iailab-iems-coal-proddisp/hikvision/device/list`, {
|
params: {
|
menuRoute: this.$route.name
|
}
|
}).then(({ data: res }) => {
|
if (res.code !== 0) {
|
return this.$message.error(res.msg)
|
}
|
that.deviceList = res.data
|
// 登录
|
that.szDeviceIdentifyList = []
|
setTimeout(function () {
|
console.log('开始登录')
|
for (let i = 0; i < that.deviceList.length; i ++) {
|
if (i > 9) {
|
return;
|
}
|
let hikDevice = that.deviceList[i]
|
that.clickLogin(hikDevice.ipAddress, hikDevice.httpPort, hikDevice.deviceUsername, hikDevice.devicePassword, i)
|
}
|
}, 1100)
|
}).catch(() => {})
|
},
|
|
// 登录
|
clickLogin(szIP, szPort, szUsername, szPassword, index) {
|
let that = this
|
if ("" === szIP || "" === szPort) {
|
return;
|
}
|
let szDeviceIdentify = szIP + "_" + szPort;
|
WebVideoCtrl.I_Login(szIP, 1, szPort, szUsername, szPassword, {
|
timeout: 3000,
|
success: function (xmlDoc) {
|
that.szDeviceIdentifyList.push(szDeviceIdentify)
|
setTimeout(function () {
|
setTimeout(function () {
|
that.getChannelInfo(szDeviceIdentify);
|
}, 1000);
|
|
that.getDevicePort(szDeviceIdentify);
|
|
// 预览
|
setTimeout(function () {
|
let iRtspPort = that.devicePort[szDeviceIdentify]['iRtspPort'];
|
let iChannelID = that.deviceChannel[szDeviceIdentify][0]['value'];
|
let bZeroChannel = that.deviceChannel[szDeviceIdentify][0]['bZero'];
|
that.clickStartRealPlay(index, "1", szDeviceIdentify, iRtspPort, iChannelID, bZeroChannel)
|
}, 3000);
|
}, 10);
|
},
|
error: function (oError) {
|
if (that.ERROR_CODE_LOGIN_REPEATLOGIN === status) {
|
console.log(" 已登录过!")
|
} else {
|
console.log(" 登录失败!")
|
}
|
}
|
});
|
},
|
|
// 开始预览
|
clickStartRealPlay(iWndIndex, iStreamType, szDeviceIdentify, iRtspPort, iChannelID, bZeroChannel) {
|
let oWndInfo = WebVideoCtrl.I_GetWindowStatus(iWndIndex);
|
if (null == szDeviceIdentify) {
|
return;
|
}
|
let startRealPlay = function () {
|
WebVideoCtrl.I_StartRealPlay(szDeviceIdentify, {
|
iWndIndex: iWndIndex,
|
iStreamType: iStreamType,
|
iChannelID: iChannelID,
|
bZeroChannel: bZeroChannel,
|
success: function () {
|
console.log("开始预览成功!");
|
// showOPInfo(szDeviceIdentify + " " + szInfo);
|
|
},
|
error: function (oError) {
|
console.log(" 开始预览失败!errorCode=" + oError.errorCode + ",errorMsg=" + oError.errorMsg);
|
// showOPInfo(szDeviceIdentify + " 开始预览失败!", oError.errorCode, oError.errorMsg);
|
}
|
});
|
};
|
|
if (oWndInfo != null) {// 已经在播放了,先停止
|
WebVideoCtrl.I_Stop({
|
success: function () {
|
startRealPlay();
|
}
|
});
|
} else {
|
startRealPlay();
|
}
|
},
|
|
// 获取通道
|
getChannelInfo(szDeviceIdentify) {
|
let that = this;
|
let oSel = [];
|
// 模拟通道
|
WebVideoCtrl.I_GetAnalogChannelInfo(szDeviceIdentify, {
|
success: function (xmlDoc) {
|
let oChannels = $(xmlDoc).find("VideoInputChannel");
|
$.each(oChannels, function (i) {
|
let id = $(this).find("id").eq(0).text();
|
let name = $(this).find("name").eq(0).text();
|
if ("" === name) {
|
name = "Camera " + (i < 9 ? "0" + (i + 1) : (i + 1));
|
}
|
oSel.push({
|
value: id,
|
bZero: false,
|
name: name
|
})
|
});
|
console.log(" 获取模拟通道成功!")
|
},
|
error: function (oError) {
|
console.log(" 获取模拟通道失败!")
|
}
|
});
|
// 数字通道
|
WebVideoCtrl.I_GetDigitalChannelInfo(szDeviceIdentify, {
|
success: function (xmlDoc) {
|
let oChannels = $(xmlDoc).find("InputProxyChannelStatus");
|
$.each(oChannels, function (i) {
|
let id = $(this).find("id").eq(0).text();
|
let name = $(this).find("name").eq(0).text();
|
let online = $(this).find("online").eq(0).text();
|
if ("false" === online) {// 过滤禁用的数字通道
|
return true;
|
}
|
if ("" === name) {
|
name = "IPCamera " + (i < 9 ? "0" + (i + 1) : (i + 1));
|
}
|
oSel.push({
|
value: id,
|
bZero: false,
|
name: name
|
})
|
});
|
console.log(" 获取数字通道成功!");
|
},
|
error: function (oError) {
|
console.log(" 获取数字通道失败!");
|
}
|
});
|
// 零通道
|
WebVideoCtrl.I_GetZeroChannelInfo(szDeviceIdentify, {
|
success: function (xmlDoc) {
|
var oChannels = $(xmlDoc).find("ZeroVideoChannel");
|
$.each(oChannels, function (i) {
|
var id = $(this).find("id").eq(0).text(),
|
name = $(this).find("name").eq(0).text();
|
if ("" === name) {
|
name = "Zero Channel " + (i < 9 ? "0" + (i + 1) : (i + 1));
|
}
|
if ("true" === $(this).find("enabled").eq(0).text()) {// 过滤禁用的零通道
|
oSel.push({
|
value: id,
|
bZero: true,
|
name: name
|
})
|
}
|
});
|
console.log(" 获取零通道成功!");
|
},
|
error: function (oError) {
|
console.log(" 获取零通道失败!");
|
}
|
});
|
console.log(JSON.stringify())
|
that.deviceChannel[szDeviceIdentify] = oSel
|
},
|
|
// 获取端口
|
getDevicePort(szDeviceIdentify) {
|
let that = this
|
if (null == szDeviceIdentify) {
|
return;
|
}
|
WebVideoCtrl.I_GetDevicePort(szDeviceIdentify).then((oPort) => {
|
that.devicePort[szDeviceIdentify] = {
|
iDevicePort: oPort.iDevicePort,
|
iRtspPort: oPort.iRtspPort
|
}
|
console.log(" 获取端口成功!")
|
}, (oError) => {
|
console.log("获取端口失败!")
|
});
|
},
|
|
// 窗口分割数
|
changeWndNum(iType) {
|
iType = parseInt(iType, 10);
|
WebVideoCtrl.I_ChangeWndNum(iType).then(() => {
|
console.log("窗口分割成功!")
|
}, (oError) => {
|
console.log("窗口分割失败!");
|
});
|
},
|
|
// 退出
|
logout(szDeviceIdentify) {
|
WebVideoCtrl.I_Logout(szDeviceIdentify).then(() => {
|
console.log("退出成功!")
|
}, () => {
|
console.log("退出失败!")
|
});
|
}
|
},
|
|
watch: {
|
// 监听,当路由发生变化的时候执行
|
$route: {
|
handler: function (val, oldVal) {
|
let that = this
|
window.location.reload()
|
// if (val.path === 'coal-proddisp-monitor-hikvision-device'|| val.path.indexOf('coal-proddisp-monitor') === -1) {
|
// WebVideoCtrl.I_DestroyPlugin()
|
// } else {
|
// this.init()
|
// }
|
// setTimeout(function () {
|
// if (val.path !== 'coal-proddisp-monitor-hikvision-device' && val.path.indexOf('coal-proddisp-monitor') !== -1) {
|
// that.init()
|
// }
|
// }, 500)
|
|
},
|
// 深度观察监听
|
deep: true
|
}
|
},
|
}
|
</script>
|
<style scoped>
|
.video-content {
|
height: 350px;
|
background-color: #cccccc;
|
border-radius: 2px;
|
}
|
|
.video-title {
|
background-color: #FFFFFF;
|
height: 50px;
|
font-size: 14px;
|
padding: 10px;
|
display: flex;
|
flex-direction: row;
|
flex-wrap: wrap;
|
justify-content: flex-start;
|
align-content: flex-start;
|
}
|
|
.title-text {
|
padding-top: 5px;
|
width: 70%;
|
}
|
|
.title-status {
|
width: 30%;
|
}
|
|
.video-show {
|
height: 400px;
|
background-color: #FFFFFF;
|
margin: 5px;
|
}
|
|
.left {
|
float: left;
|
}
|
|
.freeze {
|
position: absolute;
|
text-align: center;
|
background: #343434;
|
color: #FFFFFF;
|
font-size: 26px;
|
font-weight: bold;
|
filter: alpha(opacity=60);
|
opacity: 0.6;
|
}
|
|
.vtop {
|
vertical-align: middle;
|
margin-top: -1px;
|
}
|
|
/*插件*/
|
.plugin {
|
width: 100%;
|
height: 45vw;
|
/*width: 500px;
|
height: 300px;*/
|
}
|
|
fieldset {
|
display: block;
|
}
|
|
/*本地配置*/
|
.localconfig {
|
width: 480px;
|
padding: 10px;
|
border: 1px solid #7F9DB9;
|
}
|
|
.localconfig .tt {
|
width: 125px;
|
}
|
|
.localconfig .txt {
|
width: 310px;
|
}
|
|
.localconfig .txt2 {
|
width: 300px;
|
}
|
|
.localconfig .btn {
|
width: 45px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.localconfig .sel {
|
width: 120px;
|
}
|
|
/*登录*/
|
.login {
|
width: 480px;
|
padding: 10px;
|
border: 1px solid #7F9DB9;
|
}
|
|
.login .tt {
|
width: 100px;
|
}
|
|
.login .txt {
|
width: 130px;
|
}
|
|
.login .btn {
|
width: 45px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.login .btn2 {
|
width: 100px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.login .sel {
|
width: 130px;
|
}
|
|
.login .sel2 {
|
width: 65px;
|
}
|
|
/*数字通道*/
|
.ipchannel {
|
width: 480px;
|
padding: 10px;
|
border: 1px solid #7F9DB9;
|
}
|
|
.ipchannel .btn {
|
width: 130px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.ipchannel .digitaltdiv {
|
height: 100px;
|
overflow: hidden;
|
overflow-y: auto;
|
border: 1px solid #7F9DB9;
|
font-size: 11px;
|
}
|
|
.ipchannel .digitalchannellist th, .ipchannel .digitalchannellist td {
|
padding: 2px;
|
border: 1px solid #7F9DB9;
|
border-collapse: collapse;
|
white-space: nowrap;
|
}
|
|
/*预览*/
|
.preview {
|
width: 450px;
|
padding: 10px;
|
padding-top: 0;
|
margin-left: 10px;
|
border: 1px solid #7F9DB9;
|
}
|
|
.preview .tt {
|
width: 60px;
|
}
|
|
.preview .txt {
|
width: 30px;
|
}
|
|
.preview .btn {
|
width: 70px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.preview .btn2 {
|
width: 90px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.preview .sel {
|
width: 105px;
|
}
|
|
/*云台*/
|
.ptz {
|
width: 450px;
|
padding: 10px;
|
margin-left: 10px;
|
border: 1px solid #7F9DB9;
|
}
|
|
.ptz .tt {
|
width: 60px;
|
}
|
|
.ptz .txt {
|
width: 60px;
|
}
|
|
.ptz .btn {
|
width: 45px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.ptz .btn2 {
|
width: 60px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.ptz .sel {
|
width: 65px;
|
}
|
|
/*视频参数*/
|
.videoparam {
|
width: 450px;
|
padding: 10px;
|
margin-left: 10px;
|
border: 1px solid #7F9DB9;
|
}
|
|
.videoparam .tt {
|
width: 60px;
|
}
|
|
.videoparam .txt {
|
width: 60px;
|
}
|
|
.videoparam .btn {
|
width: 45px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.videoparam .sel {
|
width: 65px;
|
}
|
|
/*回放*/
|
.playback {
|
width: 450px;
|
padding: 10px;
|
margin-left: 10px;
|
border: 1px solid #7F9DB9;
|
}
|
|
.playback .tt {
|
width: 60px;
|
}
|
|
.playback .txt {
|
width: 140px;
|
}
|
|
.playback .btn {
|
min-width: 45px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.playback .btn2 {
|
width: 70px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.playback .sel {
|
width: 142px;
|
}
|
|
.playback .searchdiv {
|
height: 100px;
|
overflow: hidden;
|
overflow-y: auto;
|
border: 1px solid #7F9DB9;
|
font-size: 11px;
|
}
|
|
.playback .searchlist th, .playback .searchlist td {
|
padding: 2px;
|
border: 1px solid #7F9DB9;
|
border-collapse: collapse;
|
white-space: nowrap;
|
}
|
|
/*系统维护*/
|
.maintain {
|
width: 450px;
|
padding: 10px;
|
margin-left: 10px;
|
border: 1px solid #7F9DB9;
|
}
|
|
.maintain .tt {
|
width: 60px;
|
}
|
|
.maintain .txt {
|
width: 280px;
|
}
|
|
.maintain .btn {
|
width: 45px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.maintain .btn2 {
|
width: 100px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.maintain .sel {
|
width: 65px;
|
}
|
|
/*操作信息*/
|
.operate {
|
width: 450px;
|
padding: 10px;
|
margin-left: 10px;
|
border: 1px solid #7F9DB9;
|
}
|
|
.operate .opinfo {
|
height: 150px;
|
border: 1px solid #7F9DB9;
|
overflow: auto;
|
}
|
|
/*事件回调*/
|
.callback {
|
width: 450px;
|
padding: 10px;
|
margin-left: 10px;
|
border: 1px solid #7F9DB9;
|
}
|
|
.callback .cbinfo {
|
height: 114px;
|
border: 1px solid #7F9DB9;
|
overflow: auto;
|
}
|
|
/*IP解析*/
|
.ipparse {
|
width: 450px;
|
padding: 10px;
|
margin-left: 10px;
|
border: 1px solid #7F9DB9;
|
}
|
|
.ipparse .tt {
|
width: 85px;
|
}
|
|
.ipparse .txt {
|
width: 130px;
|
}
|
|
.ipparse .btn {
|
width: 90px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.ipparse .sel {
|
width: 130px;
|
}
|
|
/*绘图*/
|
.draw {
|
width: 450px;
|
padding: 10px;
|
padding-top: 0;
|
margin-left: 10px;
|
border: 1px solid #7F9DB9;
|
}
|
|
.draw .tt {
|
width: 60px;
|
}
|
|
.draw .txt {
|
width: 140px;
|
}
|
|
.draw .btn {
|
width: 70px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.draw .btn2 {
|
width: 100px;
|
height: 22px;
|
line-height: 18px;
|
}
|
|
.draw .sel {
|
width: 105px;
|
}
|
|
</style>
|