import { request } from 'umi';

const API = 'https://duoduoenv.sagacloud.cn';

function commonParams() {
    return `openid=9a1ecfbacb6b4f249bf2dd3ec7793ead&pubname=sagacareAndtenantslink&projectId=Pj1101080259&userName=%E5%AE%89%E5%B0%8F%E9%9C%9E&userPhone=17611228068&userId=9a1ecfbacb6b4f249bf2dd3ec7793ead`;
    //   return `openid=9a1ecfbacb6b4f249bf2dd3ec7793ead&pubname=sagacareAndtenantslink&projectId=Pj1101080259&userName=anxiaoxia&userPhone=17611228068
    //   &userId=9a1ecfbacb6b4f249bf2dd3ec7793ead`;
}
function getProjectId() {
  return 'Pj1101080259';
}

//窗帘  设置设备
export const setEquipeHttp = (params)=> {
  return request(`/server/object/eqp/infocode/set?${commonParams()}`,{
    method: 'POST',
    isNotShowErrorToast: true,
    errorSave: true,
    data: JSON.stringify(params),
    headers: {
        'Content-Type': 'application/json',
    },
  });
}

//窗帘 获取设备
export const getObjectDataEqpGroupHttp = (params) => {
  return request(`/server/object/objectDataEqpGroup/query?${commonParams()}`, {
    method: 'POST',
    isNotShowErrorToast: true,
    errorSave: true,
    data: JSON.stringify(params),
    headers: {
        'Content-Type': 'application/json',
    },
  });
}



// 灯的状态
export const getLampHttp = (params) => {
    return request(`/server/light/status/query?${commonParams()}&spaceId=${params}`, {
        isNotShowErrorToast: true,
        errorSave: true,
        method: 'GET',
        headers: {
            'Content-Type': 'application/json',
        },
    });
};


// 批量 开关灯
export const setallLampHttp = (params) => {
  return request(`/server/light/onoff/set?${commonParams()}`, {
    method: 'POST',
    isNotShowErrorToast: true,
    errorSave: true,
    data: JSON.stringify(params),
    headers: {
      'Content-Type': 'application/json',
    },
  });
};

// 开关失败时 定时查询灯状态
export const getStatusHttp = (params) => {
  return request(`/server/light/onoff/setSatus?${commonParams()}`, {
    method: 'POST',
    isNotShowErrorToast: true,
    errorSave: true,
    data: JSON.stringify(params),
    headers: {
      'Content-Type': 'application/json',
    },
  });
};


//  空调 - 调节文案/空调信息
export const getFeedbackDocumentsHttp = (params) => {
    return request(`/server/custom/feedback/documents?${commonParams()}`, {
        isNotShowErrorToast: true,
        errorSave: true,
        method: 'POST',
        data: JSON.stringify(params),
        headers: {
            'Content-Type': 'application/json',
        },
    });
};

//  空调 调节
export const changeAirHttp = (params) => {
    return request(`/server/custom/feedbackCreate/v2?${commonParams()}`, {
        method: 'POST',
        isNotShowErrorToast: true,
        errorSave: true,
        data: JSON.stringify({ ...params, projectId: getProjectId() }),
        headers: {
            'Content-Type': 'application/json',
        },
    });
};

// 空间环境质量
export const getSpaceAdjustList = (params) => {
    return request(`/server/space/property?${commonParams()}`, {
        method: 'POST',
        isNotShowErrorToast: true,
        errorSave: true,
        data: JSON.stringify({ ...params, criteria: { ...params.criteria, projectId: getProjectId() } }),
        headers: {
            'Content-Type': 'application/json',
        },
    });
}
//  空调 调节
export const changeAllAirHttp = (body) => {
    return request(`/server/custom/feedbackCreate/v2Batch?${commonParams()}`, {
        method: 'POST',
        isNotShowErrorToast: true,
        errorSave: true,
        data: body,
        headers: {
            'Content-Type': 'application/json',
        },
    });
};
