index.ts 2.6 KB

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