diff --git a/xplan-ios/Base/MVP/Presenter/BaseMvpPresenter.h b/xplan-ios/Base/MVP/Presenter/BaseMvpPresenter.h index 05e9d40a..22cc2fbb 100644 --- a/xplan-ios/Base/MVP/Presenter/BaseMvpPresenter.h +++ b/xplan-ios/Base/MVP/Presenter/BaseMvpPresenter.h @@ -19,7 +19,6 @@ typedef void(^HttpFail)(NSInteger code, NSString * _Nullable msg); - (void)attatchView:(id)view; - (id)getView; -- (BaseViewController *)getBaseVC; - (void)detatchView; - (HttpRequestHelperCompletion)createHttpCompletion:(HttpSuccess)success fail:(HttpFail)fail; - (HttpRequestHelperCompletion)createHttpCompletion:(HttpSuccess)success fail:(HttpFail)fail showLoading:(BOOL)loading; diff --git a/xplan-ios/Base/MVP/Presenter/BaseMvpPresenter.m b/xplan-ios/Base/MVP/Presenter/BaseMvpPresenter.m index 626732a6..b2d29126 100644 --- a/xplan-ios/Base/MVP/Presenter/BaseMvpPresenter.m +++ b/xplan-ios/Base/MVP/Presenter/BaseMvpPresenter.m @@ -23,10 +23,6 @@ return self.view; } -- (BaseViewController *)getBaseVC { - return ((BaseViewController *) [self getView]); -} - - (HttpRequestHelperCompletion)createHttpCompletion:(HttpSuccess)success fail:(HttpFail)fail { return [self createHttpCompletion:success fail:fail showLoading:NO errorToast:YES]; } @@ -41,11 +37,11 @@ - (HttpRequestHelperCompletion)createHttpCompletion:(HttpSuccess)success fail:(HttpFail)fail showLoading:(BOOL)loading errorToast:(BOOL)toast { if (loading) { - [[self getBaseVC] showLoading]; + [self.view showLoading]; } return ^(BaseModel *data, NSInteger code, NSString * _Nullable msg) { if (loading) { - [[self getBaseVC] hideHUD]; + [self.view hideHUD]; } if (code == 200) { success(data); @@ -62,7 +58,7 @@ } if (toast) { - [[self getBaseVC] showErrorToast:msg]; + [self.view showErrorToast:msg]; } fail(code, msg); }; diff --git a/xplan-ios/Base/MVP/Protocol/BaseMvpProtocol.h b/xplan-ios/Base/MVP/Protocol/BaseMvpProtocol.h index 89707a97..e6aeda60 100644 --- a/xplan-ios/Base/MVP/Protocol/BaseMvpProtocol.h +++ b/xplan-ios/Base/MVP/Protocol/BaseMvpProtocol.h @@ -13,6 +13,25 @@ NS_ASSUME_NONNULL_BEGIN - (void)tokenInvalid; - (void)completeUserInfo; +/** + 成功 toast + */ +- (void)showSuccessToast:(NSString *)msg; + +/** + 失败 toast + */ +- (void)showErrorToast:(NSString *)msg; + +/** + 加载 loading + */ +- (void)showLoading; + +/** + 隐藏 XCHUDTool + */ +- (void)hideHUD; @end diff --git a/xplan-ios/Base/MVP/View/MvpViewController.h b/xplan-ios/Base/MVP/View/MvpViewController.h index b86f249b..7a15ab5b 100644 --- a/xplan-ios/Base/MVP/View/MvpViewController.h +++ b/xplan-ios/Base/MVP/View/MvpViewController.h @@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface MvpViewController : BaseViewController +@interface MvpViewController : BaseViewController @property (nonatomic, strong) __kindof T presenter; diff --git a/xplan-ios/Base/UI/BaseViewController.h b/xplan-ios/Base/UI/BaseViewController.h index ba66271f..5ad45fa3 100644 --- a/xplan-ios/Base/UI/BaseViewController.h +++ b/xplan-ios/Base/UI/BaseViewController.h @@ -6,10 +6,11 @@ // #import +#import "BaseMvpProtocol.h" NS_ASSUME_NONNULL_BEGIN -@interface BaseViewController : UIViewController +@interface BaseViewController : UIViewController // 是否隐藏导航 默认是不隐藏的 @property(nonatomic,assign,getter=isHiddenNavBar) BOOL hiddenNavBar; @@ -36,26 +37,6 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)hideStatusBar; -/** - 成功 toast - */ -- (void)showSuccessToast:(NSString *)msg; - -/** - 失败 toast - */ -- (void)showErrorToast:(NSString *)msg; - -/** - 加载 loading - */ -- (void)showLoading; - -/** - 隐藏 XCHUDTool - */ -- (void)hideHUD; - @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Login/Presenter/LoginPresenter.m b/xplan-ios/Main/Login/Presenter/LoginPresenter.m index efeae7b3..c1c9467a 100644 --- a/xplan-ios/Main/Login/Presenter/LoginPresenter.m +++ b/xplan-ios/Main/Login/Presenter/LoginPresenter.m @@ -85,7 +85,7 @@ [AccountInfoStorage instance].thirdUserInfo = userInfo; [Api loginWithThirdPart:[self createHttpCompletion:^(BaseModel * _Nonnull data) { - [[self getBaseVC] hideHUD]; + [[super getView] hideHUD]; AccountModel * model = [AccountModel modelWithDictionary:data.data]; if (model != nil) { [[AccountInfoStorage instance] saveAccountInfo:model]; @@ -94,11 +94,11 @@ } fail:^(NSInteger code, NSString * _Nullable msg) { } showLoading:YES] openid:openid unionid:unionid access_token:access_token type:[NSString stringWithFormat:@"%lu", (unsigned long)type]]; } else if(state == SSDKResponseStateCancel) {///取消 - [[self getBaseVC] hideHUD]; - [[self getBaseVC] showErrorToast:@"登录取消"]; + [[super getView] hideHUD]; + [[super getView] showErrorToast:@"登录取消"]; } else if (state == SSDKResponseStateFail) {///失败 - [[self getBaseVC] hideHUD]; - [[self getBaseVC] showErrorToast:@"登录失败,请重试"]; + [[super getView] hideHUD]; + [[super getView] showErrorToast:@"登录失败,请重试"]; } }]; } diff --git a/xplan-ios/Main/Tabbar/TabbarViewController.m b/xplan-ios/Main/Tabbar/TabbarViewController.m index 736d5ed0..548e72c6 100644 --- a/xplan-ios/Main/Tabbar/TabbarViewController.m +++ b/xplan-ios/Main/Tabbar/TabbarViewController.m @@ -136,7 +136,6 @@ return nav; } -#pragma mark - 如果不实现的话 如果在main里面请求接口的时候 需要的话 就会导致方法找不到的错误 - (void)showSuccessToast:(NSString *)msg { [XCHUDTool showSuccessWithMessage:msg]; }