index.ts 2.4 KB

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