index.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import request from '@/config/axios'
  2. import { getRefreshToken } from '@/utils/auth'
  3. import type { 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 refreshToken = () => {
  18. return request.post({ url: '/system/auth/refresh-token?refreshToken=' + getRefreshToken() })
  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 loginOut = () => {
  26. return request.post({ url: '/system/auth/logout' })
  27. }
  28. // 获取用户权限信息
  29. export const getInfo = () => {
  30. return request.get({ url: '/system/auth/get-permission-info' })
  31. }
  32. //获取登录验证码
  33. export const sendSmsCode = (data: SmsCodeVO) => {
  34. return request.post({ url: '/system/auth/send-sms-code', data })
  35. }
  36. // 短信验证码登录
  37. export const smsLogin = (data: SmsLoginVO) => {
  38. return request.post({ url: '/system/auth/sms-login', data })
  39. }
  40. // 社交快捷登录,使用 code 授权码
  41. export function socialLogin(type: string, code: string, state: string) {
  42. return request.post({
  43. url: '/system/auth/social-login',
  44. data: {
  45. type,
  46. code,
  47. state
  48. }
  49. })
  50. }
  51. // 社交授权的跳转
  52. export const socialAuthRedirect = (type: number, redirectUri: string) => {
  53. return request.get({
  54. url: '/system/auth/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri
  55. })
  56. }
  57. // 获取验证图片以及 token
  58. export const getCode = (data) => {
  59. return request.postOriginal({ url: 'system/captcha/get', data })
  60. }
  61. // 滑动或者点选验证
  62. export const reqCheck = (data) => {
  63. return request.postOriginal({ url: 'system/captcha/check', data })
  64. }