index.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import request from '@/config/axios'
  2. import { getRefreshToken } from '@/utils/auth'
  3. import type { RegisterVO, UserLoginVO } from './types'
  4. export interface SmsCodeVO {
  5. mobile: string
  6. scene: number
  7. }
  8. export interface SmsLoginVO {
  9. mobile: string
  10. code: string
  11. }
  12. // 登录
  13. export const login = (data: UserLoginVO) => {
  14. return request.post({ url: '/system/auth/login', data })
  15. }
  16. // 注册
  17. export const register = (data: RegisterVO) => {
  18. return request.post({ url: '/system/auth/register', data })
  19. }
  20. // 使用租户名,获得租户编号
  21. export const getTenantIdByName = (name: string) => {
  22. return request.get({ url: '/system/tenant/get-id-by-name?name=' + name })
  23. }
  24. // 使用租户域名,获得租户信息
  25. export const getTenantByWebsite = (website: string) => {
  26. return request.get({ url: '/system/tenant/get-by-website?website=' + website })
  27. }
  28. // 登出
  29. export const loginOut = () => {
  30. return request.post({ url: '/system/auth/logout' })
  31. }
  32. // 获取用户权限信息
  33. export const getInfo = () => {
  34. return request.get({ url: '/system/auth/get-permission-info' })
  35. }
  36. //获取登录验证码
  37. export const sendSmsCode = (data: SmsCodeVO) => {
  38. return request.post({ url: '/system/auth/send-sms-code', data })
  39. }
  40. // 短信验证码登录
  41. export const smsLogin = (data: SmsLoginVO) => {
  42. return request.post({ url: '/system/auth/sms-login', data })
  43. }
  44. // 社交快捷登录,使用 code 授权码
  45. export function socialLogin(type: string, code: string, state: string) {
  46. return request.post({
  47. url: '/system/auth/social-login',
  48. data: {
  49. type,
  50. code,
  51. state
  52. }
  53. })
  54. }
  55. // 社交授权的跳转
  56. export const socialAuthRedirect = (type: number, redirectUri: string) => {
  57. return request.get({
  58. url: '/system/auth/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri
  59. })
  60. }
  61. // 获取验证图片以及 token
  62. export const getCode = (data: any) => {
  63. debugger
  64. return request.postOriginal({ url: 'system/captcha/get', data })
  65. }
  66. // 滑动或者点选验证
  67. export const reqCheck = (data: any) => {
  68. return request.postOriginal({ url: 'system/captcha/check', data })
  69. }
  70. // 通过短信重置密码
  71. export const smsResetPassword = (data: any) => {
  72. return request.post({ url: '/system/auth/sms-reset-password', data })
  73. }