import $axios from '../index'

const accountApi = {
  checkUsernameApi: '/api/user/account/check/username',
  selectUsernameApi: '/api/user/account/select/username',
  checkEmailApi: '/api/user/account/check/email',
  verifyCodeApi: '/api/account/verifyCode',
  registerApi: '/api/account/user/register'
}

export function getBase64Captcha(captchaUrl) {
  return $axios.get(captchaUrl)
}

export function isUsernameExist(username) {
  return $axios.get(accountApi.checkUsernameApi + '?username=' + username)
}

export function selectUsername(username) {
  return $axios.post(accountApi.selectUsernameApi + '/' + username)
}

export function isEmailExist(email) {
  return $axios.get(accountApi.checkEmailApi + '/' + email)
}

// 获取验证码
export function getVerifyCode(verifyCode) {
  return $axios.post(accountApi.verifyCodeApi, verifyCode)
}

export function register(userRegistry) {
  return $axios.post(accountApi.registerApi, userRegistry)
}
