device.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. keyword?: string;
  13. }
  14. export interface DeviceListResponse {
  15. list: any[];
  16. total: number;
  17. page: number;
  18. pageSize: number;
  19. }
  20. /**
  21. * 获取设备列表
  22. */
  23. export async function getDeviceList(params: DeviceQueryParams = {}): Promise<DeviceListResponse> {
  24. return get('/devices/list', params);
  25. }
  26. /**
  27. * 获取设备详情
  28. */
  29. export async function getDeviceDetail(deviceId: string): Promise<any> {
  30. return get(`/devices/${deviceId}`);
  31. }
  32. /**
  33. * 获取设备统计数据
  34. */
  35. export async function getDeviceStats(): Promise<any> {
  36. return get('/devices/statistics');
  37. }
  38. /**
  39. * 远程开门
  40. */
  41. export async function openDeviceDoor(deviceId: string, doorIndex?: string): Promise<void> {
  42. await post(`/devices/${deviceId}/open`, { doorIndex: doorIndex || 'A' });
  43. }
  44. /**
  45. * 设置设备温度
  46. */
  47. export async function setDeviceTemperature(deviceId: string, temperature: number): Promise<void> {
  48. await put(`/devices/${deviceId}/temperature`, { temperature });
  49. }
  50. /**
  51. * 设置设备音量
  52. */
  53. export async function setDeviceVolume(deviceId: string, volume: number): Promise<void> {
  54. await put(`/devices/${deviceId}/volume`, { volume });
  55. }
  56. /**
  57. * 获取设备商品配置
  58. */
  59. export async function getDeviceProductConfig(deviceId: string): Promise<any> {
  60. return get(`/devices/${deviceId}/product-config`);
  61. }
  62. /**
  63. * 保存设备商品配置
  64. */
  65. export async function saveDeviceProductConfig(deviceId: string, data: any): Promise<any> {
  66. return post(`/devices/${deviceId}/product-config`, data);
  67. }
  68. /**
  69. * 获取设备门记录
  70. */
  71. export async function getDeviceDoorRecords(deviceId: string, params: { page?: number; pageSize?: number } = {}): Promise<any> {
  72. return get(`/devices/${deviceId}/door-records`, params);
  73. }