import $http from '@/common/request.js';
import config from '@/config';
function getCompmayUsers() {
  return $http({
    url: `/user/companyUsers`,
    method: 'GET',
  });
}

// 获取用户信息
function getUserInfo(params) {
  return $http({
    url: '/user/info',
    method: 'GET',
    data: JSON.stringify(params)
  });
}

function setWxAuthUserInfo(params) {
  return $http({
    url: '/user/wxAuthInfo',
    method: 'POST',
    data: JSON.stringify(params)
  });
  // return Promise.resolve()
}

function login(params) {
  return $http({
    url: `${config.duoduoenvService}userNew/wechat/login`,
    method: 'POST',
    data: JSON.stringify(params)
  })
}

// duoduo-service/duoduoenv-service/userNew/wechat/register
// 注册
function register(params) {
  return $http({
    url: `${config.duoduoenvService}userNew/wechat/register`,
    method: 'POST',
    isComParams: true,
    data: JSON.stringify(params)
  })
}

// 根据手机号获取租户数据
function getCompanyByPhone(params) {
  return $http({
    url: `${config.duoduoenvService}userNew/company?phone=${params.phone}`,
    method: 'get'
  })
}

// 根据code获取手机号
function getHttpPhoneNumber(code) {
  return $http({
    url: `${config.duoduoenvService}userNew/wechat/getPhoneNumber?code=${code}`,
    method: 'get'
  })
}

// 续约
function refreshToken(refreshToken) {
  return $http({
    header: {
      "refreshToken": refreshToken,
    },
    url: `${config.duoduoenvService}userNew/refreshToken`,
    method: 'post'
  })
}

// 获取用户空间权限
function getUserControlSpace(params) {
  return $http({
    // url: `http://192.168.88.4:52009/userControlSpace/query`,
    url: `${config.duoduoenvService}userControlSpace/query`,
    method: 'POST',
    data: JSON.stringify(params),
    isComParams: false    // 是否携带通用的参数
  })
}


export {
  getCompmayUsers,
  getUserInfo,
  getHttpPhoneNumber,
  getCompanyByPhone,
  register,
  login,
  getUserControlSpace,
  refreshToken
}