login.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import request from '@/utils/request';
  2. import { AxiosPromise } from 'axios';
  3. // pc端固定客户端授权id
  4. const clientId = import.meta.env.VITE_APP_CLIENT_ID;
  5. export function login(data) {
  6. const params = {
  7. ...data,
  8. clientId: data.clientId || clientId,
  9. grantType: data.grantType || 'password'
  10. };
  11. return request({
  12. url: '/api/auth/login',
  13. headers: {
  14. isToken: false,
  15. isEncrypt: true,
  16. repeatSubmit: false
  17. },
  18. method: 'post',
  19. data: params
  20. });
  21. }
  22. /**
  23. * 注销
  24. */
  25. export function logout() {
  26. return request({
  27. url: '/api/auth/logout',
  28. method: 'post'
  29. });
  30. }
  31. /**
  32. * 获取验证码
  33. */
  34. export function getCodeImg() {
  35. return request({
  36. url: '/api/auth/code',
  37. headers: {
  38. isToken: false
  39. },
  40. method: 'get',
  41. timeout: 20000
  42. });
  43. }
  44. // 获取租户列表
  45. export function getTenantList() {
  46. return request({
  47. url: '/api/auth/tenant/list',
  48. headers: {
  49. isToken: false
  50. },
  51. method: 'get'
  52. });
  53. }
  54. // 获取用户详细信息
  55. export function getInfo() {
  56. return request({
  57. url: '/api/system/user/getInfo',
  58. method: 'get'
  59. });
  60. }
  61. /**
  62. * 粤政易登录
  63. */
  64. export function callback(data): AxiosPromise<any> {
  65. const LoginData = {
  66. ...data,
  67. clientId: clientId,
  68. grantType: 'social'
  69. };
  70. return request({
  71. url: '/auth/yzy/callback',
  72. headers: {
  73. isToken: false,
  74. isEncrypt: true,
  75. repeatSubmit: false
  76. },
  77. method: 'post',
  78. data: LoginData
  79. });
  80. }