Commit 91cde789255bbe404806fb40dfef2901a1061770
1 parent
e25ae350
no message
Showing
3 changed files
with
7 additions
and
168 deletions
CNLiveUserAgreementManager/Classes/CNUserAgreementManager.h
| ... | ... | @@ -32,9 +32,6 @@ typedef void(^SuccessBlock)(NSString *h5,NSString *title); |
| 32 | 32 | typedef void(^FailureBlock)(NSError *error); |
| 33 | 33 | |
| 34 | 34 | @interface CNUserAgreementManager : NSObject |
| 35 | -+ (instancetype)shared; | |
| 36 | -- (void)getAgreementH5WithType:(CNGetAgreementH5Type)type success:(SuccessBlock)success failure:(FailureBlock)failure; | |
| 37 | - | |
| 38 | 35 | + (void)getAgreementH5WithType:(CNGetAgreementH5Type)type success:(SuccessBlock)success failure:(FailureBlock)failure; |
| 39 | 36 | |
| 40 | 37 | @end | ... | ... |
CNLiveUserAgreementManager/Classes/CNUserAgreementManager.m
| ... | ... | @@ -218,170 +218,12 @@ static CNUserAgreementManager *_instance = nil; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | + (void)getAgreementH5WithType:(CNGetAgreementH5Type)type success:(SuccessBlock)success failure:(FailureBlock)failure { |
| 221 | - [CNLiveNetworking setAllowRequestDefaultArgument:NO]; | |
| 222 | - [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:CNGetAgreementH5Url Param:@{} CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | |
| 223 | - if (error) { | |
| 224 | - if (failure) { | |
| 225 | - failure(error); | |
| 226 | - } | |
| 227 | - } | |
| 228 | - else{ | |
| 229 | - if ([responseObject isKindOfClass:[NSArray class]]) { | |
| 230 | - | |
| 231 | - for (NSDictionary *dic in responseObject) { | |
| 232 | - | |
| 233 | - switch (type) { | |
| 234 | - case CNAgreementUser: | |
| 235 | - { | |
| 236 | - if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"yhxy"]) { | |
| 237 | - if (success) { | |
| 238 | - success(dic[@"detailUrl"],dic[@"title"]); | |
| 239 | - return ; | |
| 240 | - } | |
| 241 | - } | |
| 242 | - } | |
| 243 | - break; | |
| 244 | - case CNAgreementPrivacy: | |
| 245 | - { | |
| 246 | - if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"yszc"]) { | |
| 247 | - if (success) { | |
| 248 | - success(dic[@"detailUrl"],dic[@"title"]); | |
| 249 | - return ; | |
| 250 | - } | |
| 251 | - } | |
| 252 | - } | |
| 253 | - break; | |
| 254 | - case CNAgreementHelp: | |
| 255 | - { | |
| 256 | - if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"bzfk"]) { | |
| 257 | - if (success) { | |
| 258 | - success(dic[@"detailUrl"],dic[@"title"]); | |
| 259 | - return ; | |
| 260 | - } | |
| 261 | - } | |
| 262 | - } | |
| 263 | - break; | |
| 264 | - case CNAgreementUnderstand: | |
| 265 | - { | |
| 266 | - if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"ljwjj"]) { | |
| 267 | - if (success) { | |
| 268 | - success(dic[@"detailUrl"],dic[@"title"]); | |
| 269 | - return ; | |
| 270 | - } | |
| 271 | - } | |
| 272 | - } | |
| 273 | - break; | |
| 274 | - case CNAgreementIntroduction: | |
| 275 | - { | |
| 276 | - if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"yyjj"]) { | |
| 277 | - if (success) { | |
| 278 | - success(dic[@"detailUrl"],dic[@"title"]); | |
| 279 | - return ; | |
| 280 | - } | |
| 281 | - } | |
| 282 | - } | |
| 283 | - break; | |
| 284 | - case CNAgreementCopyright: | |
| 285 | - { | |
| 286 | - if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"bqxx"]) { | |
| 287 | - if (success) { | |
| 288 | - success(dic[@"detailUrl"],dic[@"title"]); | |
| 289 | - return ; | |
| 290 | - } | |
| 291 | - } | |
| 292 | - } | |
| 293 | - break; | |
| 294 | - case CNAgreementPermission: | |
| 295 | - { | |
| 296 | - if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"rjxkxy"]) { | |
| 297 | - if (success) { | |
| 298 | - success(dic[@"detailUrl"],dic[@"title"]); | |
| 299 | - return ; | |
| 300 | - } | |
| 301 | - } | |
| 302 | - } | |
| 303 | - break; | |
| 304 | - case CNAgreementIntegralRules: | |
| 305 | - { | |
| 306 | - if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"jfgz"]) { | |
| 307 | - if (success) { | |
| 308 | - success(dic[@"detailUrl"],dic[@"title"]); | |
| 309 | - return ; | |
| 310 | - } | |
| 311 | - } | |
| 312 | - } | |
| 313 | - break; | |
| 314 | - case CNAgreementSigninRules: | |
| 315 | - { | |
| 316 | - if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"jfjlgz"]) { | |
| 317 | - if (success) { | |
| 318 | - success(dic[@"detailUrl"],dic[@"title"]); | |
| 319 | - return ; | |
| 320 | - } | |
| 321 | - } | |
| 322 | - } | |
| 323 | - break; | |
| 324 | - case CNAgreementReviewApply: | |
| 325 | - { | |
| 326 | - if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"shsqxy"]) { | |
| 327 | - if (success) { | |
| 328 | - success(dic[@"detailUrl"],dic[@"title"]); | |
| 329 | - return ; | |
| 330 | - } | |
| 331 | - } | |
| 332 | - } | |
| 333 | - break; | |
| 334 | - case CNAgreementCancellation: | |
| 335 | - { | |
| 336 | - if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"zxxz"]) { | |
| 337 | - if (success) { | |
| 338 | - success(dic[@"detailUrl"],dic[@"title"]); | |
| 339 | - return ; | |
| 340 | - } | |
| 341 | - } | |
| 342 | - } | |
| 343 | - break; | |
| 344 | - case CNAgreementEmojiService: | |
| 345 | - { | |
| 346 | - if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"fwsm"]) { | |
| 347 | - if (success) { | |
| 348 | - success(dic[@"detailUrl"],dic[@"title"]); | |
| 349 | - return ; | |
| 350 | - } | |
| 351 | - } | |
| 352 | - } | |
| 353 | - break; | |
| 354 | - case CNAgreementEmojiComplaints: | |
| 355 | - { | |
| 356 | - if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"tssm"]) { | |
| 357 | - if (success) { | |
| 358 | - success(dic[@"detailUrl"],dic[@"title"]); | |
| 359 | - return ; | |
| 360 | - } | |
| 361 | - } | |
| 362 | - } | |
| 363 | - break; | |
| 364 | - case CNAgreementEnterpriseQualification: | |
| 365 | - { | |
| 366 | - if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"qyzz"]) { | |
| 367 | - if (success) { | |
| 368 | - success(dic[@"detailUrl"],dic[@"title"]); | |
| 369 | - return ; | |
| 370 | - } | |
| 371 | - } | |
| 372 | - } | |
| 373 | - break; | |
| 374 | - default: | |
| 375 | - break; | |
| 376 | - } | |
| 377 | - | |
| 378 | - } | |
| 379 | - | |
| 380 | - } | |
| 381 | - if (failure) { | |
| 382 | - failure(error); | |
| 383 | - } | |
| 384 | - } | |
| 221 | + [[CNUserAgreementManager shared] getAgreementH5WithType:type success:^(NSString * _Nonnull h5, NSString * _Nonnull title) { | |
| 222 | + success(h5, title); | |
| 223 | + | |
| 224 | + } failure:^(NSError * _Nonnull error) { | |
| 225 | + failure(error); | |
| 226 | + | |
| 385 | 227 | }]; |
| 386 | 228 | |
| 387 | 229 | } | ... | ... |
Example/CNLiveUserAgreementManager/CNLiveViewController.m
| ... | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | // Do any additional setup after loading the view, typically from a nib. |
| 23 | 23 | NSLog(@"%@",CNGetAgreementH5Url); |
| 24 | 24 | |
| 25 | - [[CNUserAgreementManager shared] getAgreementH5WithType:CNAgreementUser success:^(NSString * _Nonnull h5, NSString * _Nonnull title) { | |
| 25 | + [CNUserAgreementManager getAgreementH5WithType:CNAgreementUser success:^(NSString * _Nonnull h5, NSString * _Nonnull title) { | |
| 26 | 26 | NSLog(@"%@",h5); |
| 27 | 27 | NSLog(@"%@",title); |
| 28 | 28 | ... | ... |