login.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import request from '@/utils/request'
  2. // 登录方法
  3. export function login(username, password, code, uuid) {
  4. const data = {
  5. username,
  6. password,
  7. code,
  8. uuid
  9. }
  10. return request({
  11. url: '/system/login',
  12. method: 'post',
  13. data: data
  14. })
  15. }
  16. // 获取用户详细信息
  17. export function getInfo() {
  18. return request({
  19. url: '/system/get-permission-info',
  20. method: 'get'
  21. })
  22. }
  23. // 退出方法
  24. export function logout() {
  25. return request({
  26. url: '/system/logout',
  27. method: 'post'
  28. })
  29. }
  30. // 获取验证码
  31. export function getCodeImg() {
  32. return request({
  33. url: '/system/captcha/get-image',
  34. method: 'get',
  35. timeout: 20000
  36. })
  37. }
  38. // 社交授权的跳转
  39. export function socialAuthRedirect(type, redirectUri) {
  40. return request({
  41. url: '/system/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri,
  42. method: 'get'
  43. })
  44. }
  45. // 社交登录,使用 code 授权码
  46. export function socialLogin(type, code, state) {
  47. return request({
  48. url: '/system/social-login',
  49. method: 'post',
  50. data: {
  51. type,
  52. code,
  53. state
  54. }
  55. })
  56. }
  57. // 社交登录,使用 code 授权码 + + 账号密码
  58. export function socialLogin2(type, code, state, username, password) {
  59. return request({
  60. url: '/system/social-login2',
  61. method: 'post',
  62. data: {
  63. type,
  64. code,
  65. state,
  66. username,
  67. password
  68. }
  69. })
  70. }
  71. // 社交绑定,使用 code 授权码
  72. export function socialBind(type, code, state) {
  73. return request({
  74. url: '/system/social-bind',
  75. method: 'post',
  76. data: {
  77. type,
  78. code,
  79. state,
  80. }
  81. })
  82. }
  83. // 取消社交绑定
  84. export function socialUnbind(type, unionId) {
  85. return request({
  86. url: '/system/social-unbind',
  87. method: 'delete',
  88. data: {
  89. type,
  90. unionId
  91. }
  92. })
  93. }