auth.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import request from '@/sheep/request';
  2. const AuthUtil = {
  3. // 使用手机 + 密码登录
  4. login: (data) => {
  5. return request({
  6. url: '/app-api/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: '/app-api/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: '/app-api/member/auth/send-sms-code',
  33. method: 'POST',
  34. data: {
  35. mobile,
  36. scene,
  37. },
  38. custom: {
  39. loadingMsg: '发送中',
  40. showSuccess: true,
  41. successMsg: '发送成功',
  42. },
  43. });
  44. },
  45. // 登出系统
  46. logout: () => {
  47. return request({
  48. url: '/app-api/member/auth/logout',
  49. method: 'POST',
  50. });
  51. },
  52. // 社交授权的跳转
  53. socialAuthRedirect: (type, redirectUri) => {
  54. return request({
  55. url: '/app-api/member/auth/social-auth-redirect',
  56. method: 'GET',
  57. params: {
  58. type,
  59. redirectUri,
  60. },
  61. custom: {
  62. showSuccess: true,
  63. loadingMsg: '登陆中',
  64. },
  65. });
  66. },
  67. // 社交快捷登录
  68. socialLogin: (type, code, state) => {
  69. return request({
  70. url: '/app-api/member/auth/social-login',
  71. method: 'POST',
  72. data: {
  73. type,
  74. code,
  75. state,
  76. },
  77. custom: {
  78. showSuccess: true,
  79. loadingMsg: '登陆中',
  80. },
  81. });
  82. },
  83. // 微信小程序的一键登录
  84. weixinMiniAppLogin: (phoneCode, loginCode, state) => {
  85. return request({
  86. url: '/app-api/member/auth/weixin-mini-app-login',
  87. method: 'POST',
  88. data: {
  89. phoneCode,
  90. loginCode,
  91. state
  92. },
  93. custom: {
  94. showSuccess: true,
  95. loadingMsg: '登陆中',
  96. successMsg: '登录成功',
  97. },
  98. });
  99. },
  100. // 创建微信 JS SDK 初始化所需的签名
  101. createWeixinMpJsapiSignature: (url) => {
  102. return request({
  103. url: '/app-api/member/auth/create-weixin-jsapi-signature',
  104. method: 'POST',
  105. params: {
  106. url
  107. },
  108. custom: {
  109. showError: false,
  110. showLoading: false,
  111. },
  112. })
  113. },
  114. };
  115. export default AuthUtil;