/*
 * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @Date: 2023-07-07 14:02:05
 * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @LastEditTime: 2023-07-28 10:28:12
 * @FilePath: /water_dealer-agent/src/api/login.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import request from '@/utils/request'

const userApi = {
  SendSms: '/staff/verify',
  Login: '/auth/sms',
  Logout: '/auth/logout',
  CommonLogin: '/middles/auth/login', // 登录接口
  forgetPassword: '/staff/forget/password',
  password: '/middles/user/password', // 修改密码
  // get my info
  middleUser: '/middles/user', // 获取经销商信息
  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 getMiddleUser () {
  return request({
    url: userApi.middleUser,
    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
  })
}
