index.js 1.25 KB
//获取设备分页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,
}