import request from '@/assets/js/utils/request'
import { getToken } from '@/assets/js/utils/auth'
import { createURL } from '@/assets/js/utils'
// 预览二维码
export const qRCodeContent = '/bidprocurement/common-user/user/userApp/encodeQrcode?content='
// 扫码登录-获取二维码
export function getQRCodeContent() {
  return request({
    url: '/bidprocurement/common-user/user/userApp/getQRCodeContent',
    method: 'get'
  })
}

// 检查二维码是否已扫描
export function getQRCodeIsScaned(params) {
  return request({
    url: '/bidprocurement/common-user/user/userApp/getQRCodeIsScaned',
    method: 'get',
    params
  })
}

// 是否绑定扫码APP,获取用户信息，否（输入用户名和密码登录首次推送）
export function judgeBindingScanCode(params) {
  return request({
    url: '/bidprocurement/common-user/user/userApp/judgeBindingScanCode',
    method: 'get',
    params
  })
}
// 更改默认的机构或者角色
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(data) {
  return request({
    url: '/bidprocurement/common-login/login/login',
    data: data,
    method: 'post'
  })
}
// 管理员代理登录
export function proxyAdminLogin(data) {
  return request({
    url: '/bidprocurement/common-login/login/proxyAdminLogin',
    data: data,
    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/logoutRest',
    method: 'post'
  })
}

// 获取TOKEN
export function getUserToken(userName, password) {
  return request({
    url: '/bidprocurement/common-login/login/getToken?userName=' + userName + '&password=' + password,
    method: 'post'
  })
}

// 获取防止重复提交TOKEN
export function getRepeatToken() {
  return request({
    url: '/bidprocurement/common-login/login/getRepeatToken',
    method: 'post'
  })
}

// 初始化国际化信息
export function mutiLangCode(planProject, langCode) {
  return request({
    url: '/bidprocurement/login/mutiLang/mutilangUtil/initMutiLang?mutiLangCode=' +
            planProject +
            '&langCode=' +
            langCode,
    method: 'post'
  })
}

// 图片验证码接口
// {
//   type:login:登陆时 expertRegister:注册时
//   a:时间戳
// }
export function randCodeImage(data) {
  return '/bidprocurement/common-login/login/randCodeImage' + createURL(data)
}
