auth.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. "use strict";
  2. const sheep_request_index = require("../../request/index.js");
  3. const AuthUtil = {
  4. // 使用手机 + 密码登录
  5. login: (data) => {
  6. return sheep_request_index.request({
  7. url: "/member/auth/login",
  8. method: "POST",
  9. data,
  10. custom: {
  11. showSuccess: true,
  12. loadingMsg: "登录中",
  13. successMsg: "登录成功"
  14. }
  15. });
  16. },
  17. // 使用手机 + 验证码登录
  18. smsLogin: (data) => {
  19. return sheep_request_index.request({
  20. url: "/member/auth/sms-login",
  21. method: "POST",
  22. data,
  23. custom: {
  24. showSuccess: true,
  25. loadingMsg: "登录中",
  26. successMsg: "登录成功"
  27. }
  28. });
  29. },
  30. // 账号注册
  31. register: (data) => {
  32. return sheep_request_index.request({
  33. url: "/member/auth/sms-register",
  34. method: "POST",
  35. data,
  36. custom: {
  37. showSuccess: true,
  38. loadingMsg: "注册中",
  39. successMsg: "注册成功"
  40. }
  41. });
  42. },
  43. // 注册校验用户名是否重复
  44. verifyUsername: (username) => {
  45. return sheep_request_index.request({
  46. url: "/member/user/verifyUsername?username=" + username,
  47. method: "GET"
  48. });
  49. },
  50. // 发送手机验证码
  51. sendSmsCode: (mobile, scene) => {
  52. return sheep_request_index.request({
  53. url: "/member/auth/send-sms-code",
  54. method: "POST",
  55. data: {
  56. mobile,
  57. scene
  58. },
  59. custom: {
  60. loadingMsg: "发送中",
  61. showSuccess: true,
  62. successMsg: "发送成功"
  63. }
  64. });
  65. },
  66. // 微信公众号登录选择账号登录
  67. selectUsernameLogin: (data) => {
  68. return sheep_request_index.request({
  69. url: "/member/auth/select-username-login",
  70. method: "POST",
  71. data,
  72. custom: {
  73. showSuccess: true,
  74. loadingMsg: "登录中",
  75. successMsg: "登录成功"
  76. }
  77. });
  78. },
  79. // 微信公众号注册
  80. officialRegister: (data) => {
  81. return sheep_request_index.request({
  82. url: "/member/auth/social-register",
  83. method: "POST",
  84. data,
  85. custom: {
  86. showSuccess: true,
  87. loadingMsg: "注册中",
  88. successMsg: "注册成功"
  89. }
  90. });
  91. },
  92. // 微信公众号首次登录校验手机
  93. OfficialEnterLogin: (reqVO, registerReqVO) => {
  94. return sheep_request_index.request({
  95. url: "/member/auth/social-login-validate-sms-code",
  96. method: "POST",
  97. data: {
  98. reqVO,
  99. registerReqVO
  100. }
  101. });
  102. },
  103. // 登出系统
  104. logout: () => {
  105. return sheep_request_index.request({
  106. url: "/member/auth/logout",
  107. method: "POST"
  108. });
  109. },
  110. // 刷新令牌
  111. refreshToken: (refreshToken) => {
  112. return sheep_request_index.request({
  113. url: "/member/auth/refresh-token",
  114. method: "POST",
  115. params: {
  116. refreshToken
  117. },
  118. custom: {
  119. loading: false,
  120. // 不用加载中
  121. showError: false
  122. // 不展示错误提示
  123. }
  124. });
  125. },
  126. // 社交授权的跳转
  127. socialAuthRedirect: (type, redirectUri) => {
  128. return sheep_request_index.request({
  129. url: "/member/auth/social-auth-redirect",
  130. method: "GET",
  131. params: {
  132. type,
  133. redirectUri
  134. },
  135. custom: {
  136. showSuccess: true,
  137. loadingMsg: "登陆中"
  138. }
  139. });
  140. },
  141. // 社交快捷登录
  142. socialLogin: (type, code, state) => {
  143. return sheep_request_index.request({
  144. url: "/member/auth/social-login",
  145. method: "POST",
  146. data: {
  147. type,
  148. code,
  149. state
  150. },
  151. custom: {
  152. showSuccess: true,
  153. loadingMsg: "登陆中"
  154. }
  155. });
  156. },
  157. // 微信小程序的一键登录
  158. weixinMiniAppLogin: (phoneCode, loginCode, state) => {
  159. return sheep_request_index.request({
  160. url: "/member/auth/weixin-mini-app-login",
  161. method: "POST",
  162. data: {
  163. phoneCode,
  164. loginCode,
  165. state
  166. },
  167. custom: {
  168. showSuccess: true,
  169. loadingMsg: "登陆中",
  170. successMsg: "登录成功"
  171. }
  172. });
  173. },
  174. // 创建微信 JS SDK 初始化所需的签名
  175. createWeixinMpJsapiSignature: (url) => {
  176. return sheep_request_index.request({
  177. url: "/member/auth/create-weixin-jsapi-signature",
  178. method: "POST",
  179. params: {
  180. url
  181. },
  182. custom: {
  183. showError: false,
  184. showLoading: false
  185. }
  186. });
  187. }
  188. //
  189. };
  190. exports.AuthUtil = AuthUtil;