import { requestForm, request } from '@/request';

// 登录
export function PhoneLogin(data: any) {
  return requestForm({ url: '/api/login', data });
}

export function sendCode(data) {
  return requestForm({ url: '/user/smsSendCode', data });
}

// 获取图形码（旧）
export function captcha() {
  return request({
    url: '/user/captcha',
    method: 'get',
    responseType: 'blob',
  });
}

//退出
export function logout() {
  return requestForm({
    url: '/user/logout',
    method: 'get',
  });
}
// 登录
export function login(data: any) {
  return requestForm({ url: '/api/login', method: 'post', data });
}

// 新增：获取验证码（新）
export function getCaptchaNew(params?: any) {
  return request({
    url: '/api/captcha/new',
    method: 'get',
    responseType: 'blob',
    // 某些服务端验证码依赖会话，开启携带凭证以提高兼容性
    withCredentials: true,
    params,
  });
}

// 新增：注册
export function register(data: any) {
  return requestForm({ url: '/api/register', method: 'post', data });
}
