Commit a94bbb447c04852ab3a0c3e5fd5c304c87f3a6ec
1 parent
d9f394cb
no message
Showing
6 changed files
with
38 additions
and
61 deletions
CNLiveUserAgreementManager.podspec
CNLiveUserAgreementManager/Classes/CNLiveUserAgreementController.m
| ... | ... | @@ -15,7 +15,6 @@ |
| 15 | 15 | @end |
| 16 | 16 | |
| 17 | 17 | @implementation CNLiveUserAgreementController |
| 18 | - | |
| 19 | 18 | #pragma mark - 交互 |
| 20 | 19 | - (void)interaction { |
| 21 | 20 | [super interaction]; |
| ... | ... | @@ -41,7 +40,7 @@ |
| 41 | 40 | |
| 42 | 41 | #pragma mark - CNLiveWebViewDelegate |
| 43 | 42 | - (void)webView:(CNLiveWebView *)webView didFinishLoadWithURL:(NSURL *)url { |
| 44 | - NSLog(@"CNLIVEViewController - didFinishLoad"); | |
| 43 | + NSLog(@"CNLiveUserAgreementController - didFinishLoad"); | |
| 45 | 44 | if(self.title.length == 0){ |
| 46 | 45 | self.title = webView.title; |
| 47 | 46 | } | ... | ... |
CNLiveUserAgreementManager/Classes/CNLiveUserAgreementManager.h
| ... | ... | @@ -29,7 +29,7 @@ typedef NS_ENUM(NSUInteger, CNLiveGetAgreementH5Type) { |
| 29 | 29 | |
| 30 | 30 | }; |
| 31 | 31 | |
| 32 | -typedef void(^SuccessBlock)(NSString *h5, NSString *title, BOOL isShow); | |
| 32 | +typedef void(^SuccessBlock)(NSString *h5, NSString *title, BOOL closeHidden); | |
| 33 | 33 | typedef void(^FailureBlock)(NSError *error); |
| 34 | 34 | |
| 35 | 35 | @interface CNLiveUserAgreementManager : NSObject | ... | ... |
CNLiveUserAgreementManager/Classes/CNLiveUserAgreementManager.m
| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | #import <CNLiveRequestBastKit/CNLiveNetworking.h> |
| 10 | 10 | #import "CNLiveEnvironment.h" |
| 11 | 11 | #import "CNLiveUserAgreementController.h" |
| 12 | +#import "CNLiveManager.h" | |
| 12 | 13 | |
| 13 | 14 | @interface CNLiveUserAgreementManager() |
| 14 | 15 | |
| ... | ... | @@ -63,7 +64,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 63 | 64 | } |
| 64 | 65 | else{ |
| 65 | 66 | if ([responseObject isKindOfClass:[NSArray class]]) { |
| 66 | - | |
| 67 | + BOOL closeHidden = NO; | |
| 67 | 68 | for (NSDictionary *dic in responseObject) { |
| 68 | 69 | |
| 69 | 70 | switch (type) { |
| ... | ... | @@ -71,7 +72,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 71 | 72 | { |
| 72 | 73 | if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"yhxy"]) { |
| 73 | 74 | if (success) { |
| 74 | - success(dic[@"detailUrl"], dic[@"title"], YES); | |
| 75 | + success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 75 | 76 | return ; |
| 76 | 77 | } |
| 77 | 78 | } |
| ... | ... | @@ -81,7 +82,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 81 | 82 | { |
| 82 | 83 | if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"yszc"]) { |
| 83 | 84 | if (success) { |
| 84 | - success(dic[@"detailUrl"], dic[@"title"], YES); | |
| 85 | + success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 85 | 86 | return ; |
| 86 | 87 | } |
| 87 | 88 | } |
| ... | ... | @@ -91,7 +92,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 91 | 92 | { |
| 92 | 93 | if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"bzfk"]) { |
| 93 | 94 | if (success) { |
| 94 | - success(dic[@"detailUrl"], dic[@"title"], YES); | |
| 95 | + success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 95 | 96 | return ; |
| 96 | 97 | } |
| 97 | 98 | } |
| ... | ... | @@ -101,7 +102,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 101 | 102 | { |
| 102 | 103 | if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"ljwjj"]) { |
| 103 | 104 | if (success) { |
| 104 | - success(dic[@"detailUrl"], dic[@"title"], YES); | |
| 105 | + success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 105 | 106 | return ; |
| 106 | 107 | } |
| 107 | 108 | } |
| ... | ... | @@ -111,7 +112,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 111 | 112 | { |
| 112 | 113 | if ([[NSString stringWithFormat:@"%@", dic[@"type"]] isEqualToString:@"yyjj"]) { |
| 113 | 114 | if (success) { |
| 114 | - success(dic[@"detailUrl"], dic[@"title"], YES); | |
| 115 | + success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 115 | 116 | return ; |
| 116 | 117 | } |
| 117 | 118 | } |
| ... | ... | @@ -121,7 +122,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 121 | 122 | { |
| 122 | 123 | if ([[NSString stringWithFormat:@"%@", dic[@"type"]] isEqualToString:@"bqxx"]) { |
| 123 | 124 | if (success) { |
| 124 | - success(dic[@"detailUrl"], dic[@"title"], YES); | |
| 125 | + success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 125 | 126 | return ; |
| 126 | 127 | } |
| 127 | 128 | } |
| ... | ... | @@ -131,7 +132,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 131 | 132 | { |
| 132 | 133 | if ([[NSString stringWithFormat:@"%@", dic[@"type"]] isEqualToString:@"rjxkxy"]) { |
| 133 | 134 | if (success) { |
| 134 | - success(dic[@"detailUrl"], dic[@"title"], YES); | |
| 135 | + success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 135 | 136 | return ; |
| 136 | 137 | } |
| 137 | 138 | } |
| ... | ... | @@ -141,7 +142,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 141 | 142 | { |
| 142 | 143 | if ([[NSString stringWithFormat:@"%@", dic[@"type"]] isEqualToString:@"jfgz"]) { |
| 143 | 144 | if (success) { |
| 144 | - success(dic[@"detailUrl"], dic[@"title"], YES); | |
| 145 | + success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 145 | 146 | return ; |
| 146 | 147 | } |
| 147 | 148 | } |
| ... | ... | @@ -151,7 +152,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 151 | 152 | { |
| 152 | 153 | if ([[NSString stringWithFormat:@"%@", dic[@"type"]] isEqualToString:@"jfjlgz"]) { |
| 153 | 154 | if (success) { |
| 154 | - success(dic[@"detailUrl"], dic[@"title"], YES); | |
| 155 | + success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 155 | 156 | return ; |
| 156 | 157 | } |
| 157 | 158 | } |
| ... | ... | @@ -161,7 +162,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 161 | 162 | { |
| 162 | 163 | if ([[NSString stringWithFormat:@"%@", dic[@"type"]] isEqualToString:@"shsqxy"]) { |
| 163 | 164 | if (success) { |
| 164 | - success(dic[@"detailUrl"], dic[@"title"], YES); | |
| 165 | + success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 165 | 166 | return ; |
| 166 | 167 | } |
| 167 | 168 | } |
| ... | ... | @@ -171,7 +172,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 171 | 172 | { |
| 172 | 173 | if ([[NSString stringWithFormat:@"%@", dic[@"type"]] isEqualToString:@"zxxz"]) { |
| 173 | 174 | if (success) { |
| 174 | - success(dic[@"detailUrl"], dic[@"title"], YES); | |
| 175 | + success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 175 | 176 | return ; |
| 176 | 177 | } |
| 177 | 178 | } |
| ... | ... | @@ -181,7 +182,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 181 | 182 | { |
| 182 | 183 | if ([[NSString stringWithFormat:@"%@", dic[@"type"]] isEqualToString:@"fwsm"]) { |
| 183 | 184 | if (success) { |
| 184 | - success(dic[@"detailUrl"], dic[@"title"], YES); | |
| 185 | + success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 185 | 186 | return ; |
| 186 | 187 | } |
| 187 | 188 | } |
| ... | ... | @@ -191,7 +192,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 191 | 192 | { |
| 192 | 193 | if ([[NSString stringWithFormat:@"%@", dic[@"type"]] isEqualToString:@"tssm"]) { |
| 193 | 194 | if (success) { |
| 194 | - success(dic[@"detailUrl"], dic[@"title"], YES); | |
| 195 | + success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 195 | 196 | return ; |
| 196 | 197 | } |
| 197 | 198 | } |
| ... | ... | @@ -201,7 +202,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 201 | 202 | { |
| 202 | 203 | if ([[NSString stringWithFormat:@"%@", dic[@"type"]] isEqualToString:@"qyzz"]) { |
| 203 | 204 | if (success) { |
| 204 | - success(dic[@"detailUrl"], dic[@"title"], YES); | |
| 205 | + success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 205 | 206 | return ; |
| 206 | 207 | } |
| 207 | 208 | } |
| ... | ... | @@ -211,7 +212,7 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 211 | 212 | { |
| 212 | 213 | if ([[NSString stringWithFormat:@"%@", dic[@"type"]] isEqualToString:@"ypxy"]) { |
| 213 | 214 | if (success) { |
| 214 | - success(dic[@"detailUrl"], dic[@"title"], YES); | |
| 215 | + success(dic[@"detailUrl"], dic[@"title"], closeHidden); | |
| 215 | 216 | return ; |
| 216 | 217 | } |
| 217 | 218 | } |
| ... | ... | @@ -239,8 +240,8 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 239 | 240 | * @param failure 请求失败回调 |
| 240 | 241 | */ |
| 241 | 242 | + (void)getAgreementH5WithType:(CNLiveGetAgreementH5Type)type success:(SuccessBlock)success failure:(FailureBlock)failure { |
| 242 | - [[CNLiveUserAgreementManager manager] getAgreementH5WithType:type success:^(NSString * _Nonnull h5, NSString * _Nonnull title, BOOL isShow) { | |
| 243 | - success?success(h5, title, isShow):@""; | |
| 243 | + [[CNLiveUserAgreementManager manager] getAgreementH5WithType:type success:^(NSString * _Nonnull h5, NSString * _Nonnull title, BOOL closeHidden) { | |
| 244 | + success?success(h5, title, closeHidden):@""; | |
| 244 | 245 | |
| 245 | 246 | } failure:^(NSError * _Nonnull error) { |
| 246 | 247 | failure?failure(error):@""; |
| ... | ... | @@ -255,10 +256,10 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 255 | 256 | */ |
| 256 | 257 | + (void)jumpToAgreementH5WithType:(CNLiveGetAgreementH5Type)type{ |
| 257 | 258 | __weak typeof(self) weakSelf = self; |
| 258 | - [CNLiveUserAgreementManager getAgreementH5WithType:type success:^(NSString *h5, NSString *title, BOOL isShow) { | |
| 259 | + [CNLiveUserAgreementManager getAgreementH5WithType:type success:^(NSString *h5, NSString *title, BOOL closeHidden) { | |
| 259 | 260 | __strong typeof(weakSelf) strongSelf = weakSelf; |
| 260 | 261 | if(!strongSelf) return; |
| 261 | - [strongSelf pushToWebControllerUrl:h5 name:title showCloseBtn:isShow]; | |
| 262 | + [strongSelf pushToWebControllerUrl:h5 name:title closeHidden:closeHidden]; | |
| 262 | 263 | |
| 263 | 264 | } failure:^(NSError *error) { |
| 264 | 265 | if(TestEnvironment){ |
| ... | ... | @@ -276,10 +277,10 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 276 | 277 | */ |
| 277 | 278 | + (void)jumpToAgreementH5WithString:(NSString *)string { |
| 278 | 279 | __weak typeof(self) weakSelf = self; |
| 279 | - [CNLiveUserAgreementManager getAgreementH5WithString:string success:^(NSString *h5, NSString *title, BOOL isShow) { | |
| 280 | + [CNLiveUserAgreementManager getAgreementH5WithString:string success:^(NSString *h5, NSString *title, BOOL closeHidden) { | |
| 280 | 281 | __strong typeof(weakSelf) strongSelf = weakSelf; |
| 281 | 282 | if(!strongSelf) return; |
| 282 | - [strongSelf pushToWebControllerUrl:h5 name:title showCloseBtn:isShow]; | |
| 283 | + [strongSelf pushToWebControllerUrl:h5 name:title closeHidden:closeHidden]; | |
| 283 | 284 | |
| 284 | 285 | } failure:^(NSError *error) { |
| 285 | 286 | if(TestEnvironment){ |
| ... | ... | @@ -297,8 +298,8 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 297 | 298 | * @param failure 请求失败回调 |
| 298 | 299 | */ |
| 299 | 300 | + (void)getAgreementH5WithString:(NSString *)string success:(SuccessBlock)success failure:(FailureBlock)failure{ |
| 300 | - [[CNLiveUserAgreementManager manager] getAgreementH5WithString:string success:^(NSString *h5, NSString *title, BOOL isShow) { | |
| 301 | - success?success(h5, title, isShow):@""; | |
| 301 | + [[CNLiveUserAgreementManager manager] getAgreementH5WithString:string success:^(NSString *h5, NSString *title, BOOL closeHidden) { | |
| 302 | + success?success(h5, title, closeHidden):@""; | |
| 302 | 303 | |
| 303 | 304 | } failure:^(NSError *error) { |
| 304 | 305 | failure?failure(error):@""; |
| ... | ... | @@ -319,15 +320,12 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 319 | 320 | if ([responseObject isKindOfClass:[NSArray class]]) { |
| 320 | 321 | for (NSDictionary *dic in responseObject) { |
| 321 | 322 | if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:string]) { |
| 322 | - success?success(dic[@"detailUrl"], dic[@"title"], YES):@""; | |
| 323 | + success?success(dic[@"detailUrl"], dic[@"title"], NO):@""; | |
| 323 | 324 | return; |
| 324 | 325 | } |
| 325 | - | |
| 326 | 326 | } |
| 327 | - | |
| 328 | 327 | } |
| 329 | 328 | failure?failure(error):@""; |
| 330 | - | |
| 331 | 329 | |
| 332 | 330 | }else{ |
| 333 | 331 | failure?failure(error):@""; |
| ... | ... | @@ -337,34 +335,9 @@ static CNLiveUserAgreementManager *_instance = nil; |
| 337 | 335 | } |
| 338 | 336 | |
| 339 | 337 | #pragma mark - 跳转控制器 |
| 340 | -+ (void)pushToWebControllerUrl:(NSString *)url name:(NSString *)name showCloseBtn:(BOOL)isShow{ | |
| 341 | - UIViewController *root = [UIApplication sharedApplication].delegate.window.rootViewController; | |
| 342 | - | |
| 343 | - //跟控制器是Navigation | |
| 344 | - if ([root isKindOfClass:[UINavigationController class]]){ | |
| 345 | - UINavigationController *nav = (UINavigationController *)root; | |
| 346 | - CNLiveUserAgreementController *vc = [[CNLiveUserAgreementController alloc] initWithUrl:url title:name closeHidden:isShow]; | |
| 347 | - [nav pushViewController:vc animated:YES]; | |
| 348 | - | |
| 349 | - } | |
| 350 | - //跟控制器是TabBar | |
| 351 | - else if ([root isKindOfClass:[UITabBarController class]]){ | |
| 352 | - UITabBarController *tab = (UITabBarController *)root; | |
| 353 | - UIViewController *selected = tab.selectedViewController; | |
| 354 | - if ([selected isKindOfClass:[UINavigationController class]]){ | |
| 355 | - UINavigationController *nav = (UINavigationController *)selected; | |
| 356 | - CNLiveUserAgreementController *vc = [[CNLiveUserAgreementController alloc] initWithUrl:url title:name closeHidden:isShow]; | |
| 357 | - [nav pushViewController:vc animated:YES]; | |
| 358 | - }else{ | |
| 359 | - CNLiveUserAgreementController *vc = [[CNLiveUserAgreementController alloc] initWithUrl:url title:name closeHidden:isShow]; | |
| 360 | - [root presentViewController:vc animated:YES completion:nil]; | |
| 361 | - } | |
| 362 | - | |
| 363 | - }else{ | |
| 364 | - CNLiveUserAgreementController *vc = [[CNLiveUserAgreementController alloc] initWithUrl:url title:name closeHidden:isShow]; | |
| 365 | - [root presentViewController:vc animated:YES completion:nil]; | |
| 366 | - | |
| 367 | - } | |
| 338 | ++ (void)pushToWebControllerUrl:(NSString *)url name:(NSString *)name closeHidden:(BOOL)closeHidden{ | |
| 339 | + CNLiveUserAgreementController *vc = [[CNLiveUserAgreementController alloc] initWithUrl:url title:name closeHidden:closeHidden]; | |
| 340 | + [CNLivePageJumpManager jumpViewController:vc]; | |
| 368 | 341 | |
| 369 | 342 | } |
| 370 | 343 | ... | ... |
Example/CNLiveUserAgreementManager.xcodeproj/project.pbxproj
| ... | ... | @@ -354,6 +354,7 @@ |
| 354 | 354 | "${BUILT_PRODUCTS_DIR}/CNLiveCategory/CNLiveCategory.framework", |
| 355 | 355 | "${BUILT_PRODUCTS_DIR}/CNLiveCustomControl/CNLiveCustomControl.framework", |
| 356 | 356 | "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework", |
| 357 | + "${BUILT_PRODUCTS_DIR}/CNLiveManager/CNLiveManager.framework", | |
| 357 | 358 | "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework", |
| 358 | 359 | "${BUILT_PRODUCTS_DIR}/CNLiveTripartiteManagement/CNLiveTripartiteManagement.framework", |
| 359 | 360 | "${BUILT_PRODUCTS_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.framework", |
| ... | ... | @@ -368,6 +369,7 @@ |
| 368 | 369 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCategory.framework", |
| 369 | 370 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCustomControl.framework", |
| 370 | 371 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework", |
| 372 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveManager.framework", | |
| 371 | 373 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework", |
| 372 | 374 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveTripartiteManagement.framework", |
| 373 | 375 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserAgreementManager.framework", | ... | ... |
Example/CNLiveUserAgreementManager/CNLiveViewController.m
| ... | ... | @@ -35,11 +35,11 @@ |
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | - (void)testButtonClicked { |
| 38 | -// [CNLiveUserAgreementManager jumpToAgreementH5WithType:CNLiveUserAgreementCancellation]; | |
| 38 | + [CNLiveUserAgreementManager jumpToAgreementH5WithType:CNLiveUserAgreementCancellation]; | |
| 39 | 39 | // [CNLiveUserAgreementManager jumpToAgreementH5WithString:@"yhxy"]; |
| 40 | 40 | [CNLiveUserAgreementManager getAgreementH5WithType:CNLiveUserAgreementCancellation success:^(NSString * _Nonnull h5, NSString * _Nonnull title, BOOL isShow) { |
| 41 | 41 | CNLiveUserAgreementController *vc = [[CNLiveUserAgreementController alloc] initWithUrl:h5 title:title closeHidden:NO]; |
| 42 | - [self.navigationController pushViewController:vc animated:YES]; | |
| 42 | +// [self.navigationController pushViewController:vc animated:YES]; | |
| 43 | 43 | |
| 44 | 44 | } failure:^(NSError * _Nonnull error) { |
| 45 | 45 | ... | ... |