index.js
1.25 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
//获取设备分页API 修改为post
/**
* params ((page,pageSize))
* data ((deviceProfileIds))
*/
const getDeviceApi = (urlParams, data) => {
const { page, pageSize } = urlParams
return uni.$u.http.post(`/yt/device?page=${page}&pageSize=${pageSize}`, data)
}
// 设备详情
const getDeviceDetail = (id) => {
return uni.$u.http.get(`/yt/device/${id}`)
}
//设备属性
const getAttribute = (deviceProfileId) => {
return uni.$u.http.get(`/yt/device/attributes/${deviceProfileId}`)
}
//命令下发
const issueCommand = (type, tbDeviceId, data) => {
return uni.$u.http.post(`/rpc/${type === 'OneWay' ? 'oneway' : 'twoway'}/${tbDeviceId}`, data)
}
//获取命令下发记录
const getRpcRecord = (params) => {
return uni.$u.http.get('/yt/rpc', params)
}
// 获取设备状态 在线or离线
const getDeviceActiveTime = (entityId) => {
return uni.$u.http.get(`/plugins/telemetry/DEVICE/${entityId}/values/attributes?keys=active`)
}
// 获取服务调用
const getModelServices = (params) => {
const { deviceProfileId } = params
return uni.$u.http.get(`/yt/things_model/get_services/${deviceProfileId}`)
}
export default {
getDeviceApi,
getDeviceDetail,
getAttribute,
issueCommand,
getRpcRecord,
getModelServices,
getDeviceActiveTime,
}