index.ts 2.2 KB

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