import axios from 'axios'

export const login = ({ userName, password ,localUserInfo}) => {
  const data = {
    userName,
    password,
    localUserInfo,
  }
  console.log(data)
  return axios.post('http://192.168.3.106:8083/login',data,{
    withCredentials: true, // 跨域凭证
  }).then(res =>{
    console.log("跨域凭证")
    console.log(res)
    if(res.data.flag){
      return Promise.resolve(res.data)
    }else{
      return Promise.reject(res.data)
    }
    }).catch( err =>{
    return Promise.reject(err)
  })
}

export const getUserInfo = (token) => {
  return axios.request({
    url: 'get_info',
    params: {
      token
    },
    method: 'get'
  })
}

export const logout = (token) => {
  return axios.post("http://192.168.3.106:8083/loginOut",token,{
  }).then(res =>{
    console.log(res)
  }).catch( err =>{
    console.log(err)
  })
}

