auth.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. // TODO 芋艿:登录成功???
  68. },
  69. });
  70. },
  71. // 创建微信 JS SDK 初始化所需的签名
  72. createWeixinMpJsapiSignature: (url) => {
  73. return request({
  74. url: '/app-api/member/auth/create-weixin-jsapi-signature',
  75. method: 'POST',
  76. params: {
  77. url
  78. },
  79. custom: {
  80. showError: false,
  81. showLoading: false,
  82. },
  83. })
  84. },
  85. };
  86. export default AuthUtil;