index.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 getAsyncRoutes = () => {
  34. return request.get({ url: '/system/auth/list-menus' })
  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. // 社交授权的跳转
  45. export const socialAuthRedirect = (type: number, redirectUri: string) => {
  46. return request.get({
  47. url: '/system/auth/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri
  48. })
  49. }
  50. // 获取验证图片以及 token
  51. export const getCode = (data) => {
  52. return request.postOriginal({ url: 'system/captcha/get', data })
  53. }
  54. // 滑动或者点选验证
  55. export const reqCheck = (data) => {
  56. return request.postOriginal({ url: 'system/captcha/check', data })
  57. }