import { axios } from '@/utils/request'
import { stringify } from 'qs'

/**
 * login func
 * parameter: {
 *     username: '',
 *     password: '',
 *     remember_me: true,
 *     captcha: '12345'
 * }
 * @param parameter
 * @returns {*}
 */
export function login (parameter) {
  return axios({
    url: `/oauth/token?${stringify(parameter)}`,
    method: 'post'
  })
}

export function smsLogin (parameter) {
  return axios({
    url: `/mobile/token?${stringify(parameter)}`,
    method: 'post'
  })
}

export function getInfo () {
  return axios({
    url: '/upms/users/info',
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function getDataDict () {
  return axios({
    url: '/upms/dicts/data',
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function getSmsCaptcha (parameter) {
  return axios({
    url: '/verify/sms/code/send',
    method: 'post',
    data: parameter
  })
}

export function checkCaptchaCode (parameter) {
  return axios({
    url: '/verify/captcha',
    method: 'post',
    data: parameter
  })
}

// export function getCurrentUserNav (token) {
//   return axios({
//     url: '/user/nav',
//     method: 'get'
//   })
// }

export function logout () {
  return axios({
    url: '/auth/logout',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
//
// /**
//  * get user 2step code open?
//  * @param parameter {*}
//  */
// export function get2step (parameter) {
//   return axios({
//     url: api.twoStepCode,
//     method: 'post',
//     data: parameter
//   })
// }
