Commit fdeb742e427dd32e401c020f40c6868f52af6430
1 parent
76eed0b5
提交0.0.18
Showing
6 changed files
with
266 additions
and
9 deletions
CNLiveServiceCenterModule.podspec
CNLiveServiceCenterModule/Classes/CNLiveServiceCenterModule/Category/NSString+Random.h
0 → 100755
| 1 | +/* | |
| 2 | + * Copyright (C) 2011 Michael Dippery <mdippery@gmail.com> | |
| 3 | + * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 5 | + * of this software and associated documentation files (the "Software"), to deal | |
| 6 | + * in the Software without restriction, including without limitation the rights | |
| 7 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 8 | + * copies of the Software, and to permit persons to whom the Software is | |
| 9 | + * furnished to do so, subject to the following conditions: | |
| 10 | + * | |
| 11 | + * The above copyright notice and this permission notice shall be included in | |
| 12 | + * all copies or substantial portions of the Software. | |
| 13 | + * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 17 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 19 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 20 | + * THE SOFTWARE. | |
| 21 | + */ | |
| 22 | + | |
| 23 | +#import <Foundation/Foundation.h> | |
| 24 | + | |
| 25 | +@interface NSString (Randomized) | |
| 26 | ++ (NSString *)defaultAlphabet; | |
| 27 | ++ (id)randomizedString; | |
| 28 | ++ (id)randomizedStringWithAlphabet:(NSString *)alphabet; | |
| 29 | ++ (id)randomizedStringWithAlphabet:(NSString *)alphabet length:(NSUInteger)len; | |
| 30 | +- (id)initWithDefaultAlphabet; | |
| 31 | +- (id)initWithAlphabet:(NSString *)alphabet; | |
| 32 | +- (id)initWithAlphabet:(NSString *)alphabet length:(NSUInteger)len; | |
| 33 | +@end | ... | ... |
CNLiveServiceCenterModule/Classes/CNLiveServiceCenterModule/Category/NSString+Random.m
0 → 100755
| 1 | +/* | |
| 2 | + * Copyright (C) 2011 Michael Dippery <mdippery@gmail.com> | |
| 3 | + * | |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 5 | + * of this software and associated documentation files (the "Software"), to deal | |
| 6 | + * in the Software without restriction, including without limitation the rights | |
| 7 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 8 | + * copies of the Software, and to permit persons to whom the Software is | |
| 9 | + * furnished to do so, subject to the following conditions: | |
| 10 | + * | |
| 11 | + * The above copyright notice and this permission notice shall be included in | |
| 12 | + * all copies or substantial portions of the Software. | |
| 13 | + * | |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 17 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 19 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 20 | + * THE SOFTWARE. | |
| 21 | + */ | |
| 22 | + | |
| 23 | +#import "NSString+Random.h" | |
| 24 | +#include <stdlib.h> | |
| 25 | + | |
| 26 | +#define DEFAULT_LENGTH 8 | |
| 27 | + | |
| 28 | +@implementation NSString (Randomized) | |
| 29 | + | |
| 30 | ++ (NSString *)defaultAlphabet | |
| 31 | +{ | |
| 32 | + return @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZY0123456789"; | |
| 33 | +} | |
| 34 | + | |
| 35 | ++ (id)randomizedString | |
| 36 | +{ | |
| 37 | + return [self randomizedStringWithAlphabet:[self defaultAlphabet]]; | |
| 38 | +} | |
| 39 | + | |
| 40 | ++ (id)randomizedStringWithAlphabet:(NSString *)alphabet | |
| 41 | +{ | |
| 42 | + return [self randomizedStringWithAlphabet:alphabet length:DEFAULT_LENGTH]; | |
| 43 | +} | |
| 44 | + | |
| 45 | ++ (id)randomizedStringWithAlphabet:(NSString *)alphabet length:(NSUInteger)len | |
| 46 | +{ | |
| 47 | + return [[self alloc] initWithAlphabet:alphabet length:len]; | |
| 48 | +} | |
| 49 | + | |
| 50 | +- (id)initWithDefaultAlphabet | |
| 51 | +{ | |
| 52 | + return [self initWithAlphabet:[NSString defaultAlphabet]]; | |
| 53 | +} | |
| 54 | + | |
| 55 | +- (id)initWithAlphabet:(NSString *)alphabet | |
| 56 | +{ | |
| 57 | + return [self initWithAlphabet:alphabet length:DEFAULT_LENGTH]; | |
| 58 | +} | |
| 59 | + | |
| 60 | +- (id)initWithAlphabet:(NSString *)alphabet length:(NSUInteger)len | |
| 61 | +{ | |
| 62 | + NSMutableString *s = [NSMutableString stringWithCapacity:len]; | |
| 63 | + for (NSUInteger i = 0U; i < len; i++) { | |
| 64 | + u_int32_t r = arc4random() % [alphabet length]; | |
| 65 | + unichar c = [alphabet characterAtIndex:r]; | |
| 66 | + [s appendFormat:@"%C", c]; | |
| 67 | + } | |
| 68 | + return [NSString stringWithString:s]; | |
| 69 | +} | |
| 70 | + | |
| 71 | +@end | ... | ... |
CNLiveServiceCenterModule/Classes/CNLiveServiceCenterModule/Controller/CNLiveBServiceCenterController.m
| ... | ... | @@ -26,6 +26,8 @@ |
| 26 | 26 | #import <CNLiveBServices/CNLiveLiveSetHomeProtocol.h> |
| 27 | 27 | #import "CNLiveBCreatorViewController.h" |
| 28 | 28 | #import "CNLiveBServiceLiveSelectedView.h" |
| 29 | +#import "NSString+Random.h" | |
| 30 | +#import <CNLiveBServices/CNLiveBStreamServiceProtocol.h> | |
| 29 | 31 | |
| 30 | 32 | /// 认证状态 |
| 31 | 33 | #define CNLiveBGetServiceStatusUrl cn_API_OpenApi2(@"/user/readWJJBStatusById") |
| ... | ... | @@ -110,9 +112,9 @@ |
| 110 | 112 | self.navigationController.navigationBarHidden = YES; |
| 111 | 113 | [self loadStatus]; |
| 112 | 114 | if (self.headerView) { |
| 113 | - [self.headerView eidtHeaderView]; | |
| 115 | + [self.headerView eidtHeaderView]; | |
| 114 | 116 | } |
| 115 | - | |
| 117 | + | |
| 116 | 118 | |
| 117 | 119 | } |
| 118 | 120 | |
| ... | ... | @@ -179,6 +181,9 @@ |
| 179 | 181 | [weakSelf checkPersonCertification]; |
| 180 | 182 | }; |
| 181 | 183 | |
| 184 | + ///天机获取参数 | |
| 185 | + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateServiceStatusNotification:) name:@"UpdateServiceStatus" object:nil]; | |
| 186 | + | |
| 182 | 187 | } |
| 183 | 188 | |
| 184 | 189 | #pragma mark - |
| ... | ... | @@ -266,6 +271,15 @@ |
| 266 | 271 | }else { |
| 267 | 272 | headerView.titleL.text = @""; |
| 268 | 273 | } |
| 274 | + | |
| 275 | +#pragma mark - TODO: 测试使用 | |
| 276 | + __weak typeof(self) weakSelf = self; | |
| 277 | + headerView.clickTestViewBlock = ^(CNLiveBCenterHeaderFooterView * _Nonnull view) { | |
| 278 | + NSLog(@"点击了头部"); | |
| 279 | + [self testLiveVC]; | |
| 280 | + | |
| 281 | + }; | |
| 282 | + | |
| 269 | 283 | return headerView; |
| 270 | 284 | |
| 271 | 285 | } |
| ... | ... | @@ -346,6 +360,85 @@ |
| 346 | 360 | |
| 347 | 361 | |
| 348 | 362 | #pragma mark - *** 事件实现 *** |
| 363 | + | |
| 364 | + | |
| 365 | +#pragma mark - TODO: 测试需要后期直接删除 | |
| 366 | +- (void)testLiveVC { | |
| 367 | + | |
| 368 | + NSString *strUrl = [self getStreamCloudURL]; | |
| 369 | + NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:strUrl]]; | |
| 370 | + request.HTTPMethod = @"GET"; | |
| 371 | + request.timeoutInterval = 10; | |
| 372 | + | |
| 373 | + NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { | |
| 374 | + | |
| 375 | + | |
| 376 | + if (error != nil || response == nil || data == nil) { | |
| 377 | + NSLog(@"get play json faild, %@, %@, %@", error, response, data); | |
| 378 | + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.4 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
| 379 | + [self testLiveVC]; | |
| 380 | + }); | |
| 381 | + return; | |
| 382 | + } | |
| 383 | + | |
| 384 | + NSURL *streamURL = [NSURL URLWithString:[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]]; | |
| 385 | + | |
| 386 | + dispatch_async(dispatch_get_main_queue(), ^{ | |
| 387 | + NSString *streamURLString = streamURL.absoluteString; | |
| 388 | + | |
| 389 | + NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; | |
| 390 | + [params setValue:@"10515174" forKey:@"userId"]; | |
| 391 | + [params setValue:@"UGC主播测试-0412-4" forKey:@"spName"]; | |
| 392 | + [params setValue:@"604" forKey:@"spId"]; | |
| 393 | + [params setValue:@"769_bb50cde6847011ea9f1bfa163e21407f" forKey:@"activityId"]; | |
| 394 | + [params setValue:@"AVCR_769_9295cbc6883b11eaa436fa163e21407f" forKey:@"chatRoomId"]; | |
| 395 | + [params setValue:@"欢迎进入聊天室" forKey:@"appLiveNotice"]; | |
| 396 | + [params setValue:@"分享直播可获得平台积分奖励,进行奖赏,增加热度" forKey:@"spLiveNotice"]; | |
| 397 | + [params setValue:@"1919" forKey:@"fansNum"]; | |
| 398 | + [params setValue:@"1919" forKey:@"onlineCount"]; | |
| 399 | + [params setValue:@"1" forKey:@"legalize"]; | |
| 400 | + [params setValue:@"https://wjjtest.ys2.cnliveimg.com/802/img_new/1586916434665.HEIC" forKey:@"activityImg"]; | |
| 401 | + [params setValue:@"https://wjjtest.ys2.cnliveimg.com/802/img_new/1559115890722.png" forKey:@"spIcon"]; | |
| 402 | + [params setValue:[NSString stringWithFormat:@"%@",streamURLString] forKey:@"streamLocation"]; | |
| 403 | + [params setValue:@"0" forKey:@"isAuthLive"]; | |
| 404 | + | |
| 405 | + NSLog(@"输出内容参数 = %@",params); | |
| 406 | + /// 详情页 | |
| 407 | + id<CNLiveBStreamServiceProtocol> serviceProtocol = [[BeeHive shareInstance] createService:@protocol(CNLiveBStreamServiceProtocol)]; | |
| 408 | + UIViewController *vc = [serviceProtocol getStreamController:params]; | |
| 409 | + vc.hidesBottomBarWhenPushed = YES; | |
| 410 | + [self.navigationController pushViewController:vc animated:YES]; | |
| 411 | + | |
| 412 | + }); | |
| 413 | + | |
| 414 | + }]; | |
| 415 | + [task resume]; | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | +} | |
| 421 | + | |
| 422 | +- (NSString *)getStreamCloudURL { | |
| 423 | +#warning 在这里填写获取推流地址的业务服务器 url | |
| 424 | + NSString *streamServer = @"https://api-demo.qnsdk.com/v1/live/stream/"; | |
| 425 | + NSString *streamID = [NSString randomizedString]; | |
| 426 | + NSString *streamURLString = [streamServer stringByAppendingPathComponent:streamID]; | |
| 427 | + return streamURLString; | |
| 428 | +} | |
| 429 | + | |
| 430 | + | |
| 431 | +/// 通知实现 | |
| 432 | +- (void)updateServiceStatusNotification:(NSNotification *)notification { | |
| 433 | + | |
| 434 | + [self loadStatus]; | |
| 435 | + if (self.headerView) { | |
| 436 | + [self.headerView eidtHeaderView]; | |
| 437 | + } | |
| 438 | + | |
| 439 | +} | |
| 440 | + | |
| 441 | + | |
| 349 | 442 | ///跳转个人 |
| 350 | 443 | - (void)jumpPersonVC { |
| 351 | 444 | /// 详情页 |
| ... | ... | @@ -424,17 +517,63 @@ |
| 424 | 517 | if (!err) { |
| 425 | 518 | NSDictionary * contentDic = (NSDictionary *)data; |
| 426 | 519 | if ([contentDic containsObjectForKey:@"personStatus"]) { |
| 427 | - self.personStatus = [NSString stringWithFormat:@"%@",[contentDic objectForKey:@"personStatus"] ? [contentDic objectForKey:@"personStatus"] : @"0"]; | |
| 428 | - self.centerModel.personStatus = self.personStatus; | |
| 520 | + | |
| 521 | + if (CNUserShareModel.wjjStatus) { | |
| 522 | + if (![[NSString stringWithFormat:@"%@",CNUserShareModel.wjjStatus.personStatus ? CNUserShareModel.wjjStatus.personStatus : @"0"] isEqualToString:@"0"]) { | |
| 523 | + self.personStatus = [NSString stringWithFormat:@"%@",CNUserShareModel.wjjStatus.personStatus ? CNUserShareModel.wjjStatus.personStatus : @"0"]; | |
| 524 | + self.centerModel.personStatus = self.personStatus; | |
| 525 | + | |
| 526 | + | |
| 527 | + }else { | |
| 528 | + self.personStatus = [NSString stringWithFormat:@"%@",[contentDic objectForKey:@"personStatus"] ? [contentDic objectForKey:@"personStatus"] : @"0"]; | |
| 529 | + self.centerModel.personStatus = self.personStatus; | |
| 530 | + } | |
| 531 | + }else { | |
| 532 | + self.personStatus = [NSString stringWithFormat:@"%@",[contentDic objectForKey:@"personStatus"] ? [contentDic objectForKey:@"personStatus"] : @"0"]; | |
| 533 | + self.centerModel.personStatus = self.personStatus; | |
| 534 | + } | |
| 429 | 535 | |
| 430 | 536 | } |
| 431 | 537 | |
| 432 | 538 | if ([contentDic containsObjectForKey:@"institutionStatus"]) { |
| 433 | - self.institutionStatus = [NSString stringWithFormat:@"%@",[contentDic objectForKey:@"institutionStatus"] ? [contentDic objectForKey:@"institutionStatus"] : @"0"]; | |
| 539 | + | |
| 540 | + if (CNUserShareModel.wjjStatus) { | |
| 541 | + if (![[NSString stringWithFormat:@"%@",CNUserShareModel.wjjStatus.institutionStatus ? CNUserShareModel.wjjStatus.institutionStatus : @"0"] isEqualToString:@"0"]) { | |
| 542 | + | |
| 543 | + self.institutionStatus = [NSString stringWithFormat:@"%@",CNUserShareModel.wjjStatus.institutionStatus ? CNUserShareModel.wjjStatus.institutionStatus : @"0"]; | |
| 544 | + self.centerModel.institutionStatus = self.institutionStatus; | |
| 545 | + | |
| 546 | + }else { | |
| 547 | + self.institutionStatus = [NSString stringWithFormat:@"%@",[contentDic objectForKey:@"institutionStatus"] ? [contentDic objectForKey:@"institutionStatus"] : @"0"]; | |
| 548 | + self.centerModel.institutionStatus = self.institutionStatus; | |
| 549 | + | |
| 550 | + } | |
| 551 | + | |
| 552 | + }else { | |
| 553 | + self.institutionStatus = [NSString stringWithFormat:@"%@",[contentDic objectForKey:@"institutionStatus"] ? [contentDic objectForKey:@"institutionStatus"] : @"0"]; | |
| 554 | + self.centerModel.institutionStatus = self.institutionStatus; | |
| 555 | + } | |
| 556 | + | |
| 557 | + } | |
| 558 | + | |
| 559 | + | |
| 560 | + if (self.headerView) { | |
| 561 | + [self.headerView configUIWithIsPerson:self.personStatus isEnterprise:self.institutionStatus]; | |
| 562 | + } | |
| 563 | + [self.tableView reloadData]; | |
| 564 | + | |
| 565 | + | |
| 566 | + }else { | |
| 567 | + if (CNUserShareModel.wjjStatus) { | |
| 568 | + self.personStatus = [NSString stringWithFormat:@"%@",CNUserShareModel.wjjStatus.personStatus ? CNUserShareModel.wjjStatus.personStatus : @"0"]; | |
| 569 | + self.institutionStatus = [NSString stringWithFormat:@"%@",CNUserShareModel.wjjStatus.institutionStatus ? CNUserShareModel.wjjStatus.institutionStatus : @"0"]; | |
| 570 | + self.centerModel.personStatus = self.personStatus; | |
| 434 | 571 | self.centerModel.institutionStatus = self.institutionStatus; |
| 435 | 572 | |
| 436 | 573 | } |
| 437 | - [self.headerView configUIWithIsPerson:self.personStatus isEnterprise:self.institutionStatus]; | |
| 574 | + if (self.headerView) { | |
| 575 | + [self.headerView configUIWithIsPerson:self.personStatus isEnterprise:self.institutionStatus]; | |
| 576 | + } | |
| 438 | 577 | [self.tableView reloadData]; |
| 439 | 578 | } |
| 440 | 579 | |
| ... | ... | @@ -621,7 +760,7 @@ |
| 621 | 760 | vc.hidesBottomBarWhenPushed = YES; |
| 622 | 761 | [self.navigationController pushViewController:vc animated:YES]; |
| 623 | 762 | }); |
| 624 | - | |
| 763 | + | |
| 625 | 764 | }else { |
| 626 | 765 | |
| 627 | 766 | } |
| ... | ... | @@ -643,7 +782,7 @@ |
| 643 | 782 | vc.hidesBottomBarWhenPushed = YES; |
| 644 | 783 | [self.navigationController pushViewController:vc animated:YES]; |
| 645 | 784 | }); |
| 646 | - | |
| 785 | + | |
| 647 | 786 | |
| 648 | 787 | }else { |
| 649 | 788 | ... | ... |
CNLiveServiceCenterModule/Classes/CNLiveServiceCenterModule/View/CNLiveBServiceCenterHeaderView.h
| ... | ... | @@ -54,6 +54,9 @@ NS_ASSUME_NONNULL_BEGIN |
| 54 | 54 | |
| 55 | 55 | /*** 题头 ***/ |
| 56 | 56 | @property (nonatomic, strong) UILabel *titleL; |
| 57 | + | |
| 58 | +/** 点击用户认证实现*/ | |
| 59 | +@property (nonatomic, copy) void(^clickTestViewBlock)(CNLiveBCenterHeaderFooterView *view); | |
| 57 | 60 | @end |
| 58 | 61 | |
| 59 | 62 | NS_ASSUME_NONNULL_END | ... | ... |
CNLiveServiceCenterModule/Classes/CNLiveServiceCenterModule/View/CNLiveBServiceCenterHeaderView.m
| ... | ... | @@ -618,6 +618,11 @@ |
| 618 | 618 | [self setBackgroundColor:[UIColor yellowColor]]; |
| 619 | 619 | [self.contentView addSubview:self.titleL]; |
| 620 | 620 | self.titleL.frame = CGRectMake(15, 4, KScreenWidth - 30, 15); |
| 621 | + | |
| 622 | +#pragma mark - TODO:测试添加后期要删掉 | |
| 623 | + ///测试添加 | |
| 624 | + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)]; | |
| 625 | + [self addGestureRecognizer:tap]; | |
| 621 | 626 | |
| 622 | 627 | } |
| 623 | 628 | |
| ... | ... | @@ -629,6 +634,12 @@ |
| 629 | 634 | #pragma mark - editUI |
| 630 | 635 | |
| 631 | 636 | #pragma mark - ***事件实现*** |
| 637 | +- (void)tapAction:(UITapGestureRecognizer *)tap { | |
| 638 | + | |
| 639 | + if (self.clickTestViewBlock) { | |
| 640 | + self.clickTestViewBlock(self); | |
| 641 | + } | |
| 642 | +} | |
| 632 | 643 | |
| 633 | 644 | |
| 634 | 645 | #pragma mark - ***私有方法*** | ... | ... |