user.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import { useMyRequest } from '~/composables/useFetchRequest'
  2. enum Api {
  3. Login = '/client-s003/s003Customer/login',
  4. Logout = '/client-s003/s003Customer/logout',
  5. Register = '/client/user/preRegister',
  6. ValidateRegister = '/client/user/register',
  7. ValidateEmail = '/client/user/forgetPassword',
  8. ResetOrChangePassword = '/client/user/changePassword',
  9. ValidateEmailIsExist = '/client-s003/s003Customer/lastLoginType',
  10. validateEmailIsWork = '/client-s003/s003Customer/getStateByEmail',
  11. SendEmailCode = '/client-s003/captcha/sms/send',
  12. SubmitInfo = '/client-s003/s003ProductCatalogue/download',
  13. UserInfo = '/client-s003/s003Customer/userinfo',
  14. DownloadRecord = '/client-s003/s003ProductCatalogue/downloadRecord',
  15. }
  16. /**
  17. * 下载记录
  18. */
  19. export async function downloadRecordApi(params: any) {
  20. return await useMyRequest().post(Api.DownloadRecord, params)
  21. }
  22. /**
  23. * 获取用户信息,获取更新后的用户信息
  24. */
  25. export async function getUpdateUserInfoApi(params?: any) {
  26. return await useMyRequest().get(Api.UserInfo, params)
  27. }
  28. /**
  29. * 提交用户信息
  30. */
  31. export async function submitInfoApi(params: any) {
  32. return await useMyRequest().post(Api.SubmitInfo, params)
  33. }
  34. /**
  35. * 验证邮箱是否失效
  36. */
  37. export async function validateEmailIsWorkApi(params: any) {
  38. return await useMyRequest().get(Api.validateEmailIsWork, params)
  39. }
  40. /**
  41. * 验证邮箱
  42. */
  43. export async function validateEmailIsExistApi(params: any) {
  44. return await useMyRequest().get(Api.ValidateEmailIsExist, params)
  45. }
  46. /**
  47. * 获取邮箱验证码
  48. */
  49. export async function getEmailCodeApi(params: any) {
  50. return await useMyRequest().post(Api.SendEmailCode, params)
  51. }
  52. /**
  53. * @description: user login api
  54. */
  55. export async function loginApi(params: any) {
  56. return await useMyRequest().post(Api.Login, params, { isForbiddenErrorPrompt: true })
  57. }
  58. /**
  59. * 预注册
  60. * @param params
  61. * @param mode
  62. * @returns
  63. */
  64. export async function registerApi(params: any) {
  65. return await useMyRequest().post(Api.Register, params)
  66. }
  67. /**
  68. * 注册
  69. * @param params
  70. * @returns
  71. */
  72. export async function validateRegisterApi(params: any) {
  73. return await useMyRequest().post(Api.ValidateRegister, params)
  74. }
  75. /**
  76. * 忘记密码,发送邮箱
  77. * @param params
  78. * @returns
  79. */
  80. export async function validateEmailApi(params: any) {
  81. return await useMyRequest().post(Api.ValidateEmail, params)
  82. }
  83. /**
  84. * 更新用户信息
  85. * @param params
  86. * @returns
  87. */
  88. export async function updateUserInfoApi(params: any) {
  89. return await useMyRequest().post(Api.UserInfo, params)
  90. }
  91. /**
  92. * 重置密码
  93. * @param params
  94. * @returns
  95. */
  96. export async function resetOrChangePasswordApi(params: any) {
  97. return await useMyRequest().post(Api.ResetOrChangePassword, params)
  98. }
  99. export async function logoutApi() {
  100. return await useMyRequest().get(Api.Logout)
  101. }