user.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import BaseStore from '@src/stores/base';
  2. export default class UserStore extends BaseStore {
  3. /**
  4. * 验证token
  5. */
  6. token() {
  7. return this.apiPost('/auth/token');
  8. }
  9. /**
  10. * 登陆
  11. * @param {*} mobile 手机号
  12. * @param {*} mobileVerifyCode 手机验证码
  13. * @param {*} inviteCode 邀请人手机/邀请码
  14. */
  15. login(mobile, mobileVerifyCode, inviteCode) {
  16. return this.apiPost('/auth/login', { mobile, mobileVerifyCode, inviteCode });
  17. }
  18. loginWechat(code) {
  19. return this.apiGet('/auth/wechat', { code });
  20. }
  21. loginWechatPC(code) {
  22. return this.apiGet('/auth/wechat_pc', { code });
  23. }
  24. /**
  25. * 登出
  26. */
  27. logout() {
  28. return this.apiPost('/auth/logout');
  29. }
  30. /**
  31. * 绑定手机
  32. * @param {*} mobile 手机号
  33. * @param {*} mobileVerifyCode 手机验证码
  34. * @param {*} inviteCode 邀请人手机/邀请码
  35. */
  36. bind(mobile, mobileVerifyCode, inviteCode) {
  37. return this.apiPost('/auth/bind', { mobile, mobileVerifyCode, inviteCode });
  38. }
  39. /**
  40. * 查询邀请码对应账号
  41. * @param {*} code 邀请码
  42. */
  43. validInviteCode(code) {
  44. return this.apiGet('/auth/valid/invite_code', { code });
  45. }
  46. /**
  47. * 查询手机对应账号
  48. */
  49. validMobile(mobile) {
  50. return this.apiGet('/auth/valid/mobile', { mobile });
  51. }
  52. }
  53. export const User = new UserStore({ key: 'user' });