auth.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. selectUsernameLogin: (data) => {
  67. return request({
  68. url: '/member/auth/select-username-login',
  69. method: 'POST',
  70. data,
  71. custom: {
  72. showSuccess: true,
  73. loadingMsg: '登录中',
  74. successMsg: '登录成功',
  75. },
  76. });
  77. },
  78. // 微信公众号首次登录校验手机
  79. OfficialEnterLogin: (reqVO, loginReqVO) => {
  80. return request({
  81. url: '/member/auth/social-login-validate-sms-code',
  82. method: 'POST',
  83. data: {
  84. reqVO,
  85. loginReqVO
  86. },
  87. });
  88. },
  89. // 登出系统
  90. logout: () => {
  91. return request({
  92. url: '/member/auth/logout',
  93. method: 'POST',
  94. });
  95. },
  96. // 刷新令牌
  97. refreshToken: (refreshToken) => {
  98. return request({
  99. url: '/member/auth/refresh-token',
  100. method: 'POST',
  101. params: {
  102. refreshToken
  103. },
  104. custom: {
  105. loading: false, // 不用加载中
  106. showError: false, // 不展示错误提示
  107. },
  108. });
  109. },
  110. // 社交授权的跳转
  111. socialAuthRedirect: (type, redirectUri) => {
  112. return request({
  113. url: '/member/auth/social-auth-redirect',
  114. method: 'GET',
  115. params: {
  116. type,
  117. redirectUri,
  118. },
  119. custom: {
  120. showSuccess: true,
  121. loadingMsg: '登陆中',
  122. },
  123. });
  124. },
  125. // 社交快捷登录
  126. socialLogin: (type, code, state) => {
  127. return request({
  128. url: '/member/auth/social-login',
  129. method: 'POST',
  130. data: {
  131. type,
  132. code,
  133. state,
  134. },
  135. custom: {
  136. showSuccess: true,
  137. loadingMsg: '登陆中',
  138. },
  139. });
  140. },
  141. // 微信小程序的一键登录
  142. weixinMiniAppLogin: (phoneCode, loginCode, state) => {
  143. return request({
  144. url: '/member/auth/weixin-mini-app-login',
  145. method: 'POST',
  146. data: {
  147. phoneCode,
  148. loginCode,
  149. state
  150. },
  151. custom: {
  152. showSuccess: true,
  153. loadingMsg: '登陆中',
  154. successMsg: '登录成功',
  155. },
  156. });
  157. },
  158. // 创建微信 JS SDK 初始化所需的签名
  159. createWeixinMpJsapiSignature: (url) => {
  160. return request({
  161. url: '/member/auth/create-weixin-jsapi-signature',
  162. method: 'POST',
  163. params: {
  164. url
  165. },
  166. custom: {
  167. showError: false,
  168. showLoading: false,
  169. },
  170. })
  171. },
  172. //
  173. };
  174. export default AuthUtil;