补全了退出当前账号的逻辑

This commit is contained in:
fengshuo
2021-10-24 23:41:26 +08:00
parent 76ec07c966
commit 0d370a1c0f
8 changed files with 52 additions and 4 deletions

View File

@@ -15,8 +15,13 @@ NSString * const kWeChatNumber = @"yinyoucc";
///
NSString * const KeyWithType(KeyType type) {
#warning to do
BOOL isRelease = NO;
BOOL isRelase = NO;
#ifdef DEBUG
isRelase = NO;
#else
isRelase = YES;
#endif
NSDictionary * dic = @{
///
@(YES):@{
@@ -43,7 +48,7 @@ NSString * const KeyWithType(KeyType type) {
@(KeyType_APNSCer) : @"yinyouApnsDebug",
}
};
NSDictionary * enviroDic = [dic objectForKey:@(isRelease)];
NSDictionary * enviroDic = [dic objectForKey:@(isRelase)];
return [enviroDic objectForKey:@(type)];
}

View File

@@ -130,6 +130,12 @@ NS_ASSUME_NONNULL_BEGIN
uid:(NSString *)uid
ticket:(NSString *)ticket;
/// 退出当前账号
/// @param complection 完成
/// @param access_token token
+ (void)logoutCurrentAccount:(HttpRequestHelperCompletion)complection
access_token:(NSString *)access_token;
@end

View File

@@ -131,4 +131,12 @@
}
/// 退
/// @param complection
/// @param access_token token
+ (void)logoutCurrentAccount:(HttpRequestHelperCompletion)complection access_token:(NSString *)access_token {
[self makeRequest:@"acc/logout" method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__, access_token, nil];
}
@end

View File

@@ -18,6 +18,9 @@ NS_ASSUME_NONNULL_BEGIN
/// @param userinfo 当前的用户信息
- (void)getMineSettingDataSourceWith:(UserInfoModel *)userinfo;
/// 退出当前账号
- (void)logoutCurrentAccount;
@end
NS_ASSUME_NONNULL_END

View File

@@ -11,6 +11,7 @@
#import "XPMineSettingProtocol.h"
///Model
#import "UserInfoModel.h"
#import "AccountModel.h"
#import "XPMineSettingItemModel.h"
///Tool
#import "AccountInfoStorage.h"
@@ -94,5 +95,14 @@
}
/// 退
- (void)logoutCurrentAccount {
AccountModel * account = [[AccountInfoStorage instance] accountModel];
[Api logoutCurrentAccount:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[self logout];
[[self getView] logoutCurrentAccountSuccess];
}] access_token:account.access_token];
}
@end

View File

@@ -15,6 +15,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)getMineSettingDatasourceSuccess:(NSArray *)array;
///获取用户信息成功
- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo;
///退出当前账号成功
- (void)logoutCurrentAccountSuccess;
@end
NS_ASSUME_NONNULL_END

View File

@@ -54,6 +54,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
[self initEvents];
[self initSubViews];
[self initSubViewConstraints];
[self.presenter getMineSettingDataSourceWith:self.userInfo];
@@ -66,6 +67,12 @@
}
#pragma mark - Private Method
- (void)initEvents {
[[self.logoutButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
[self.presenter logoutCurrentAccount];
}];
}
- (void)initSubViews {
self.title = @"设置";
[self.view addSubview:self.tableView];
@@ -228,6 +235,10 @@
[self.presenter getMineSettingDataSourceWith:userInfo];
}
- (void)logoutCurrentAccountSuccess {
[self.navigationController popToRootViewControllerAnimated:NO];
}
#pragma mark - Getters And Setters
- (UITableView *)tableView {
if (!_tableView) {

View File

@@ -143,9 +143,12 @@
} else {
if ([self.roomUid isEqualToString:uid]) {
// TODO:
[self.presenter openUserRoomWithTitle:roomInfo.title.length > 0 ? roomInfo.title : @"" type:roomInfo.type roomPwd:roomInfo.roomPwd roomDesc:roomInfo.roomDesc backPic:nil];
[self showSuccessToast:@"请选择进入其他人的房间"];
[self enterRoomFail];
} else {
// TODO: 线
[self showSuccessToast:@"房主已下线"];
[self enterRoomFail];
}
}
}