device.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * 设备管理相关API
  3. */
  4. import { get, post, put } from '@/utils/request';
  5. export interface DeviceQueryParams {
  6. page?: number;
  7. pageSize?: number;
  8. deviceId?: string;
  9. shopId?: number;
  10. status?: number;
  11. storeName?: string;
  12. }
  13. export interface DeviceListResponse {
  14. list: any[];
  15. total: number;
  16. page: number;
  17. pageSize: number;
  18. }
  19. /**
  20. * 获取设备列表
  21. */
  22. export async function getDeviceList(params: DeviceQueryParams = {}): Promise<DeviceListResponse> {
  23. return get('/devices/list', params);
  24. }
  25. /**
  26. * 获取设备详情
  27. */
  28. export async function getDeviceDetail(deviceId: number): Promise<any> {
  29. return get(`/devices/${deviceId}`);
  30. }
  31. /**
  32. * 获取设备统计数据
  33. */
  34. export async function getDeviceStats(): Promise<any> {
  35. return get('/devices/statistics');
  36. }
  37. /**
  38. * 远程开门
  39. */
  40. export async function openDeviceDoor(deviceId: number, doorIndex?: string): Promise<void> {
  41. await post(`/devices/${deviceId}/open`, { doorIndex: doorIndex || 'A' });
  42. }
  43. /**
  44. * 设置设备温度
  45. */
  46. export async function setDeviceTemperature(deviceId: number, temperature: number): Promise<void> {
  47. await put(`/devices/${deviceId}/temperature`, { temperature });
  48. }
  49. /**
  50. * 设置设备音量
  51. */
  52. export async function setDeviceVolume(deviceId: number, volume: number): Promise<void> {
  53. await put(`/devices/${deviceId}/volume`, { volume });
  54. }
  55. /**
  56. * 获取设备门记录
  57. */
  58. export async function getDeviceDoorRecords(deviceId: string, params: { page?: number; pageSize?: number } = {}): Promise<any> {
  59. return get(`/devices/${deviceId}/door-records`, params);
  60. }