import request from "@/utils/request";

function customParamsSerializer(params) {
  let result = '';
  for (let key in params) {
    if (params.hasOwnProperty(key)) {
      if (Array.isArray(params[key])) {
        params[key].forEach((item,index) => {
          result += `${key}[${index}]=${item}&`;
        });
      } else {
        result += `${key}=${params[key]}&`;
      }
    }
  }
  return result.slice(0, -1);
}
export function getOaToken (isLoading=false) {
  return request({
    url: "/api/admin/oa/get-oa-token",
    method: "get",
    isLoading
  })
}

export function weather (params) {
  return request({
    url: "/api/admin/other/weather",
    method: "get",
    params,
    isLoading: false
  })
}

export function infoStatics() {
  return request({
    url: "/api/admin/other/statistic",
    method: "get",
    isLoading: false
  })
}
export function info (data) {
  return request({
    url: "/api/admin/other/get-daily-details-by-date",
    method: "post",
    data,
    isLoading: false
  })
}

export function equipmentInfos (params) {
  return request({
    url: "/api/admin/other/list-hob-real",
    method: "get",
    params,
    isLoading: false
  })
}

export function checkTransfer (params) {
  return request({
    url: "/api/admin/other/check",
    method: "get",
    params,
    isLoading: false
  })
}

export function sendSms (params) {
  return request({
    url: "/api/admin/sned_sms",
    method: "get",
    params,
    paramsSerializer: customParamsSerializer,
    isLoading: false
  })
}
