fajiao
2 years ago
13 changed files with 720 additions and 35 deletions
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 26 KiB |
@ -1,6 +1,5 @@ |
|||||
export const apiUrl = { |
export const apiUrl = { |
||||
CisApiUrl: 'http://192.168.1.119:5000/api', |
CisApiUrl: 'http://192.168.1.119:5000/api', |
||||
WebRtcUrl: 'http://192.168.1.119:8000', |
WebRtcUrl: 'http://192.168.1.119:8000', |
||||
OnvifApiUrl: '' |
OnvifApiUrl: '', |
||||
// CisApiUrl: 'https://192.168.1.119:5001/api'
|
|
||||
} |
} |
||||
|
@ -0,0 +1,154 @@ |
|||||
|
import axios from "axios"; |
||||
|
import exp from "constants"; |
||||
|
|
||||
|
// 视频点播、云台各种控制、录像回放和下载,主要就是这些接口,后面缺的再加就行
|
||||
|
// Ip : 113.200.190.167
|
||||
|
// username : liusuo
|
||||
|
// passwd : MapMap123
|
||||
|
|
||||
|
const service = axios.create({ |
||||
|
baseURL: '/', // api base_url
|
||||
|
timeout: 9000, // 请求超时时间
|
||||
|
}); |
||||
|
|
||||
|
service.interceptors.request.use( |
||||
|
request => { |
||||
|
// 处理 axios get请求特殊字符编码问题
|
||||
|
if (request.method === 'get' && request.params) { |
||||
|
let url: string = request.url || ''; |
||||
|
url += '?'; |
||||
|
let keys = Object.keys(request.params); |
||||
|
for (let key of keys) { |
||||
|
url += `${key}=${encodeURIComponent(request.params[key])}&`; |
||||
|
} |
||||
|
// url = url.substring(0, url.length - 1);
|
||||
|
request.url = url |
||||
|
request.params = {} |
||||
|
} |
||||
|
// 带上 token
|
||||
|
let viidToken = GetViidToken(); |
||||
|
if (!!viidToken) { |
||||
|
request.headers!.Authorization = viidToken; |
||||
|
} |
||||
|
return request; |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
service.interceptors.response.use( |
||||
|
response => { |
||||
|
console.log(response); |
||||
|
if (response.status === 200 && (!response.data.ErrCode || response.data.ErrCode === 0)) { |
||||
|
return response.data; |
||||
|
} else { |
||||
|
console.error(response.data); |
||||
|
return Promise.reject(new Error(response.data)); |
||||
|
} |
||||
|
}, |
||||
|
error => { |
||||
|
console.error(error); |
||||
|
return Promise.reject(error); |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
const apiUrl = { |
||||
|
YuShiApiUrl: 'http://113.200.190.167:8088/VIID', |
||||
|
YuShiVmUrl: 'http://113.200.190.167:7010/VIID', |
||||
|
} |
||||
|
export const vmIp="113.200.190.167" |
||||
|
export const username = "liusuo"; |
||||
|
export const passwd = "MapMap123"; |
||||
|
|
||||
|
enum ApiName { |
||||
|
Login = '/login', |
||||
|
KeepAlive = '/token/alive/keep', |
||||
|
Logout = '/logout', |
||||
|
LoginV2 = '/login/v2', |
||||
|
KeepAliveV2 = '/hadesadapter/user/keepalive', |
||||
|
Query = '/query', |
||||
|
QueryOrg = '/org/query/list', |
||||
|
PtzCtrl = '/ptz/ctrl' |
||||
|
} |
||||
|
|
||||
|
const baseUrl = apiUrl.YuShiApiUrl; |
||||
|
const vmUrl = apiUrl.YuShiVmUrl; |
||||
|
|
||||
|
let viidToken = '', vmToken = ''; |
||||
|
|
||||
|
export const GetViidToken = () => { |
||||
|
return viidToken; |
||||
|
} |
||||
|
|
||||
|
export const SetViidToken = (token: string) => { |
||||
|
viidToken = token; |
||||
|
} |
||||
|
|
||||
|
export const GetVmToken = () => { |
||||
|
return vmToken; |
||||
|
} |
||||
|
|
||||
|
export const SetVmToken = (token: string) => { |
||||
|
vmToken = token; |
||||
|
} |
||||
|
|
||||
|
export const Login = (params?: any) => service.post(baseUrl + ApiName.Login, params) |
||||
|
|
||||
|
export const KeepAlive = (params?: any) => service.post(baseUrl + ApiName.KeepAlive, params) |
||||
|
|
||||
|
export const Logout = (params?: any) => service.post(baseUrl + ApiName.Logout, params) |
||||
|
|
||||
|
export const LoginV2 = (params?: any) => service.post(baseUrl + ApiName.LoginV2, params) |
||||
|
|
||||
|
export const KeepAliveV2 = (params?: any) => service.post(baseUrl + ApiName.KeepAliveV2, params) |
||||
|
|
||||
|
export const Query = (params: any) => service.get(baseUrl + ApiName.Query, {params: params}) |
||||
|
|
||||
|
export const QueryOrg = (params: any) => service.get(baseUrl + ApiName.QueryOrg + `/${params.id}`, params.condition) |
||||
|
|
||||
|
export const PtzCtrl = (params: any) => service.post(baseUrl + ApiName.PtzCtrl+ `/${params.code}`, params) |
||||
|
|
||||
|
/** |
||||
|
* 发送云台控制指令 |
||||
|
* PTZCmdID { |
||||
|
* 转向中上 1026 开始 1025 停止 |
||||
|
* 转向右上 2050 开始 2049 停止 |
||||
|
* 转向右中 1282 开始 1281 停止 |
||||
|
* 转向右下 2052 开始 2051 停止 |
||||
|
* 转向中下 1028 开始 1027 停止 |
||||
|
* 转向左下 1796 开始 1795 停止 |
||||
|
* 转向左中 1284 开始 1283 停止 |
||||
|
* 转向左上 1794 开始 1793 停止 |
||||
|
* 变倍放大 770 开始 769 停止 |
||||
|
* 变倍缩小 772 开始 771 停止 |
||||
|
* 对焦放大 516 开始 515 停止 |
||||
|
* 对焦缩小 514 开始 513 停止 |
||||
|
* } |
||||
|
*/ |
||||
|
export enum PtzCmdId { |
||||
|
Up = 0x0402, |
||||
|
UpStop = 0x0401, |
||||
|
Down = 0x0404, |
||||
|
DownStop = 0x0403, |
||||
|
Left = 0x0504, |
||||
|
LeftStop = 0x0503, |
||||
|
Right = 0x0502, |
||||
|
RightStop = 0x0501, |
||||
|
LeftUp = 0x0702, |
||||
|
LeftUpStop = 0x0701, |
||||
|
LeftDown = 0x0704, |
||||
|
LeftDownStop = 0x0703, |
||||
|
RightUp = 0x0802, |
||||
|
RightUpStop = 0x0801, |
||||
|
RightDown = 0x0804, |
||||
|
RightDownStop = 0x0803, |
||||
|
ZoomIn = 0x0302, |
||||
|
ZoomInStop = 0x0301, |
||||
|
ZoomOut = 0x0304, |
||||
|
ZoomOutStop = 0x0303, |
||||
|
FocusZoomIn = 0x0204, |
||||
|
FocusZoomInStop = 0x0203, |
||||
|
FocusZoomOut = 0x0202, |
||||
|
FocusZoomOutStop = 0x0201, |
||||
|
AllStop = 0x0901 |
||||
|
} |
||||
|
|
||||
|
// export const Get = (params?: any) => axios.get(baseUrl + Api.Get, {params: params})
|
@ -0,0 +1,258 @@ |
|||||
|
let base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
||||
|
let base64DecodeChars = new Array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1); |
||||
|
|
||||
|
/** |
||||
|
* base64编码 |
||||
|
* @param {string} str 需要编码的字符串 |
||||
|
*/ |
||||
|
export function base64encode(str: string) { |
||||
|
let out, i, len; |
||||
|
let c1, c2, c3; |
||||
|
len = str.length; |
||||
|
i = 0; |
||||
|
out = ""; |
||||
|
while (i < len) { |
||||
|
c1 = str.charCodeAt(i++) & 0xff; |
||||
|
if (i == len) { |
||||
|
out += base64EncodeChars.charAt(c1 >> 2); |
||||
|
out += base64EncodeChars.charAt((c1 & 0x3) << 4); |
||||
|
out += "=="; |
||||
|
break; |
||||
|
} |
||||
|
c2 = str.charCodeAt(i++); |
||||
|
if (i == len) { |
||||
|
out += base64EncodeChars.charAt(c1 >> 2); |
||||
|
out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); |
||||
|
out += base64EncodeChars.charAt((c2 & 0xF) << 2); |
||||
|
out += "="; |
||||
|
break; |
||||
|
} |
||||
|
c3 = str.charCodeAt(i++); |
||||
|
out += base64EncodeChars.charAt(c1 >> 2); |
||||
|
out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); |
||||
|
out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6)); |
||||
|
out += base64EncodeChars.charAt(c3 & 0x3F); |
||||
|
} |
||||
|
return out; |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message |
||||
|
* Digest Algorithm, as defined in RFC 1321. |
||||
|
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. |
||||
|
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet |
||||
|
* Distributed under the BSD License |
||||
|
* See http://pajhome.org.uk/crypt/md5 for more info.
|
||||
|
*/ |
||||
|
/* |
||||
|
* Configurable variables. You may need to tweak these to be compatible with |
||||
|
* the server-side, but the defaults work in most cases. |
||||
|
*/ |
||||
|
let hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ |
||||
|
let b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ |
||||
|
let chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ |
||||
|
|
||||
|
/* |
||||
|
* These are the functions you'll usually want to call |
||||
|
* They take string arguments and return either hex or base-64 encoded strings |
||||
|
*/ |
||||
|
export function hex_md5(s: string) { |
||||
|
return binl2hex(core_md5(str2binl(s), s.length * chrsz)); |
||||
|
} |
||||
|
|
||||
|
function b64_md5(s: string) { |
||||
|
return binl2b64(core_md5(str2binl(s), s.length * chrsz)); |
||||
|
} |
||||
|
|
||||
|
function str_md5(s: string) { |
||||
|
return binl2str(core_md5(str2binl(s), s.length * chrsz)); |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* Perform a simple self-test to see if the VM is working |
||||
|
*/ |
||||
|
function md5_vm_test() { |
||||
|
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* Calculate the MD5 of an array of little-endian words, and a bit length |
||||
|
*/ |
||||
|
function core_md5(x: any[], len: number) { |
||||
|
/* append padding */ |
||||
|
x[len >> 5] |= 0x80 << ((len) % 32); |
||||
|
x[(((len + 64) >>> 9) << 4) + 14] = len; |
||||
|
let a = 1732584193; |
||||
|
let b = -271733879; |
||||
|
let c = -1732584194; |
||||
|
let d = 271733878; |
||||
|
for (let i = 0; i < x.length; i += 16) { |
||||
|
let olda = a; |
||||
|
let oldb = b; |
||||
|
let oldc = c; |
||||
|
let oldd = d; |
||||
|
a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936); |
||||
|
d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586); |
||||
|
c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819); |
||||
|
b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330); |
||||
|
a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897); |
||||
|
d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426); |
||||
|
c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341); |
||||
|
b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983); |
||||
|
a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416); |
||||
|
d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417); |
||||
|
c = md5_ff(c, d, a, b, x[i + 10], 17, -42063); |
||||
|
b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162); |
||||
|
a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682); |
||||
|
d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101); |
||||
|
c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290); |
||||
|
b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329); |
||||
|
a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510); |
||||
|
d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632); |
||||
|
c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713); |
||||
|
b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302); |
||||
|
a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691); |
||||
|
d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083); |
||||
|
c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335); |
||||
|
b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848); |
||||
|
a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438); |
||||
|
d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690); |
||||
|
c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961); |
||||
|
b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501); |
||||
|
a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467); |
||||
|
d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784); |
||||
|
c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473); |
||||
|
b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734); |
||||
|
a = md5_hh(a, b, c, d, x[i + 5], 4, -378558); |
||||
|
d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463); |
||||
|
c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562); |
||||
|
b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556); |
||||
|
a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060); |
||||
|
d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353); |
||||
|
c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632); |
||||
|
b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640); |
||||
|
a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174); |
||||
|
d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222); |
||||
|
c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979); |
||||
|
b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189); |
||||
|
a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487); |
||||
|
d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835); |
||||
|
c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520); |
||||
|
b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651); |
||||
|
a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844); |
||||
|
d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415); |
||||
|
c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905); |
||||
|
b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055); |
||||
|
a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571); |
||||
|
d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606); |
||||
|
c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523); |
||||
|
b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799); |
||||
|
a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359); |
||||
|
d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744); |
||||
|
c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380); |
||||
|
b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649); |
||||
|
a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070); |
||||
|
d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379); |
||||
|
c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259); |
||||
|
b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551); |
||||
|
a = safe_add(a, olda); |
||||
|
b = safe_add(b, oldb); |
||||
|
c = safe_add(c, oldc); |
||||
|
d = safe_add(d, oldd); |
||||
|
} |
||||
|
return Array(a, b, c, d); |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* These functions implement the four basic operations the algorithm uses. |
||||
|
*/ |
||||
|
function md5_cmn(q: number, a: number, b: number, x: number, s: number, t: number) { |
||||
|
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b); |
||||
|
} |
||||
|
|
||||
|
function md5_ff(a: number, b: number, c: number, d: number, x: number, s: number, t: number) { |
||||
|
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); |
||||
|
} |
||||
|
|
||||
|
function md5_gg(a: number, b: number, c: number, d: number, x: number, s: number, t: number) { |
||||
|
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); |
||||
|
} |
||||
|
|
||||
|
function md5_hh(a: number, b: number, c: number, d: number, x: number, s: number, t: number) { |
||||
|
return md5_cmn(b ^ c ^ d, a, b, x, s, t); |
||||
|
} |
||||
|
|
||||
|
function md5_ii(a: number, b: number, c: number, d: number, x: number, s: number, t: number) { |
||||
|
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* Add integers, wrapping at 2^32. This uses 16-bit operations internally |
||||
|
* to work around bugs in some JS interpreters. |
||||
|
*/ |
||||
|
function safe_add(x: number, y: number) { |
||||
|
let lsw = (x & 0xFFFF) + (y & 0xFFFF); |
||||
|
let msw = (x >> 16) + (y >> 16) + (lsw >> 16); |
||||
|
return (msw << 16) | (lsw & 0xFFFF); |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* Bitwise rotate a 32-bit number to the left. |
||||
|
*/ |
||||
|
function bit_rol(num: number, cnt: number) { |
||||
|
return (num << cnt) | (num >>> (32 - cnt)); |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* Convert a string to an array of little-endian words |
||||
|
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored. |
||||
|
*/ |
||||
|
function str2binl(str: string) { |
||||
|
let bin = Array(); |
||||
|
let mask = (1 << chrsz) - 1; |
||||
|
for (let i = 0; i < str.length * chrsz; i += chrsz) |
||||
|
bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << (i % 32); |
||||
|
return bin; |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* Convert an array of little-endian words to a string |
||||
|
*/ |
||||
|
function binl2str(bin: any) { |
||||
|
let str = ""; |
||||
|
let mask = (1 << chrsz) - 1; |
||||
|
for (let i = 0; i < bin.length * 32; i += chrsz) |
||||
|
str += String.fromCharCode((bin[i >> 5] >>> (i % 32)) & mask); |
||||
|
return str; |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* Convert an array of little-endian words to a hex string. |
||||
|
*/ |
||||
|
function binl2hex(binarray: any) { |
||||
|
let hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; |
||||
|
let str = ""; |
||||
|
for (let i = 0; i < binarray.length * 4; i++) { |
||||
|
str += hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8 + 4)) & 0xF) + |
||||
|
hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 0xF); |
||||
|
} |
||||
|
return str; |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* Convert an array of little-endian words to a base-64 string |
||||
|
*/ |
||||
|
function binl2b64(binarray: any) { |
||||
|
let tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
||||
|
let str = ""; |
||||
|
for (let i = 0; i < binarray.length * 4; i += 3) { |
||||
|
let triplet = (((binarray[i >> 2] >> 8 * (i % 4)) & 0xFF) << 16) |
||||
|
| (((binarray[i + 1 >> 2] >> 8 * ((i + 1) % 4)) & 0xFF) << 8) |
||||
|
| ((binarray[i + 2 >> 2] >> 8 * ((i + 2) % 4)) & 0xFF); |
||||
|
for (let j = 0; j < 4; j++) { |
||||
|
if (i * 8 + j * 6 > binarray.length * 32) str += b64pad; |
||||
|
else str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F); |
||||
|
} |
||||
|
} |
||||
|
return str; |
||||
|
} |
@ -1,12 +1,25 @@ |
|||||
import axios from "axios"; |
import axios from "axios"; |
||||
|
|
||||
let apiBaseUrl = "/api"; |
|
||||
|
|
||||
const service = axios.create({ |
const service = axios.create({ |
||||
baseURL: apiBaseUrl, // api base_url
|
baseURL: '', // api base_url
|
||||
timeout: 9000, // 请求超时时间
|
timeout: 9000, // 请求超时时间
|
||||
}); |
}); |
||||
|
|
||||
|
service.interceptors.response.use( |
||||
|
response => { |
||||
|
if (response.data.success) { |
||||
|
return response.data; |
||||
|
} else { |
||||
|
console.error(response.data.message); |
||||
|
return Promise.reject(new Error(response.data.message)); |
||||
|
} |
||||
|
}, |
||||
|
error => { |
||||
|
console.error(error.message); |
||||
|
return Promise.reject(error); |
||||
|
} |
||||
|
) |
||||
|
|
||||
export { |
export { |
||||
service as axios, |
service as axios, |
||||
} |
} |
@ -0,0 +1,252 @@ |
|||||
|
<template> |
||||
|
<button @click="test">test</button> |
||||
|
<br> |
||||
|
<br> |
||||
|
<button @click="login">Login</button> |
||||
|
<br> |
||||
|
<br> |
||||
|
<button @click="loginV2">LoginV2</button> |
||||
|
<br> |
||||
|
<br> |
||||
|
<button @click="getOrgs">GetOrgs</button> |
||||
|
<br> |
||||
|
<br> |
||||
|
<button @click="getCameras">GetCameras</button> |
||||
|
<br> |
||||
|
<br> |
||||
|
<div> |
||||
|
<span>摄像机编码:</span><input type="text" id="cameraCode" value="61010000001310000001"/> |
||||
|
</div> |
||||
|
<br> |
||||
|
<button @click="creatVideoPanel">CreatVideoPanel</button> |
||||
|
<br> |
||||
|
<br> |
||||
|
<div> |
||||
|
<h2>发送云台控制指令</h2> |
||||
|
<div> |
||||
|
<p><span>云台命令:</span><input type="text" id="ptzCode" value="0x0402"/></p> |
||||
|
<p><span>云台转速(1~9):</span><input type="text" id="ptzSpeed" value="5"/></p> |
||||
|
<button @click="ptzControl">PtzControl</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
<br> |
||||
|
<br> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import {defineComponent, ref} from 'vue'; |
||||
|
import * as ysApi from '@/api/yushi/yushiApi'; |
||||
|
import * as ysHelper from '@api/yushi/yushiHelper' |
||||
|
import qs from "qs"; |
||||
|
|
||||
|
let username = ysApi.username; |
||||
|
let passwd = ysApi.passwd; |
||||
|
|
||||
|
export default defineComponent({ |
||||
|
data() { |
||||
|
return {}; |
||||
|
}, |
||||
|
mounted() { |
||||
|
window.playLive = (iframeId) => { |
||||
|
this.playLive(iframeId); |
||||
|
} |
||||
|
window.stopPlay = (iframeId) => { |
||||
|
this.stopPlay(iframeId); |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
test() { |
||||
|
let loginSignature = ysHelper.hex_md5(ysHelper.base64encode(username)); |
||||
|
console.log(loginSignature); |
||||
|
}, |
||||
|
login() { |
||||
|
if (!!ysApi.GetViidToken()) return; |
||||
|
ysApi.Login().then((data) => { |
||||
|
console.log(data); |
||||
|
let accessCode = data.AccessCode; |
||||
|
let loginSignature = ysHelper.hex_md5(ysHelper.base64encode(username) + accessCode + ysHelper.hex_md5(passwd)); |
||||
|
let params = { |
||||
|
UserName: username, |
||||
|
AccessCode: accessCode, |
||||
|
LoginSignature: loginSignature |
||||
|
} |
||||
|
ysApi.Login(params).then((data) => { |
||||
|
console.log(data); |
||||
|
let accessToken = data.AccessToken; |
||||
|
ysApi.SetViidToken(accessToken); |
||||
|
}); |
||||
|
}); |
||||
|
}, |
||||
|
loginV2() { |
||||
|
if (!!ysApi.GetViidToken()) return; |
||||
|
ysApi.LoginV2().then((data) => { |
||||
|
console.log(data); |
||||
|
let accessCode = data.AccessCode; |
||||
|
let loginSignature = ysHelper.hex_md5(ysHelper.base64encode(username) + accessCode + ysHelper.hex_md5(passwd)); |
||||
|
let params = { |
||||
|
UserName: username, |
||||
|
AccessCode: accessCode, |
||||
|
LoginSignature: loginSignature |
||||
|
} |
||||
|
ysApi.LoginV2(params).then((data) => { |
||||
|
console.log(data); |
||||
|
let accessToken = data.AccessToken; |
||||
|
ysApi.SetViidToken(accessToken); |
||||
|
ysApi.SetVmToken(accessToken); |
||||
|
this.initImosSdk(); |
||||
|
}); |
||||
|
}); |
||||
|
}, |
||||
|
initImosSdk() { |
||||
|
//在使用https 的时候设置为https 代理端口号 |
||||
|
let isHttps = "https:" === document.location.protocol; |
||||
|
if (isHttps) imosSdk.setLinkPort("7077"); |
||||
|
imosSdk.init( |
||||
|
ysApi.vmIp,//VMip地址 |
||||
|
ysApi.GetVmToken(),//登录VIID所返回的token值 |
||||
|
16,//最多允许同时播放窗格数,最大值16 |
||||
|
"/app/imosSdk.html",//回调页面的绝对url路径 |
||||
|
true,//是否自动保活,默认为true:自动保活。B3351P01及以后版本建议此处填写false,通过2.1.3保活接口进行手动保活。 |
||||
|
).then(function (res) { |
||||
|
alert("登录成功"); |
||||
|
//设置后续事件回调 |
||||
|
imosSdk.registerLiveMsg((result) => { |
||||
|
console.log(result) |
||||
|
}) |
||||
|
|
||||
|
}).catch(function (err) { |
||||
|
console.log(err); |
||||
|
alert("调用失败" + err); |
||||
|
}); |
||||
|
}, |
||||
|
getOrgs() { |
||||
|
let params = { |
||||
|
id: "iccsid", |
||||
|
condition: JSON.stringify({ |
||||
|
"ItemNum": 1, |
||||
|
"Condition": [{ |
||||
|
"QueryType": 1, |
||||
|
"LogicFlag": 5, |
||||
|
"QueryData": "" |
||||
|
}], |
||||
|
QueryCount: 1, |
||||
|
PageFirstRowNumber: 0, |
||||
|
PageRowNum: 30 |
||||
|
}) |
||||
|
}; |
||||
|
ysApi.QueryOrg(params).then((data) => { |
||||
|
console.log(data); |
||||
|
// ResStatus, 资源状态(1为在线,2为离线,0为不可用) |
||||
|
}); |
||||
|
}, |
||||
|
getCameras() { |
||||
|
let params = { |
||||
|
org: "iccsid", //非必填,如果不填默认查本域 iccsid |
||||
|
condition: JSON.stringify({ |
||||
|
ItemNum: 3, |
||||
|
Condition: [{ |
||||
|
"QueryType": 256, |
||||
|
"LogicFlag": 0, |
||||
|
"QueryData": "1001" |
||||
|
}, { |
||||
|
"QueryType": 257, |
||||
|
"LogicFlag": 0, |
||||
|
"QueryData": "1"//"0":不查子组织、"1":查子组织 |
||||
|
}, { |
||||
|
"QueryType": 1, |
||||
|
"LogicFlag": 5,//0: 等于, 1: 大于, 2: 小于, 3: 大于等于, 4: 小于等于, 5: 模糊查询, 6: 升序, 7: 降序, 8: 不等于, 13: NOT LIKE |
||||
|
"QueryData": "" |
||||
|
}], |
||||
|
QueryCount: 1, |
||||
|
PageFirstRowNumber: 0, |
||||
|
PageRowNum: 30 |
||||
|
}) |
||||
|
}; |
||||
|
ysApi.Query(params).then((data) => { |
||||
|
console.log(data); |
||||
|
}); |
||||
|
}, |
||||
|
ptzControl() { |
||||
|
let cameraCode = document.getElementById("cameraCode").value; |
||||
|
let params = { |
||||
|
code: cameraCode, |
||||
|
PTZCmdID: ysApi.PtzCmdId.Left, |
||||
|
PTZCmdPara1: 3, |
||||
|
PTZCmdPara2: 3, |
||||
|
PTZCmdPara3: 0 |
||||
|
} |
||||
|
ysApi.PtzCtrl(params).then((data) => { |
||||
|
console.log(data); |
||||
|
setTimeout(function () { |
||||
|
params.PTZCmdID = ysApi.PtzCmdId.AllStop; |
||||
|
ysApi.PtzCtrl(params).then((data) => { |
||||
|
|
||||
|
}); |
||||
|
}, 3000); |
||||
|
}) |
||||
|
}, |
||||
|
creatVideoPanel() { |
||||
|
let iframeObj = imosSdk.createPanelWindow(); |
||||
|
// 如果窗格创建已经到达上限 |
||||
|
if (iframeObj === null) { |
||||
|
alert("窗格创建已经到达上限"); |
||||
|
return; |
||||
|
} |
||||
|
this.createVideoDiv(iframeObj); |
||||
|
}, |
||||
|
createVideoDiv(iframeObj) { |
||||
|
let divDom = document.createElement("div"); |
||||
|
let date = new Date(); |
||||
|
divDom.innerHTML = |
||||
|
"<button onclick=\"playLive('" + |
||||
|
iframeObj.id + |
||||
|
'\')">播放实况</button>' + |
||||
|
"<button onclick=\"stopPlay('" + |
||||
|
iframeObj.id + |
||||
|
"')\">停止播放</button></p>" + |
||||
|
'<p><input id="startd' + |
||||
|
iframeObj.id + |
||||
|
'" type="date" value="' + date.getFullYear() + '-' + ("0" + (date.getMonth() + 1)).substr(-2) + '-' + ("0" + date.getDate()).substr(-2) + '"/>' + |
||||
|
'<input id="startt' + |
||||
|
iframeObj.id + |
||||
|
'" type="time" value="01:00:00" step="1"/>' + |
||||
|
'<input id="endd' + |
||||
|
iframeObj.id + |
||||
|
'" type="date" value="' + date.getFullYear() + '-' + ("0" + (date.getMonth() + 1)).substr(-2) + '-' + ("0" + date.getDate()).substr(-2) + '" step="1"/>' + |
||||
|
'<input id="endt' + |
||||
|
iframeObj.id + |
||||
|
'" type="time" value="23:59:59" step="1"/></p>' + |
||||
|
"<p><button onclick=\"replay('" + |
||||
|
iframeObj.id + |
||||
|
')" >播放回放</button>' + |
||||
|
'<button onclick="continuePlay(\'' + iframeObj.id + '\')">播放</button>' + |
||||
|
'<button onclick="pausePlay(\'' + iframeObj.id + '\')">暂停</button>' + |
||||
|
'<button onclick="playSpeed(\'' + iframeObj.id + '\')" id="' + iframeObj.id + '-speed">切换到2倍速</button>' + |
||||
|
'<button onclick="singleFrame(\'' + iframeObj.id + '\')">单帧</button>' + |
||||
|
'<button onclick="stepFrame(\'' + iframeObj.id + '\')">逐帧</button>' + |
||||
|
'<button onclick="playcatch(\'' + iframeObj.id + '\')">抓拍</button></p>' + |
||||
|
'<p><button onclick="addTitleBtn(\'' + iframeObj.id + '\')">增加自定义标题按钮</button>' + |
||||
|
'<button onclick="delTitleBtn(\'' + iframeObj.id + '\')">删除标题按钮</button></p>' + |
||||
|
'</p>' + |
||||
|
'<p><button onclick="playStatus(\'' + iframeObj.id + '\')">状态输出到控制台</button>' + |
||||
|
'<input type="text" value="2020-04-03 13:30:00" id="recordJump"/>' + |
||||
|
'<button onclick="recordJump(\'' + iframeObj.id + '\')">跳转播放</button></p>'; |
||||
|
divDom.appendChild(iframeObj); |
||||
|
document.body.appendChild(divDom); |
||||
|
this.playLive(iframeObj.id); |
||||
|
}, |
||||
|
playLive(iframeId) { |
||||
|
let cameraCode = document.getElementById("cameraCode").value; |
||||
|
imosSdk.playLive(iframeId, cameraCode, cameraCode, (e) => { |
||||
|
console.log(e); |
||||
|
}); |
||||
|
}, |
||||
|
stopPlay(iframeId){ |
||||
|
imosSdk.playStop(iframeId, (e) => { |
||||
|
console.log(e); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
</script> |
Loading…
Reference in new issue