import fetch from '../fetch';
import { getBaseUrl, getSaasDomain, getSaasApiDomain } from '@/utils/index'
import utils from '@/utils/followup/followupUtils';

const headers = {
  // sysCode: 9,
  productType: 1,  // productType 产品线类型，1 表示云鹊医产品系，2 表示云鹊健康产品系
  sourceType:  3,  // sourceType 终端来源，1 表示安卓，2 表示 ios，3 表示 web，4 表示 H5 登录，5 表示 admin 后台
}

// 获取 RSA public key
export const getPubKey = (params) => {
  return fetch({
    headers,
    url: getBaseUrl(`account/cipher/key`),
    method: 'get',
    params: params,
    description: 'get public key',
  })
};

// 密码登录
export const handleLogin = data => {
  return fetch({
    headers,
    url: getBaseUrl(`account/login`),
    method: 'post',
    data: data,
    description: '密码登录',
  })
}

// 密码退出登录
export const handleLogout = data => {
  return fetch({
    headers,
    url: getBaseUrl(`account/logout`),
    method: 'get',
    data: data,
    description: '密码退出登录',
  })
}

// 获取图形验证码
export const handleGetCaptcha = data => {
  return fetch({
    headers,
    url: getBaseUrl(`account/account/captcha`),
    method: 'get',
    data: data,
    description: '获取图形验证码',
  })
}

// 忘记密码时 获取短信验证码
export const handleGetAuthCode = data => {
  return fetch({
    headers,
    url: getBaseUrl(`account/account/authCode`),
    method: 'post',
    data: data,
    description: '获取短信验证码',
  })
}

// 重设密码
export const handleResetPWD = data => {
  return fetch({
    headers,
    url: getBaseUrl(`account/password/reset`),
    method: 'post',
    data: data,
    description: '忘记密码之重设密码',
  })
}

// 判断是否同意协议
export const handleAgreement = data => {
  return fetch({
    headers,
    url: getBaseUrl(`api-ws/agreements/consent`),
    method: 'get',
    params: data,
    description: '检查用户同意的协议',
  })
}


