Browse Source

yushi A8 api

master
fajiao 2 years ago
parent
commit
73e7257d12
  1. 114
      Frontend/src/api/yushi/yushiApi.ts
  2. 47
      Frontend/src/views/page/yushi.vue

114
Frontend/src/api/yushi/yushiApi.ts

@ -1,11 +1,18 @@
import axios from "axios";
import exp from "constants";
// 视频点播、云台各种控制、录像回放和下载,主要就是这些接口,后面缺的再加就行
// Ip : 113.200.190.167
// username : liusuo
// passwd : MapMap123
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";
const service = axios.create({
baseURL: '/', // api base_url
timeout: 9000, // 请求超时时间
@ -26,7 +33,7 @@ service.interceptors.request.use(
request.params = {}
}
// 带上 token
let viidToken = GetViidToken();
let viidToken = Base.GetViidToken();
if (!!viidToken) {
request.headers!.Authorization = viidToken;
}
@ -50,61 +57,75 @@ service.interceptors.response.use(
}
)
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;
enum BaseApiName {
Login = '/login', // 登录接口
KeepAlive = '/token/alive/keep', // 登录保活
Logout = '/logout', // 退出接口
LoginV2 = '/login/v2', // 登录接口 v2
KeepAliveV2 = '/hadesadapter/user/keepalive', // 登录保活 V2
}
export const SetViidToken = (token: string) => {
viidToken = token;
enum CommonApiName {
Query = '/query', // 查询组织下资源列表
}
export const GetVmToken = () => {
return vmToken;
enum OrgApiName {
QueryList = '/org/query/list', // 查询组织下子组织列表
}
export const SetVmToken = (token: string) => {
vmToken = token;
enum PtzApiName {
Ctrl = '/ptz/ctrl', // 发送云台控制指令
}
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)
enum A8ApiName {
QueryTvList = '/A8/tvlist', // 查询电视墙列表
QueryTvWall = '/A8/tvwall', // 查询电视墙信息
OpenWindow = '/window/open', // 开启窗口
CloseWindow = '/window/close', // 关闭窗口
StartMonitor = '/A8/monitor/start', // 开始实时监控
StopMonitor = '/A8/monitor/stop', // 停止实时监控
}
export const LoginV2 = (params?: any) => service.post(baseUrl + ApiName.LoginV2, params)
let viidToken = '', vmToken = '';
export const KeepAliveV2 = (params?: any) => service.post(baseUrl + ApiName.KeepAliveV2, params)
// Base
export const Base = {
GetViidToken: () => {
return viidToken;
},
SetViidToken: (token: string) => {
viidToken = token;
},
GetVmToken: () => {
return vmToken;
},
SetVmToken: (token: string) => {
vmToken = token;
},
Login: (params?: any) => service.post(baseUrl + BaseApiName.Login, params),
KeepAlive: (params?: any) => service.post(baseUrl + BaseApiName.KeepAlive, params),
Logout: (params?: any) => service.post(baseUrl + BaseApiName.Logout, params),
LoginV2: (params?: any) => service.post(baseUrl + BaseApiName.LoginV2, params),
KeepAliveV2: (params?: any) => service.post(baseUrl + BaseApiName.KeepAliveV2, params)
}
export const Query = (params: any) => service.get(baseUrl + ApiName.Query, {params: params})
// Common
export const Common = {
Query: (params: any) => service.get(baseUrl + CommonApiName.Query, {params: params}),
}
export const QueryOrg = (params: any) => service.get(baseUrl + ApiName.QueryOrg + `/${params.id}`, params.condition)
// Org
export const Org = {
QueryList: (params: any) => service.get(baseUrl + OrgApiName.QueryList + `/${params.id}`, {params: params.condition})
}
export const PtzCtrl = (params: any) => service.post(baseUrl + ApiName.PtzCtrl+ `/${params.code}`, params)
// Ptz
export const Ptz = {
Ctrl: (params: any) => service.post(baseUrl + PtzApiName.Ctrl + `/${params.code}`, params)
}
/**
*
@ -151,4 +172,13 @@ export enum PtzCmdId {
AllStop = 0x0901
}
// export const Get = (params?: any) => axios.get(baseUrl + Api.Get, {params: params})
// A8
export const A8 = {
QueryTvList: () => service.get(baseUrl + A8ApiName.QueryTvList),
QueryTvWall: (params?: any) => service.get(baseUrl + A8ApiName.QueryTvWall + `/${params.code}`),
OpenWindow: (params?: any) => service.post(baseUrl + A8ApiName.OpenWindow, params),
CloseWindow: (params?: any) => service.get(baseUrl + A8ApiName.CloseWindow, {params: params}),
StartMonitor: (params?: any) => service.get(baseUrl + A8ApiName.StartMonitor, params),
StopMonitor: (params?: any) => service.get(baseUrl + A8ApiName.StopMonitor, params),
}

47
Frontend/src/views/page/yushi.vue

@ -1,5 +1,5 @@
<template>
<button @click="test">test</button>
<button @click="test">Test</button>
<br>
<br>
<button @click="login">Login</button>
@ -34,10 +34,9 @@
</template>
<script>
import {defineComponent, ref} from 'vue';
import {defineComponent} 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;
@ -56,12 +55,16 @@ export default defineComponent({
},
methods: {
test() {
let loginSignature = ysHelper.hex_md5(ysHelper.base64encode(username));
console.log(loginSignature);
// let loginSignature = ysHelper.hex_md5(ysHelper.base64encode(username));
// console.log(loginSignature);
ysApi.A8.QueryTvList().then((data)=>{
console.log(arguments);
console.log(data);
});
},
login() {
if (!!ysApi.GetViidToken()) return;
ysApi.Login().then((data) => {
if (!!ysApi.Base.GetViidToken()) return;
ysApi.Base.Login().then((data) => {
console.log(data);
let accessCode = data.AccessCode;
let loginSignature = ysHelper.hex_md5(ysHelper.base64encode(username) + accessCode + ysHelper.hex_md5(passwd));
@ -70,16 +73,16 @@ export default defineComponent({
AccessCode: accessCode,
LoginSignature: loginSignature
}
ysApi.Login(params).then((data) => {
ysApi.Base.Login(params).then((data) => {
console.log(data);
let accessToken = data.AccessToken;
ysApi.SetViidToken(accessToken);
ysApi.Base.SetViidToken(accessToken);
});
});
},
loginV2() {
if (!!ysApi.GetViidToken()) return;
ysApi.LoginV2().then((data) => {
if (!!ysApi.Base.GetViidToken()) return;
ysApi.Base.LoginV2().then((data) => {
console.log(data);
let accessCode = data.AccessCode;
let loginSignature = ysHelper.hex_md5(ysHelper.base64encode(username) + accessCode + ysHelper.hex_md5(passwd));
@ -88,11 +91,11 @@ export default defineComponent({
AccessCode: accessCode,
LoginSignature: loginSignature
}
ysApi.LoginV2(params).then((data) => {
ysApi.Base.LoginV2(params).then((data) => {
console.log(data);
let accessToken = data.AccessToken;
ysApi.SetViidToken(accessToken);
ysApi.SetVmToken(accessToken);
ysApi.Base.SetViidToken(accessToken);
ysApi.Base.SetVmToken(accessToken);
this.initImosSdk();
});
});
@ -103,12 +106,12 @@ export default defineComponent({
if (isHttps) imosSdk.setLinkPort("7077");
imosSdk.init(
ysApi.vmIp,//VMip
ysApi.GetVmToken(),//VIIDtoken
ysApi.Base.GetVmToken(),//VIIDtoken
16,//16
"/app/imosSdk.html",//url
true,//trueB3351P01false2.1.3
).then(function (res) {
alert("登录成功");
console.log(res);
//
imosSdk.registerLiveMsg((result) => {
console.log(result)
@ -134,7 +137,7 @@ export default defineComponent({
PageRowNum: 30
})
};
ysApi.QueryOrg(params).then((data) => {
ysApi.Org.QueryList(params).then((data) => {
console.log(data);
// ResStatus, 1线2线0
});
@ -162,7 +165,7 @@ export default defineComponent({
PageRowNum: 30
})
};
ysApi.Query(params).then((data) => {
ysApi.Common.Query(params).then((data) => {
console.log(data);
});
},
@ -175,12 +178,12 @@ export default defineComponent({
PTZCmdPara2: 3,
PTZCmdPara3: 0
}
ysApi.PtzCtrl(params).then((data) => {
ysApi.Ptz.Ctrl(params).then((data) => {
console.log(data);
setTimeout(function () {
params.PTZCmdID = ysApi.PtzCmdId.AllStop;
ysApi.PtzCtrl(params).then((data) => {
ysApi.Ptz.Ctrl(params).then((data) => {
console.log(data);
});
}, 3000);
})
@ -241,7 +244,7 @@ export default defineComponent({
console.log(e);
});
},
stopPlay(iframeId){
stopPlay(iframeId) {
imosSdk.playStop(iframeId, (e) => {
console.log(e);
});

Loading…
Cancel
Save