auth.js 2.9 KB

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