feat: 完善双端演示注册与红娘服务闭环
This commit is contained in:
@@ -89,6 +89,23 @@ class AuthStore extends BaseStore {
|
||||
}
|
||||
}
|
||||
|
||||
async loginWithDemo(code, displayName, phone) {
|
||||
this.setState({ authStatus: 'logging_in', lastError: null });
|
||||
try {
|
||||
const result = displayName
|
||||
? await authService.demoRegister({ code, displayName, phone })
|
||||
: await authService.demoLogin({ code });
|
||||
api.saveToken(result.accessToken, result.refreshToken);
|
||||
const snapshot = { isLoggedIn: true, userId: result.userId, phoneBound: !result.isNewUser };
|
||||
this.setState({ ...snapshot, authStatus: 'idle' });
|
||||
this.persist(snapshot, STORAGE_KEYS.IS_LOGGED_IN);
|
||||
return result;
|
||||
} catch (err) {
|
||||
this.setState({ authStatus: 'idle', lastError: err });
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定手机号
|
||||
* @param {{ phoneCode?: string, encryptedData?: string, iv?: string }} payload
|
||||
|
||||
Reference in New Issue
Block a user