import { httpPost } from '../utils/request'

export function getOrg(params) { // 获取组织列表（service)
  return httpPost('OP/TenantInfo/GetOrgList', params)
}

export function getToken(params) { // 获取Token（service)
  return httpPost('Token/Gen', params, false)
}

export function getLoginInfo(params) { // 登录、获取信息（service)
  params.Parameter20 = getBrowserVersion();
  params.Parameter21 = "PC";
  return httpPost('PF/Login/Login', params, true, true)
}

export function modifyPassword(params) { // 修改密码（service）
  return httpPost('FM/User/UpdatePwd', params)
}

export function checkLcpLogin(params) { // 修改密码（service）
  return httpPost('DT/SingleLogin/SingleLogin', params)
}

export function getNotices(params) { // 获取消息列表
  return httpPost('FM/Notification/OrderPagedNotice', params, false)
}

export function getAlarmLog(params) { // 获取消息列表
  return httpPost('KR/AlarmLog/OrderPaged', params, false)
}
function getBrowserVersion() {
  var name = navigator.userAgent;
  if (name.indexOf("MSIE ") > -1) {
    return "MSIE" + name.slice(name.indexOf("MSIE ") + 5, name.indexOf(" ", name.indexOf("MSIE ") + 5));
  } else if (name.indexOf("Firefox/") > -1) {
    return "Firefox" + name.slice(name.indexOf("Firefox/") + 8, name.indexOf(" ", name.indexOf("Firefox/") + 8));
  } else if (name.indexOf("Chrome/") > -1) {
    return "Chrome" + name.slice(name.indexOf("Chrome/") + 7, name.indexOf(" ", name.indexOf("Chrome/") + 7));
  } else if (name.indexOf("Safari/") > -1) {
    return "Safari" + name.slice(name.indexOf("Safari/") + 7, name.indexOf(" ", name.indexOf("Safari/") + 7));
  } else {
    return "Unknown";
  }
}