import request from '@/utils/request'

export function loginByUsername(username, password) {
  const data = {
    username: username,
    password: password
  }
  return request({
    url: '/web/auth',
    method: 'post',
    data
    // transformRequest: [function(data) {
    //   // Do whatever you want to transform the data
    //   let ret = ''
    //   for (const it in data) {
    //     ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
    //   }
    //   return ret
    // }],
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    //   // 'Access-Control-Allow-Origin': '*'
    // }
  })
}

export function logout() {
  return request({
    url: '/login/logout',
    method: 'post'
  })
}

export function getUserInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}

