auth.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. url: '/menduner/system/auth/refresh-token',
  61. method: 'POST',
  62. params: {
  63. refreshToken
  64. },
  65. custom: {
  66. loading: false, // 不用加载中
  67. showError: false, // 不展示错误提示
  68. },
  69. });
  70. },
  71. // 社交授权的跳转
  72. socialAuthRedirect: (type, redirectUri) => {
  73. return request({
  74. url: '/member/auth/social-auth-redirect',
  75. method: 'GET',
  76. params: {
  77. type,
  78. redirectUri,
  79. },
  80. custom: {
  81. showSuccess: true,
  82. loadingMsg: '登陆中',
  83. },
  84. });
  85. },
  86. // 社交快捷登录
  87. socialLogin: (type, code, state) => {
  88. return request({
  89. url: '/member/auth/social-login',
  90. method: 'POST',
  91. data: {
  92. type,
  93. code,
  94. state,
  95. },
  96. custom: {
  97. showSuccess: true,
  98. loadingMsg: '登陆中',
  99. },
  100. });
  101. },
  102. // 微信小程序的一键登录
  103. weixinMiniAppLogin: (phoneCode, loginCode, state) => {
  104. return request({
  105. url: '/member/auth/weixin-mini-app-login',
  106. method: 'POST',
  107. data: {
  108. phoneCode,
  109. loginCode,
  110. state
  111. },
  112. custom: {
  113. showSuccess: true,
  114. loadingMsg: '登陆中',
  115. successMsg: '登录成功',
  116. },
  117. });
  118. },
  119. // 创建微信 JS SDK 初始化所需的签名
  120. createWeixinMpJsapiSignature: (url) => {
  121. return request({
  122. url: '/member/auth/create-weixin-jsapi-signature',
  123. method: 'POST',
  124. params: {
  125. url
  126. },
  127. custom: {
  128. showError: false,
  129. showLoading: false,
  130. },
  131. })
  132. },
  133. //
  134. };
  135. export default AuthUtil;