import HttpAxios from '@/utils/axios'

const base = import.meta.env.VITE_API_HOST
const baseUrl = `${base}/login.php`

/**
 * 获取验证码
 */
export const getVerifcationCode = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'login',
      operate: 'verifcation_code',
      ...params
    },
    config
  )
}

/**
 * 验证用户名是否存在
 */
export const isUserNameExit = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'login',
      operate: 'check_uname',
      ...params
    },
    config
  )
}

/**
 * 登录
 */
export const login = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'login',
      operate: 'do_login',
      ...params
    },
    config
  )
}

// 退出登录
export const logout = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'login',
      operate: 'logout',
      ...params
    },
    config
  )
}

/**
 * 忘记密码
 */
export const forgotPassword = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'login',
      operate: 'forgot_password',
      ...params
    },
    config
  )
}

/**
 * 更新密码
 */
export const changePassword = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'login',
      operate: 'update_pwd_expires',
      ...params
    },
    config
  )
}

/**
 * 获取public tracking detail详情数据
 */
export const getPublicTrackingDetail = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'login',
      operate: 'tracking_checked',
      ...params
    },
    config
  )
}

/**
 * reset password
 */
export const resetPwd = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'login',
      operate: 'update_pwd_expires',
      ...params
    },
    config
  )
}
