import { useMyRequest } from '~/composables/useFetchRequest'

enum Api {
  Login = '/client-s003/s003Customer/login',
  Logout = 'client-s003/s003Customer/logout',
  Register = '/client/user/preRegister',
  ValidateRegister = '/client/user/register',
  ValidateEmail = '/client/user/forgetPassword',
  ResetOrChangePassword = '/client/user/changePassword',
  ValidateEmailIsExist = '/client-s003/s003Customer/lastLoginType',
  SendEmailCode = '/client-s003/captcha/sms/send',
  SubmitInfo = '/client-s003/s003ProductCatalogue/download',
  UserInfo = '/client-s003/s003Customer/userinfo',
}
/**
 * 获取用户信息，获取更新后的用户信息
 */
export async function getUpdateUserInfoApi(params?: any) {
  return await useMyRequest().get(Api.UserInfo, params)
}

/**
 * 提交用户信息
 */
export async function submitInfoApi(params: any) {
  return await useMyRequest().post(Api.SubmitInfo, params)
}

/**
 * 验证邮箱是否存在
 */
export async function validateEmailIsExistApi(params: any) {
  return await useMyRequest().get(Api.ValidateEmailIsExist, params)
}
/**
 * 验证邮箱是否存在
 */
export async function getEmailCodeApi(params: any) {
  return await useMyRequest().post(Api.SendEmailCode, params)
}
/**
 * @description: user login api
 */
export async function loginApi(params: any) {
  return await useMyRequest().post(Api.Login, params)
}
/**
 * 预注册
 * @param params
 * @param mode
 * @returns
 */
export async function registerApi(params: any) {
  return await useMyRequest().post(Api.Register, params)
}
/**
 * 注册
 * @param params
 * @returns
 */
export async function validateRegisterApi(params: any) {
  return await useMyRequest().post(Api.ValidateRegister, params)
}
/**
 * 忘记密码，发送邮箱
 * @param params
 * @returns
 */
export async function validateEmailApi(params: any) {
  return await useMyRequest().post(Api.ValidateEmail, params)
}
/**
 * 更新用户信息
 * @param params
 * @returns
 */
export async function updateUserInfoApi(params: any) {
  return await useMyRequest().post(Api.UserInfo, params)
}
/**
 * 重置密码
 * @param params
 * @returns
 */
export async function resetOrChangePasswordApi(params: any) {
  return await useMyRequest().post(Api.ResetOrChangePassword, params)
}

export async function logoutApi() {
  return await useMyRequest().get(Api.Logout)
}
