import request from '@/utils/request'

const userApi = {
  SendSms: '/staff/verify',
  Login: '/auth/sms',
  Logout: '/auth/logout',
  CommonLogin: '/staff/login',
  forgetPassword: '/staff/forget/password',
  password: '/staff/password',
  // get my info
  UserPermission: '/staff',
  getScanCode: '/staff/scan_code',
  getVerifyScanCode: '/staff/verify_subscribe'
}

export function login (parameter) {
  return request({
    url: userApi.Login,
    method: 'post',
    data: parameter
  })
}

/**
 * 通用账号密码登录
 * @param parameter
 * @returns {*}
 */
export function commonLogin (parameter) {
  parameter.redirectUrl = window.location.href
  return request({
    url: userApi.CommonLogin,
    method: 'post',
    data: parameter
  })
}

export function forgetPassword (parameter) {
  return request({
    url: userApi.forgetPassword,
    method: 'post',
    data: parameter
  })
}

export function password (parameter) {
  return request({
    url: userApi.password,
    method: 'post',
    data: parameter
  })
}

export function getSmsCaptcha (parameter) {
  return request({
    url: userApi.SendSms,
    method: 'post',
    data: parameter
  })
}

export function getPermission () {
  return request({
    url: userApi.UserPermission,
    method: 'get'
  })
}

export function logout () {
  return request({
    url: userApi.Logout,
    method: 'post'
  })
}
// 获取关注二维码
export function getScanCode () {
  return request({
    url: userApi.getScanCode
  })
}

// 判断用户是否关注二维码
export function getVerifyScanCode () {
  return request({
    url: userApi.getVerifyScanCode
  })
}
