import request from "@/utils/request.js";

const baseURL = import.meta.env.VITE_APP_BASE_API

/**
 * @description 注册
 * @params email，password
 * @returns data
 */
export function register(data) {
  return request({
    url: `/api/user/doRegisterByEmail`,
    method: 'post',
    data
  })
}

/**
 * @description 登录
 * @params email，password，code
 * @returns data
 */
export function login(data) {
  return request({
    url: `/api/user/loginByEmail`,
    method: 'post',
    data
  })
}

/**
/**
 * @description:重新发送邮件
 * @param {string} data
 * @return: data
 */
export function sendRegisterEmail(email) {
  return request({
    url: `/api/user/sendRegisterEmail`,
    method: 'post',
    data: {
      email
    }
  })
}

/**
/**
 * @description:忘记密码发送邮件
 * @param {string} data
 * @return: data
 */
export function sendUpdPwdEmailApi(email) {
  return request({
    url: `/api/user/sendUpdPwdEmail`,
    method: 'post',
    data: {
      email
    }
  })
}

/**
/**
 * @description:邮件重置密码,
 * @param pwd, ticket
 * @return: data
 */
export function resetPwdEmailApi(data) {
  return request({
    url: `/api/user/doUpdPass`,
    method: 'post',
    data
  })
}

/**
/**
 * @description:邮件重置密码,
 * @param oldpwd, newpwd
 * @return: data
 */
export function resetPwdFormApi(data) {
  return request({
    url: `/api/user/oldUpdPass`,
    method: 'post',
    data
  })
}


/**
* @description:获取图形验证码
* @return: 验证码地址
*/
export const getCodeImgUrl = baseURL + '/api/user/captcha.jpg'

