import request from '@/utils/request'

// pc端固定客户端授权id
// const clientId = 'e5cd7e4891bf95d1d19206ce24a7b32e';
const clientId = process.env.VUE_APP_CLIENT_ID

/**
 * @param data {LoginData}
 * @returns
 */
export function login(username, password, code, uuid,tenantId,grantType,phonenumber,smsCode) {
	const data = {
	  username,
	  password,
	  code,
	  uuid,
	  tenantId,
    grantType,
    phonenumber,
    smsCode
	}
  const params = {
    ...data,
    clientId: data.clientId || clientId,
  };
  return request({
    url: '/auth/login',
    headers: {
      isToken: false,
    },
    method: 'post',
    data: params
  });
}

export function loginde(data) {
  return request({
    url: '/auth/login',
    headers: {
      isToken: false,
    },
    method: 'post',
    data: data
  });
}

// 注册方法
export function register(data) {
  return request({
    url: '/auth/register',
    headers: {
      isToken: false,
      isEncrypt: true
    },
    method: 'post',
    data: data
  });
}

/**
 * 注销
 */
export function logout() {
  return request({
    url: '/auth/logout',
    method: 'post'
  });
}

/**
 * 获取验证码
 */
export function getCodeImg(){
  return request({
    url: '/auth/code',
    headers: {
      isToken: false
    },
    method: 'get',
    timeout: 20000
  });
}

// 重置密码
export function registerf(query) {
  return request({
    url: '/system/user/profile/appCheck',
    method: 'get',
	params: query
  });
}


// 登录获取短信验证码
export function getCaptcha(data) {
  return request({
    url: '/wuYe/sendSms/sendLoginSms',
    method: 'post',
    data: data
  });
}

// 注册
export function postphones(query) {
  return request({
    url: '/wuYe/resource/sms/code',
    method: 'get',
    params: query
  });
}







/**
 * 第三方登录
 */
export function callback(data){
  const LoginData = {
    ...data,
    clientId: clientId,
    grantType: 'social'
  };
  return request({
    url: '/auth/social/callback',
    method: 'post',
    data: LoginData
  });
}

// 获取用户详细信息
export function getInfo() {
  return request({
    url: '/system/user/getInfo',
    method: 'get'
  });
}

// 获取租户列表
export function getTenantList(){
  return request({
    url: '/auth/tenant/list',
    headers: {
      isToken: false
    },
    method: 'get'
  });
}
