auth.js 2.2 KB

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