login.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import request from '@/utils/request'
  2. const client_id = 'web'
  3. const client_secret = '123456'
  4. const scope = 'server'
  5. // 登录方法
  6. export function login(username, password, code, uuid) {
  7. const grant_type = 'password'
  8. return request({
  9. url: '/auth/oauth/token',
  10. method: 'post',
  11. params: { username, password, code, uuid, client_id, client_secret, grant_type, scope }
  12. })
  13. }
  14. // 刷新方法
  15. export function refreshToken(refresh_token) {
  16. const grant_type = 'refresh_token'
  17. return request({
  18. url: '/auth/oauth/token',
  19. method: 'post',
  20. params: { client_id, client_secret, grant_type, scope, refresh_token }
  21. })
  22. }
  23. // 获取用户详细信息
  24. export function getInfo() {
  25. return request({
  26. url: '/system/user/getInfo',
  27. method: 'get'
  28. })
  29. }
  30. // 退出方法
  31. export function logout() {
  32. return request({
  33. url: '/auth/token/logout',
  34. method: 'delete'
  35. })
  36. }
  37. // 获取验证码
  38. export function getCodeImg() {
  39. return request({
  40. url: '/code',
  41. method: 'get'
  42. })
  43. }