auth.js 2.8 KB

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