Login.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import FetchRequest from "@/api/FetchRequest";
  2. // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  3. // @ts-ignore
  4. import packageJson from '/package.json'
  5. const version = packageJson.version
  6. interface loginBody {
  7. username: string;
  8. password: string;
  9. code: string;
  10. uuid: string;
  11. }
  12. interface rePasswBody {
  13. username: string;
  14. password: string;
  15. code: string;
  16. }
  17. // 登录方法
  18. export const login = (
  19. username: string,
  20. password: string,
  21. code: string,
  22. uuid: string
  23. ) => {
  24. const data: loginBody = {
  25. username,
  26. password,
  27. code,
  28. uuid,
  29. };
  30. return FetchRequest.post("/login", JSON.stringify(data), false);
  31. };
  32. // 安全登录方法
  33. export const savelogin = (
  34. username: string,
  35. password: string,
  36. code: string,
  37. uuid: string
  38. ) => {
  39. const data: loginBody = {
  40. username,
  41. password,
  42. code,
  43. uuid,
  44. };
  45. return FetchRequest.post("/security/safeLogin", JSON.stringify(data), false);
  46. };
  47. //获取邮箱验证码 /getcode?email=${email}
  48. export const getEmailcode = (
  49. email: string,
  50. ) => {
  51. return FetchRequest.get(`/getcode?email=${email}`, false);
  52. };
  53. //用户重置密码获取邮箱验证码
  54. export const getcodeByUsername = (
  55. username: string,
  56. ) => {
  57. return FetchRequest.get(`/getcodeByUsername?username=${username}`, false);
  58. };
  59. //clearVoipTk
  60. export const clearVoipTk = (data: string) => {//参数{voipTk:***}
  61. return FetchRequest.post("/system/user/clearVoipTk",data, false);
  62. };
  63. //用户重置密码
  64. export const resetPassword = (data: rePasswBody) => {
  65. return FetchRequest.post("/resetPwd",JSON.stringify(data), false);
  66. };
  67. //注销账号
  68. export const zhuxiaozhanghao = (data:any) => {
  69. return FetchRequest.post("/delUser",JSON.stringify(data), false);
  70. };
  71. // 注册方法
  72. export const register = (data: loginBody) => FetchRequest.post('/register', JSON.stringify(data), false)
  73. // 获取用户详细信息
  74. export const getInfo = () => {
  75. return FetchRequest.get("/getInfo", false);
  76. };
  77. // 退出方法
  78. export const logout = () => FetchRequest.post("/logout", "", true);
  79. // 获取验证码
  80. export const getCodeImg = () => FetchRequest.get(`/captchaImage?version=${version}`, false)