123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import BaseStore from '@src/stores/base';
- import * as querystring from 'querystring';
- export default class UserStore extends BaseStore {
- initState() {
- const { token } = querystring.parse(window.location.search.replace('?', ''));
- if (token) {
- this.setToken(token);
- }
- return { login: !!token };
- }
-
- token() {
- return this.apiPost('/auth/token');
- }
-
- login(mobile, mobileVerifyCode, inviteCode) {
- return this.apiPost('/auth/login', { mobile, mobileVerifyCode, inviteCode });
- }
- loginWechat(code) {
- return this.apiGet('/auth/wechat_pc', { code }).then(() => {
- this.setState({ login: true });
- });
- }
-
- logout() {
- return this.apiPost('/auth/logout');
- }
-
- bind(mobile, mobileVerifyCode, inviteCode) {
- return this.apiPost('/auth/bind', { mobile, mobileVerifyCode, inviteCode });
- }
-
- validInviteCode(code) {
- return this.apiGet('/auth/valid/invite_code', { code });
- }
-
- validMobile(mobile) {
- return this.apiGet('/auth/valid/mobile', { mobile });
- }
- }
- export const User = new UserStore({ key: 'user', local: true });
|