user.js 960 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import http from '@/http/api.js'
  2. // 获取token
  3. const token = (tenantId, username, password, type) => {
  4. return http.request({
  5. url: '/api/blade-auth/oauth/token',
  6. method: 'POST',
  7. header: {
  8. 'Tenant-Id': tenantId
  9. },
  10. params: {
  11. tenantId,
  12. username,
  13. password,
  14. grant_type: "password",
  15. scope: "all",
  16. type
  17. }
  18. })
  19. }
  20. const refreshToken = (refresh_token, tenantId) => {
  21. return http.request({
  22. url: '/api/blade-auth/oauth/token',
  23. method: 'post',
  24. headers: {
  25. 'Tenant-Id': tenantId
  26. },
  27. params: {
  28. tenantId,
  29. refresh_token,
  30. grant_type: "refresh_token",
  31. scope: "all",
  32. }
  33. })
  34. }
  35. // 获取用户信息
  36. const userInfo = () => {
  37. return http.request({
  38. url: '/api/blade-system/user/info',
  39. method: 'GET',
  40. })
  41. }
  42. // 获取用户信息
  43. export const getUser = (id) => {
  44. return http.request({
  45. url: '/api/blade-system/user/detail',
  46. method: 'GET',
  47. params: { id }
  48. })
  49. }
  50. export default {
  51. token,
  52. userInfo,
  53. refreshToken
  54. }