diff --git a/xplan-ios/Global/XPConstant.m b/xplan-ios/Global/XPConstant.m index 519bb9f7..d04b746f 100644 --- a/xplan-ios/Global/XPConstant.m +++ b/xplan-ios/Global/XPConstant.m @@ -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)]; } diff --git a/xplan-ios/Main/Mine/Api/Api+Mine.h b/xplan-ios/Main/Mine/Api/Api+Mine.h index 706edcc7..e0f075dc 100644 --- a/xplan-ios/Main/Mine/Api/Api+Mine.h +++ b/xplan-ios/Main/Mine/Api/Api+Mine.h @@ -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 diff --git a/xplan-ios/Main/Mine/Api/Api+Mine.m b/xplan-ios/Main/Mine/Api/Api+Mine.m index 1b45199d..6f0ed7e5 100644 --- a/xplan-ios/Main/Mine/Api/Api+Mine.m +++ b/xplan-ios/Main/Mine/Api/Api+Mine.m @@ -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 diff --git a/xplan-ios/Main/Mine/Presenter/XPMineSettingPresent.h b/xplan-ios/Main/Mine/Presenter/XPMineSettingPresent.h index fb7189bb..15eb45eb 100644 --- a/xplan-ios/Main/Mine/Presenter/XPMineSettingPresent.h +++ b/xplan-ios/Main/Mine/Presenter/XPMineSettingPresent.h @@ -18,6 +18,9 @@ NS_ASSUME_NONNULL_BEGIN /// @param userinfo 当前的用户信息 - (void)getMineSettingDataSourceWith:(UserInfoModel *)userinfo; +/// 退出当前账号 +- (void)logoutCurrentAccount; + @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/Presenter/XPMineSettingPresent.m b/xplan-ios/Main/Mine/Presenter/XPMineSettingPresent.m index 9e212ad0..3abbe7a6 100644 --- a/xplan-ios/Main/Mine/Presenter/XPMineSettingPresent.m +++ b/xplan-ios/Main/Mine/Presenter/XPMineSettingPresent.m @@ -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 diff --git a/xplan-ios/Main/Mine/Protocol/XPMineSettingProtocol.h b/xplan-ios/Main/Mine/Protocol/XPMineSettingProtocol.h index 02078ecd..b0ec49ee 100644 --- a/xplan-ios/Main/Mine/Protocol/XPMineSettingProtocol.h +++ b/xplan-ios/Main/Mine/Protocol/XPMineSettingProtocol.h @@ -15,6 +15,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)getMineSettingDatasourceSuccess:(NSArray *)array; ///获取用户信息成功 - (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo; +///退出当前账号成功 +- (void)logoutCurrentAccountSuccess; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/XPMineSettingViewController.m b/xplan-ios/Main/Mine/View/XPMineSettingViewController.m index 17d391c4..a73c49a8 100644 --- a/xplan-ios/Main/Mine/View/XPMineSettingViewController.m +++ b/xplan-ios/Main/Mine/View/XPMineSettingViewController.m @@ -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) { diff --git a/xplan-ios/Main/Room/View/XPRoomViewController.m b/xplan-ios/Main/Room/View/XPRoomViewController.m index c57ad0aa..d403bd54 100644 --- a/xplan-ios/Main/Room/View/XPRoomViewController.m +++ b/xplan-ios/Main/Room/View/XPRoomViewController.m @@ -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]; } } }