auth.js 3.6 KB

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