login.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. })
  36. }
  37. // 社交授权的跳转
  38. export function socialAuthRedirect(type, redirectUri) {
  39. return request({
  40. url: '/system/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri,
  41. method: 'get'
  42. })
  43. }
  44. // 社交登录,使用 code 授权码
  45. export function socialLogin(type, code, state) {
  46. return request({
  47. url: '/system/social-login',
  48. method: 'post',
  49. data: {
  50. type,
  51. code,
  52. state
  53. }
  54. })
  55. }
  56. // 社交登录,使用 code 授权码 + + 账号密码
  57. export function socialLogin2(type, code, state, username, password) {
  58. return request({
  59. url: '/system/social-login2',
  60. method: 'post',
  61. data: {
  62. type,
  63. code,
  64. state,
  65. username,
  66. password
  67. }
  68. })
  69. }
  70. // 社交绑定,使用 code 授权码
  71. export function socialBind(type, code, state) {
  72. return request({
  73. url: '/system/social-bind',
  74. method: 'post',
  75. data: {
  76. type,
  77. code,
  78. state,
  79. }
  80. })
  81. }
  82. // 取消社交绑定
  83. export function socialUnbind(type, unionId) {
  84. return request({
  85. url: '/system/social-unbind',
  86. method: 'delete',
  87. data: {
  88. type,
  89. unionId
  90. }
  91. })
  92. }