import request from '@/utils/request'

const formDataHeader = {
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  }
}
/**
 * 获取租户
 */
interface UserTenants {
  // 用户账号
  userNameOrEmailAddressOrPhoneNumber: string
}
export const fetchUserTenants = (data: UserTenants) =>
  request.post('/api/TokenAuth/SearchUserTenants', data, { ...formDataHeader })

interface ILogin {
  // 账户
  userNameOrEmailAddressOrPhoneNumber: string
  // 密码
  password: string
  // 租户名称
  tenancyName: string
  // 多端类型
  type: number
}
/**
 * 登录
 * @param data
 * @returns  token
 */
export const userLogin = (data: ILogin) =>
  request.post('/api/TokenAuth/Authenticate', data, {
    headers: {
      'Content-Type': 'application/json'
    }
  })
/**
 * 退出登录
 */
export const signOut = () => request.post('/api/services/app/Account/SignOut')
