auth.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import request from '@/sheep/request';
  2. const AuthUtil = {
  3. // 使用手机 + 密码登录
  4. login: (data) => {
  5. return request({
  6. url: '/member/auth/login',
  7. method: 'POST',
  8. data,
  9. custom: {
  10. showSuccess: true,
  11. loadingMsg: '登录中',
  12. successMsg: '登录成功',
  13. },
  14. });
  15. },
  16. // 使用手机 + 验证码登录
  17. smsLogin: (data) => {
  18. return request({
  19. // url: '/member/auth/sms-login',
  20. url: '/menduner/system/auth/send-sms-code ',
  21. method: 'POST',
  22. data,
  23. custom: {
  24. showSuccess: true,
  25. loadingMsg: '登录中',
  26. successMsg: '登录成功',
  27. },
  28. });
  29. },
  30. // 发送手机验证码
  31. sendSmsCode: (mobile, scene) => {
  32. return request({
  33. url: '/member/auth/send-sms-code',
  34. method: 'POST',
  35. data: {
  36. mobile,
  37. scene,
  38. },
  39. custom: {
  40. loadingMsg: '发送中',
  41. showSuccess: true,
  42. successMsg: '发送成功',
  43. },
  44. });
  45. },
  46. // 登出系统
  47. logout: () => {
  48. return request({
  49. url: '/member/auth/logout',
  50. method: 'POST',
  51. });
  52. },
  53. // 刷新令牌
  54. refreshToken: (refreshToken) => {
  55. return request({
  56. url: '/member/auth/refresh-token',
  57. method: 'POST',
  58. params: {
  59. refreshToken
  60. },
  61. custom: {
  62. loading: false, // 不用加载中
  63. showError: false, // 不展示错误提示
  64. },
  65. });
  66. },
  67. // 社交授权的跳转
  68. socialAuthRedirect: (type, redirectUri) => {
  69. return request({
  70. url: '/member/auth/social-auth-redirect',
  71. method: 'GET',
  72. params: {
  73. type,
  74. redirectUri,
  75. },
  76. custom: {
  77. showSuccess: true,
  78. loadingMsg: '登陆中',
  79. },
  80. });
  81. },
  82. // 社交快捷登录
  83. socialLogin: (type, code, state) => {
  84. return request({
  85. url: '/member/auth/social-login',
  86. method: 'POST',
  87. data: {
  88. type,
  89. code,
  90. state,
  91. },
  92. custom: {
  93. showSuccess: true,
  94. loadingMsg: '登陆中',
  95. },
  96. });
  97. },
  98. // 微信小程序的一键登录
  99. weixinMiniAppLogin: (phoneCode, loginCode, state) => {
  100. return request({
  101. url: '/member/auth/weixin-mini-app-login',
  102. method: 'POST',
  103. data: {
  104. phoneCode,
  105. loginCode,
  106. state
  107. },
  108. custom: {
  109. showSuccess: true,
  110. loadingMsg: '登陆中',
  111. successMsg: '登录成功',
  112. },
  113. });
  114. },
  115. // 创建微信 JS SDK 初始化所需的签名
  116. createWeixinMpJsapiSignature: (url) => {
  117. return request({
  118. url: '/member/auth/create-weixin-jsapi-signature',
  119. method: 'POST',
  120. params: {
  121. url
  122. },
  123. custom: {
  124. showError: false,
  125. showLoading: false,
  126. },
  127. })
  128. },
  129. //
  130. };
  131. export default AuthUtil;