
// 电商公共api
import request from '@/assets/js/utils/request'
import { getToken } from '@/assets/js/utils/auth'

// 更改默认的机构或者角色
export function changeDefaultOrgOrRolRest(userLogin) {
  return request({
    url:
      '/bidprocurement/common-login/login/changeDefaultOrgOrRolRest?userName=' +
      userLogin.userName +
      '&password=' +
      userLogin.password +
      '&orgId=' +
      userLogin.orgId +
      '&rolId=' +
      userLogin.rolId +
      '',
    method: 'post',
    data: {
      // token: getToken()
    }
  })
}

// 校验用户名密码
export function userLogin(userLogin) {
  return request({
    url:
      '/bidprocurement/common-login/login/login?userName=' +
      userLogin.userName +
      '&password=' +
      userLogin.password +
      '&loginType=' +
      userLogin.loginType,
    method: 'post'
  })
}

// 获取菜单
export function getUserMenu() {
  return request({
    url: '/bidprocurement/common-login/login/getMenu',
    method: 'post'
  })
}

// 获取用户信息
export function getUserInfo() {
  return request({
    url: '/bidprocurement/common-login/login/getUserInfo',
    method: 'post',
    data: {
      token: getToken()
    }
  })
}

// 退出系统
export function userlogout() {
  return request({
    url: '/bidprocurement/common-login/login/shopmallLogoutRest',
    method: 'post'
  })
}

// 获取TOKEN
export function getUserToken(username, password) {
  return request({
    url:
      '/bidprocurement/common-login/login/getToken?username=' +
      username +
      '&password=' +
      password,
    method: 'post'
  })
}
// 获取当前登录人的角色信息
export function getRoleByUserId(userLogin) {
  return request({
    url:
      '/bidprocurement/common-user/user/user/getRoleByUserId?userId=' +
      userLogin.userId +
      '&userName=' +
      userLogin.userName +
      '&realName=' +
      userLogin.realName,
    method: 'get'
  })
}
