initApi.js
4.97 KB
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
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import axios from 'axios'
import * as API from './api'
import store from '../store/index.js'
class api {
constructor() {
this.instance = null;
}
static getInstance() {
if (!this.instance) {
this.instance = new api();
}
return this.instance;
}
/**@augments
* 获取库相关信息
*/
getCarDbData() {
return new Promise((reslove, reject) => {
axios.get(API.url + "/alarm/traffic/vehicle_libs")
.then(response => {
reslove(response.data);
});
})
}
/**@augments
* 获取布控类别
*/
getMonitor() {
return new Promise((reslove, reject) => {
axios.get(API.url + "/alarm/traffic/monitor_cates")
.then(response => {
reslove(response.data.list_data);
});
})
}
/**
* @argument
* 获取城市
*/
getProvince() {
return new Promise((reslove, reject) => {
axios.get(API.url + "/codes/countries/0E229CD043/provinces?depth=1").then(res => {
store.commit('SET_PROVINCE', res.data.list_data)
reslove(res);
});
});
}
/**
* @argument
* 获取人员库
*/
getFaceDbData() {
return new Promise((reslove, reject) => {
axios.get(API.url + "/codes/custom/cates/4DD23AF66E/codes")
.then(response => {
store.commit('SET_FACEDB', response.data.list_data)
reslove(response.data);
});
})
}
/**@augments
* 初始化地点
*/
getOrg() {
return new Promise((reslove, reject) => {
axios.get(API.url + '/org/list', {
params: {
org_type: 'org',
}
}).then(response => {
store.commit('SET_ORG', response.data.list_data);
reslove(response.data);
})
})
}
/**@argument
* 列出所有地点
*/
getAddress() {
return new Promise((reslove, reject) => {
axios.get(API.url + '/org/list', {
params: {
org_type: 'address',
}
}).then(response => {
store.commit('SET_ADDRESS', response.data.list_data);
reslove(response.data);
})
})
}
/**@argument
* 获取地点值
*/
getSite() {
return new Promise((reslove, reject) => {
axios.get(API.url + '/codes/custom/cates/630A634844/codes').then(response => {
reslove(response.data);
})
});
}
/**@augments
* 上传图片
*/
uploadImg() {
return new Promise((reslove, reject) => {
axios.post("http://192.168.9.225:8080/FACE-DETECT-WEB/api/v1/face_web/search_src_pics/", data)
.then(function (response) {
reslove(response.data);
});
})
}
/**@argument
* 获取推送服务websocket连接地址
*/
getPushWebsocketUrl() {
return new Promise((reslove, reject) => {
axios.post("http://192.168.9.225:8080/FACE-DETECT-WEB/api/v1/face_web/search_src_pics/", data)
.then(function (response) {
reslove(response.data);
});
})
}
/**@argument
* 获取人脸websocket连接地址
*/
getFaceWebsocketUrl() {
return new Promise((reslove, reject) => {
var userName = localStorage.getItem("user_id");
var timer = new Date();
this.axios.get("http://192.168.9.225:8080/FACE-DETECT-WEB/api/v1/face_web/ws_url?src_type=user&user_unid=" + userName + "&client_unid=" + timer.getTime()).then((response) => {
this.openWs(response.data.ws_url);
});
});
}
/**@argument
* 获取设备信息
*/
getVchanList() {
return new Promise((reslove, reject) => {
let externList = {},
cameraList = {}
axios.get(IP + "/api/v1/org/vchans/list", {
params: {
limit: 1000,
}
}).then(function (response) {
reslove(response.data);
});
});
}
/**@argument
* websocket心跳
*/
wsclock(command) {
var date = new Date();
var datatimes = date.getTime();
var wsMessage = {
"type": "request",
"id": datatimes,
// command: "get /wsapi/v1/dtid/"+wsIP+"/keep_alive",//推送服务
command: command,
mts: datatimes
};
Ws.send(JSON.stringify(wsMessage));
}
// 获取code编码
getCodeName() {
axios.get(IP + '/api/v1/codes/traffic/cates').then(m => {
m.data.list_data.forEach(ele => {
this.setCodeLocalStorage(ele)
})
})
}
setCodeLocalStorage(res) {
axios.get(IP + '/api/v1/codes/traffic/cates/' + res.cate_unid + '/codes').then(response => {
if (response.data.list_data) {
response.data.list_data.forEach(ele => {
let codeKey = res.name + '-' + ele.code;
window.localStorage.setItem(codeKey, ele.name);
})
}
})
}
// behavior
setBehaviorLocal() {
axios.get(IP + '/api/v1/codes/event_types').then(m => {
if (m.data.list_data) {
m.data.list_data.forEach(ele => {
let behaviorKey = '安防事件-' + ele.code;
window.localStorage.setItem(behaviorKey, ele.name);
})
}
})
}
}
const faceapi = api.getInstance();
export {
faceapi
}