import request from '@/utils/request'

// 获取路由
export const getRouters = () => {
  return request({
    url: '/system/menu/getRouters',
    method: 'get'
  })
}

// 登录方法
export function login(account, password, code, uuid, userType) {
  return request({
    url: '/auth/login',
    method: 'post',
    data: { account, password, code, uuid,userType }
  })
}
// 登录方法
export function supplierLogin(account, password, code, uuid, userType) {
  return request({
    url: '/auth/supplierLogin',
    method: 'post',
    data: { account, password, code, uuid,userType }
  })
}

//手机号码登录
export function phoneLogin(data) {
  return request({
    url: '/auth/login',
    method: 'post',
    data: data
  })
}
//获取验证码
export function sendCode(username) {
  return request({
    url: '/auth/send/code',
    method: 'post',
    data: { username }
  })
}

// 注册方法
export function register(data) {
  return request({
    url: '/auth/register',
    headers: {
      isToken: false
    },
    method: 'post',
    data: data
  })
}

// 刷新方法
export function refreshToken() {
  return request({
    url: '/auth/refresh',
    method: 'post'
  })
}

// 获取用户详细信息
export function getInfo() {
  return request({
    url: '/system/user/permission',
    method: 'get'
  })
}

// 退出方法
export function logout() {
  return request({
    url: '/auth/logout',
    method: 'get'
  })
}

// 获取验证码
export function getCodeImg() {
  return request({
    url: '/auth/captcha',
    method: 'get'
  })
}

// 获取首页配置
export function initPage() {
  return request({
    url: '/system/config/initPage',
    method: 'get'
  })
}

// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: '/system/user/profile',
    method: 'get'
  })
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return request({
    url: '/system/user/profile/updatePwd',
    method: 'put',
    params: data
  })
}

// 修改用户手机号
export function changePhone(data) {
  return request({
    url: '/system/user/change/phone',
    method: 'put',
    params: data
  })
}

// 上传电子签名
export function genSign(data) {
  return request({
    url: '/system/user/genSign',
    method: 'post',
    data: data
  })
}

// 修改电子签名
export function updateSignature(data) {
  return request({
    url: '/system/user/updateSignature  ',
    method: 'post',
    data: data
  })
}

// 修改用户信息
export function upDataProfile(data) {
  return request({
    url: '/system/user/profile',
    method: 'put',
    data: data
  })
}

//指纹-查询用户指纹录取数量
export const fingerprintQuantity  = (data) => {
  return request({
    url: `/laboratory/haikang/userFinger/queryCount/`+data,
    method: 'GET',
  })
};

// 用户头像上传
export function uploadAvatar(data) {
  return request({
    url: '/system/user/profile/avatar',
    method: 'post',
    data: data
  })
}

//获取认证信息
export function authInfo(query) {
  return request({
    url: '/auth/info',
    method: 'get',
    params: query
  })
}

// 查询危险化学品详情
export function chemicalMsdsDetailNotToken(query) {
  return request({
    url: '/chemical/msds/detailNotToken',
    method: 'get',
    params: query
  })
}

// 查询安全管理制度
export function examSafeBookDetailNotToken(query) {
  return request({
    url: '/laboratory/safeBook/detailNotToken',
    method: 'get',
    params: query
  })
}


// 查询危险源
export function laboratoryHazardDetailNotToken(query) {
  return request({
    url: '/laboratory/hazard/detailNotToken',
    method: 'get',
    params: query
  })
}

//获取摄像头流地址
export function iotCameraFindByCondition(data) {
  return request({
    url: '/iot/camera/findByCondition',
    method: 'post',
    data: data
  })
}

//根据设备ID获取摄像头流地址
export function iotCameraGetPreviewURLs(query) {
  return request({
    url: '/iot/camera/getPreviewURLs',
    method: 'get',
    params: query
  })
}
