http.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { AuthModule } from "..";
  2. export const https = AuthModule.http({
  3. // 获取验证码
  4. getSmsCode(data: {
  5. email?: string;
  6. phone?: string;
  7. use: "login" | "register" | "resetPasswd" | "bindAccount";
  8. }) {
  9. return this.request(data.phone ? "/sms" : "/senEmail", {
  10. method: "POST",
  11. data,
  12. });
  13. },
  14. // 个人账号注册
  15. personRegister(data: { phone: string; password: string }) {
  16. return this.request("/register", {
  17. method: "POST",
  18. data,
  19. });
  20. },
  21. // 邮箱注册
  22. emailRegist(data: { email: string; password: string }) {
  23. return this.request("/user/register/email", {
  24. data,
  25. method: "POST",
  26. });
  27. },
  28. // 个人账号密码登录
  29. personPwdLogin(data: { phone: string; password: string; key: string }) {
  30. return this.request("/login/password", {
  31. method: "POST",
  32. data,
  33. });
  34. },
  35. // 个人账号短信登录
  36. personSmsLogin(data: { phone: string; code: string; key: string }) {
  37. return this.request("/login/sms", {
  38. method: "POST",
  39. data,
  40. });
  41. },
  42. /** 微信登录 */
  43. personWechatLogin(params: { [key: string]: any }) {
  44. return this.request("/wechat/login", { method: "POST", data: params });
  45. },
  46. // 获取用户信息
  47. getProfile() {
  48. return this.request("/profile", {
  49. method: "GET",
  50. silence: false,
  51. });
  52. },
  53. // 更新用户信息
  54. updateProfile(data: any) {
  55. return this.request("/profile", {
  56. method: "POST",
  57. data,
  58. });
  59. },
  60. // 重置登录密码 、 忘记密码
  61. resetPwd(data: {
  62. email?: string;
  63. phone?: string;
  64. password: string;
  65. code: string;
  66. }) {
  67. return this.request("/resetpwd", {
  68. method: "POST",
  69. data,
  70. });
  71. },
  72. // 绑定手机号码、邮箱
  73. bindAccount(data: { phone?: string; email?: string; code: string }) {
  74. return this.request("/bind/account ", { method: "post", data });
  75. },
  76. });