auth.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. register: (data) => {
  31. return request({
  32. url: '/member/auth/sms-register',
  33. method: 'POST',
  34. data,
  35. custom: {
  36. showSuccess: true,
  37. loadingMsg: '注册中',
  38. successMsg: '注册成功',
  39. },
  40. });
  41. },
  42. // 注册校验用户名是否重复
  43. verifyUsername: (username) => {
  44. return request({
  45. url: '/member/user/verifyUsername?username='+username,
  46. method: 'GET',
  47. });
  48. },
  49. // 发送手机验证码
  50. sendSmsCode: (mobile, scene) => {
  51. return request({
  52. url: '/member/auth/send-sms-code',
  53. method: 'POST',
  54. data: {
  55. mobile,
  56. scene,
  57. },
  58. custom: {
  59. loadingMsg: '发送中',
  60. showSuccess: true,
  61. successMsg: '发送成功',
  62. },
  63. });
  64. },
  65. // 微信公众号首次登录校验手机
  66. OfficialEnterLogin: (reqVO, loginReqVO) => {
  67. return request({
  68. url: '/member/auth/social-login-validate-sms-code',
  69. method: 'POST',
  70. data: {
  71. reqVO,
  72. loginReqVO
  73. },
  74. });
  75. },
  76. // 登出系统
  77. logout: () => {
  78. return request({
  79. url: '/member/auth/logout',
  80. method: 'POST',
  81. });
  82. },
  83. // 刷新令牌
  84. refreshToken: (refreshToken) => {
  85. return request({
  86. url: '/member/auth/refresh-token',
  87. method: 'POST',
  88. params: {
  89. refreshToken
  90. },
  91. custom: {
  92. loading: false, // 不用加载中
  93. showError: false, // 不展示错误提示
  94. },
  95. });
  96. },
  97. // 社交授权的跳转
  98. socialAuthRedirect: (type, redirectUri) => {
  99. return request({
  100. url: '/member/auth/social-auth-redirect',
  101. method: 'GET',
  102. params: {
  103. type,
  104. redirectUri,
  105. },
  106. custom: {
  107. showSuccess: true,
  108. loadingMsg: '登陆中',
  109. },
  110. });
  111. },
  112. // 社交快捷登录
  113. socialLogin: (type, code, state) => {
  114. return request({
  115. url: '/member/auth/social-login',
  116. method: 'POST',
  117. data: {
  118. type,
  119. code,
  120. state,
  121. },
  122. custom: {
  123. showSuccess: true,
  124. loadingMsg: '登陆中',
  125. },
  126. });
  127. },
  128. // 微信小程序的一键登录
  129. weixinMiniAppLogin: (phoneCode, loginCode, state) => {
  130. return request({
  131. url: '/member/auth/weixin-mini-app-login',
  132. method: 'POST',
  133. data: {
  134. phoneCode,
  135. loginCode,
  136. state
  137. },
  138. custom: {
  139. showSuccess: true,
  140. loadingMsg: '登陆中',
  141. successMsg: '登录成功',
  142. },
  143. });
  144. },
  145. // 创建微信 JS SDK 初始化所需的签名
  146. createWeixinMpJsapiSignature: (url) => {
  147. return request({
  148. url: '/member/auth/create-weixin-jsapi-signature',
  149. method: 'POST',
  150. params: {
  151. url
  152. },
  153. custom: {
  154. showError: false,
  155. showLoading: false,
  156. },
  157. })
  158. },
  159. //
  160. };
  161. export default AuthUtil;