account.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import { get, post } from '@/utils/request'
  2. const accountApi = {
  3. checkUsernameApi: '/api/user/account/check/username',
  4. selectUsernameApi: '/api/user/account/select/username',
  5. checkEmailApi: '/api/user/account/check/email',
  6. verifyCodeApi: '/api/auth/code/verify',
  7. captchaCodeApi: '/api/auth/code/captcha',
  8. pubkeyApi: '/api/auth/code/pubkey',
  9. registerApi: '/api/auth/create',
  10. forgotApi: '/api/auth/forgot',
  11. loginApi: '/api/auth/signin',
  12. logoutApi: '/api/auth/signout',
  13. resetPasswordApi: '/api/account/user/reset',
  14. updateAvatarApi: '/api/account/profile/avatar',
  15. accountMyVipApi: '/api/user/vip/my',
  16. accountVipPlanApi: '/api/user/vip/plan',
  17. accountVipApi: '/api/user/vip/buy'
  18. }
  19. export function isUsernameExist(username) {
  20. return get(accountApi.checkUsernameApi + '?username=' + username)
  21. }
  22. export function selectUsername(username) {
  23. return post(accountApi.selectUsernameApi + '/' + username)
  24. }
  25. export function isEmailExist(email) {
  26. return get(accountApi.checkEmailApi + '/' + email)
  27. }
  28. export function register(userRegistry) {
  29. return post(accountApi.registerApi, userRegistry)
  30. }
  31. export function forgot(userRegistry) {
  32. return post(accountApi.forgotApi, userRegistry)
  33. }
  34. export function resetPassword(resetPasswordData) {
  35. return post(accountApi.resetPasswordApi, resetPasswordData)
  36. }
  37. // 获取公钥
  38. export function getPubkey(channel) {
  39. return get(accountApi.pubkeyApi + '?channel=' + channel)
  40. }
  41. // 获取图形验证码
  42. export function getCaptchaCode(captchaCodeApi) {
  43. return get(accountApi.captchaCodeApi)
  44. }
  45. // 获取短信验证码
  46. export function getVerifyCode(verifyCode) {
  47. return post(accountApi.verifyCodeApi, verifyCode)
  48. }
  49. // 登录
  50. export function login(loginData) {
  51. return post(accountApi.loginApi, loginData)
  52. }
  53. // 注销
  54. export function logout() {
  55. return get(accountApi.logoutApi)
  56. }
  57. export function updateAvatar(userAvatar) {
  58. return post(accountApi.updateAvatarApi, userAvatar)
  59. }
  60. // VIP
  61. export function getMyVip() {
  62. return get(accountApi.accountMyVipApi)
  63. }
  64. export function getVipPlans() {
  65. return get(accountApi.accountVipPlanApi)
  66. }
  67. export function vip(data) {
  68. return post(accountApi.accountVipApi, data)
  69. }