import api from './index'
import { axios } from '@/utils/request'

export function login ({ username, password }) {
  return axios({
    url: 'auth/login',
    data: { username, password },
    method: 'post'
  })
}

export function logout () {
  return axios({
    url: 'auth/logout',
    method: 'get'
  })
}

export function getSmsCaptcha (parameter) {
  return axios({
    url: api.SendSms,
    method: 'post',
    data: parameter
  })
}

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

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

/**
 * get user 2step code open?
 * @param parameter {*}
 */
export function get2step (parameter) {
  return axios({
    url: api.twoStepCode,
    method: 'post',
    data: parameter
  })
}

// 修改密码
export function changePwd (parameter) {
  return axios({
    url: '/user/changePWD',
    method: 'post',
    data: parameter
  })
}
