123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569 |
- //
- // YOUPAILZLiveListVC.m
- // TIANYAN
- //
- // Created by CY on 2021/5/19.
- // Copyright © 2021 leo. All rights reserved.
- //
- #import "YOUPAILZLiveListVC.h"
- #import "YOUPAILZLiveItemCell.h"
- //#import <AgoraRtcEngineKit/AgoraRtcEngineKit.h>
- #import "YOUPAILCBannerModel.h"
- #import "SDCycleScrollView.h"
- #import "YYAnimatedImageView.h"
- #import "YYImage.h"
- #import "YOUPAILZLiveModel.h"
- #import "YOUPAILZLiveAudienceVC.h"
- #import "YOUPAILZLiveAnchorVC.h"
- #import "UIViewController+TFPresent.h"
- #import "YOUPAILZEndLiveHintModel.h"
- #import "YOUPAILZEndLiveHintView.h"
- #import "YOUPAILZLiveManagerListUtils.h"
- @interface YOUPAILZLiveListVC () <UICollectionViewDataSource,UICollectionViewDelegate,AgoraRtcEngineDelegate,SDCycleScrollViewDelegate>
- //@property (nonatomic, strong) AgoraRtcEngineKit *youpaipagoraKit;
- //@property (nonatomic, strong) AgoraRtcVideoCanvas *youpaipremoteCanvas; // 远程画布
- //@property (nonatomic, strong) YOUPAILZLiveListItemModel *youpaipliveItemModel;
- @property (nonatomic, assign) NSInteger youpaipcurrentPage;
- @property (nonatomic, assign) NSInteger youpaiptotalPage;
- @property (nonatomic, strong) NSArray <YOUPAILCBannerModel *> *youpaipbannerArray;
- @property (nonatomic, strong) SDCycleScrollView *youpaipbannerView;
- @property (nonatomic, strong) NSArray <YOUPAILZLiveListItemModel*> *youpaipgetRandLives;
- @property (nonatomic, strong) YYImage *icLiveZhibozhong28;
- @property (nonatomic, strong) YYImage *icLiveZhibozhong38;
- @property (nonatomic, strong) YYImage *youpaipicLiveUserHeader;
- @property (nonatomic, copy) void(^scrollCallback)(UIScrollView *scrollView);
- @end
- @implementation YOUPAILZLiveListVC
- //@synthesize consumer;
- //
- //- (void)dealloc{
- // [[NSNotificationCenter defaultCenter] removeObserver:self];
- //}
- //
- //- (void)viewWillAppear:(BOOL)animated{
- // [super viewWillAppear:animated];
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(leave) name:UIApplicationWillResignActiveNotification object:nil];
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youpaifjoin) name:UIApplicationDidBecomeActiveNotification object:nil];
- //}
- //- (void)viewDidAppear:(BOOL)animated{
- // [super viewDidAppear:animated];
- // [self youpaifjoin];
- //}
- //- (void)viewWillDisappear:(BOOL)animated{
- // [super viewWillDisappear:animated];
- //
- // [self leave];
- // [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillResignActiveNotification object:nil];
- // [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
- //}
- - (void)viewDidLoad {
- [super viewDidLoad];
- // self.view.backgroundColor = LCBkgColor;
-
- [self youpaifsetupUI];
- // [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(leave) name:@"CallVideo" object:nil];
- }
- -(void)youpaifsetupUI{
- [self.view addSubview:self.youpaipcollectionView];
- [self.youpaipcollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.bottom.right.offset(0.0f);
- }];
- [self.youpaipcollectionView.mj_header beginRefreshing];
- }
- ///// 初始化 AgoraRtcEngineKit 类。
- //- (void)youpaifinitializeAgoraEngine{
- // self.youpaipagoraKit = [AgoraRtcEngineKit sharedEngineWithAppId:AgoraID delegate:self];
- // //设置频道场景
- // [self.youpaipagoraKit setChannelProfile:AgoraChannelProfileLiveBroadcasting];
- // //设置用户角色
- // [self.youpaipagoraKit setClientRole:AgoraClientRoleAudience];
- // //初始化并返回新分配的具有指定视频分辨率的AgoraVideoEncoderConfiguration对象
- // AgoraVideoEncoderConfiguration *configuration = [[AgoraVideoEncoderConfiguration alloc] initWithSize:AgoraVideoDimension1280x720 frameRate:AgoraVideoFrameRateFps24 bitrate:AgoraVideoBitrateCompatible orientationMode:AgoraVideoOutputOrientationModeAdaptative];
- // [self.youpaipagoraKit setVideoEncoderConfiguration:configuration];
- // //设置本地视频镜像模式
- // [self.youpaipagoraKit setLocalVideoMirrorMode:AgoraVideoMirrorModeDisabled];
- // //启用与Agora Web SDK的互操作性。
- // [self.youpaipagoraKit enableWebSdkInteroperability:YES];
- // //启用视频
- // [self.youpaipagoraKit enableVideo];
- // //设置视频源
- // [self.youpaipagoraKit setVideoSource:self];
- // [self.youpaipagoraKit youpaifmuteAllRemoteAudioStreams:YES];
- //}
- ///// 加入频道
- //- (void)youpaifjoinChannel{
- // WeakSelf;
- // [self.youpaipagoraKit joinChannelByToken:nil channelId:self.youpaipliveItemModel.room_id info:nil uid:[[LCSaveModel getUserModel].userinfo.user_id integerValue] joinSuccess:^(NSString *channel, NSUInteger uid, NSInteger elapsed) {
- // //检查扬声器是否已启用
- // if([weakSelf.youpaipagoraKit isSpeakerphoneEnabled]){
- // //设置扬声器
- // [weakSelf.youpaipagoraKit setEnableSpeakerphone:YES];
- // }
- // // 设置不自动锁屏
- // [UIApplication sharedApplication].idleTimerDisabled = YES;
- // }];
- //}
- ///// 离开频道
- //- (void)youpaifleaveChannel{
- // [self.youpaipagoraKit youpaifmuteAllRemoteAudioStreams:NO];
- // [self.youpaipagoraKit setupLocalVideo:nil];
- // // 离开频道。
- // [self.youpaipagoraKit youpaifleaveChannel:nil];
- // self.youpaipagoraKit.delegate = nil;
- // self.youpaipagoraKit.videoSource = nil;
- // self.youpaipagoraKit = nil;
- //}
- //
- //- (void)youpaifjoin{
- // BOOL isLive = NO; /// 是否在直播
- // for (UIViewController *vc in self.navigationController.viewControllers) {
- // if ([vc isKindOfClass:[YOUPAILZLiveAnchorVC class]]) {
- // isLive = YES;
- // }
- // }
- // if (self.type == 1 && self.dataSource.count != 0 && ![LCSaveData getIsVideo] && !isLive && self.youpaipliveItemModel.is_virtual != 1) { // 只有推荐才初始化声网SDK
- // [self youpaifinitializeAgoraEngine];
- // [self youpaifjoinChannel];
- // }
- //}
- //
- //- (void)leave{
- // if (self.type == 1 && self.youpaipagoraKit != nil) {
- // [self youpaifleaveChannel];
- // }
- //}
- - (void)youpaifgetRandLiveClick:(UIButton *)sender{
- [self youpaifjoinLiveWithRoomId:self.youpaipgetRandLives[sender.tag].youpaiproom_id is_comein_room_hide:0];
- }
- //#pragma mark - AgoraRtcEngineDelegate
- //
- //
- //- (void)rtcEngine:(AgoraRtcEngineKit *)engine didJoinedOfUid:(NSUInteger)uid elapsed:(NSInteger)elapsed{
- // if([self.youpaipliveItemModel.anchor_id isEqual:[NSString stringWithFormat:@"%@",@(uid)]]){
- // AgoraRtcVideoCanvas *videoCanvas = [[AgoraRtcVideoCanvas alloc] init];
- // videoCanvas.uid = uid;
- // videoCanvas.view = self.bigItemCell.youpaipremoteVideo;
- // // 视图的渲染模式
- // videoCanvas.renderMode = AgoraVideoRenderModeHidden;
- // // 设置远端视图。
- // [self.youpaipagoraKit setupRemoteVideo:videoCanvas];
- // self.youpaipremoteCanvas = videoCanvas;
- // }
- //}
- //
- //
- //#pragma mark - AgoraVideoSourceProtocol
- //// 初始化视频源
- //- (BOOL)shouldInitialize{
- // return YES;
- //}
- //
- //// 检索缓冲区类型
- //- (AgoraVideoBufferType)bufferType{
- // // 使用像素缓冲区传输视频数据
- // return AgoraVideoBufferTypePixelBuffer;
- //}
- #pragma mark - UICollectionViewDataSource
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
- return self.youpaipdataSource.count;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
- // if (indexPath.item == 0 && self.type == 1) {
- // [self.bigItemCell youpaifreloadWithModel:self.dataSource[indexPath.item]];
- // return self.bigItemCell;
- // }else{
-
- YOUPAILZLiveItemCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"YOUPAILZLiveItemCell" forIndexPath:indexPath];
- LZLiveItemCellStyle style;
- if (self.youpaiptype == 2) { /// 只有热门才显示排名
- style = LZLiveItemCellStyleWithRanking;
- }else{
- style = LZLiveItemCellStyleWithDefault;
- }
- cell.youpaipanimationImage = self.icLiveZhibozhong28;
- [cell youpaifreloadWithModel:self.youpaipdataSource[indexPath.item] style:style index:indexPath.item];
-
- UILongPressGestureRecognizer* longgs = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(youpaiflongpress:)];
- [cell addGestureRecognizer:longgs];//为cell添加手势
- longgs.minimumPressDuration = 0.25f;//定义长按识别时长
- longgs.view.tag = indexPath.item;//将手势和cell的序号绑定
- return cell;
- // }
-
- }
- - (void)youpaiflongpress:(UILongPressGestureRecognizer *)ges{
- if(ges.state == UIGestureRecognizerStateEnded){
- NSInteger row = ges.view.tag;
- YOUPAILZLiveListItemModel *model = self.youpaipdataSource[row];
- if(model.youpaipis_comein_room_hide == 1){
- @weakify(self);
- ZCAlertAction* action = [ZCAlertAction actionWithTitle:@"悄悄进房" andblock:^{//举报
- @strongify(self);
- [self youpaifjoinLiveWithRoomId:model.youpaiproom_id is_comein_room_hide:model.youpaipis_comein_room_hide];
- }];
- ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:@[action]];
- alertSheet.alertWindow.hidden = NO;
- [alertSheet show];
- }
- }
- }
- #pragma mark - UICollectionViewDelegate
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
- [self youpaifjoinLiveWithRoomId:self.youpaipdataSource[indexPath.item].youpaiproom_id is_comein_room_hide:0];
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
- // if (indexPath.item == 0 && self.type == 1) {
- // CGFloat width = KScreenWidth - 10.0f;
- // return CGSizeMake(width, width * 0.8f);
- // }else{
- CGFloat width = (KScreenWidth/2) -1.0f;
- return CGSizeMake(width, width);
- // }
- }
- -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
- CGFloat height = 0.0f;
- if (self.youpaipbannerArray.count > 0) {
- height += KScreenWidth*(88/365.0);
- }
- if (self.youpaipgetRandLives.count > 0) {
- height += 129.0f;
- }
- return CGSizeMake(KScreenWidth, height);
- }
- - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
- {
- UICollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:
- UICollectionElementKindSectionHeader withReuseIdentifier:@"header" forIndexPath:indexPath];
- for (UIView* view in headerView.subviews) {
- [view removeFromSuperview];
- }
- // 如果当前想要的是头部视图
- if (self.youpaipbannerArray.count > 0) {
- NSMutableArray* imgUrlArray = [NSMutableArray array];
- for (YOUPAILCBannerModel* model in self.youpaipbannerArray) {
- [imgUrlArray addObject:[LCTools getImageUrlWithAddress:model.youpaipimage]];
- }
- self.youpaipbannerView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(5,0, KScreenWidth - 10.0f,KScreenWidth*(88/375.0)) delegate:self placeholderImage:[UIImage imageNamed:@"banner_default"]];
- self.youpaipbannerView.autoScrollTimeInterval = 3.0;//3s轮播
- self.youpaipbannerView.layer.cornerRadius = 3.0;
- self.youpaipbannerView.layer.masksToBounds = YES;
- self.youpaipbannerView.pageControlStyle = SDCycleScrollViewPageContolStyleNone;
-
- self.youpaipbannerView.imageURLStringsGroup = imgUrlArray;
- [headerView addSubview:self.youpaipbannerView];
- }
- if (self.youpaipgetRandLives.count > 0) {
- CGFloat y = self.youpaipbannerArray.count > 0 ? KScreenWidth*(88/365.0) : 0.0f;
- UIView *randLiveBgV = [[UIView alloc] initWithFrame:CGRectMake(5.0f, y, KScreenWidth - 10.0f, 129.0f)];
- [headerView addSubview:randLiveBgV];
-
- UILabel *titleL = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 14.0f, randLiveBgV.mj_w, 16.5f)];
- titleL.textAlignment = NSTextAlignmentCenter;
- titleL.font = LCFont12;
- titleL.textColor = HexColorFromRGB(0xCCCCCC);
- [randLiveBgV addSubview:titleL];
- NSString *text = @"— 新秀推荐 —";
- NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:text];
- NSRange range2 = [text rangeOfString:@"新秀推荐"];
- [attrStr addAttribute:NSForegroundColorAttributeName value:HexColorFromRGB(0x333333) range:range2];
- titleL.attributedText = attrStr;
-
- NSInteger count = 5;
- CGFloat width = randLiveBgV.mj_w / count;
- for (NSInteger i = 0; i < count; i ++) {
- if (i >= self.youpaipgetRandLives.count) {
- break;
- }
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(i * width, CGRectGetMaxY(titleL.frame) + 9.0f, width, 90.0f);
- btn.tag = i;
- [btn addTarget:self action:@selector(youpaifgetRandLiveClick:) forControlEvents:UIControlEventTouchUpInside];
- [randLiveBgV addSubview:btn];
-
-
- YYAnimatedImageView *youpaipbgImgV = [[YYAnimatedImageView alloc] initWithFrame:CGRectMake((btn.mj_w - 59.0f) / 2.0f, 0.0f, 59.0f, 59.0f)];
- youpaipbgImgV.image = self.youpaipicLiveUserHeader;
- youpaipbgImgV.contentMode = UIViewContentModeScaleAspectFit;
- [btn addSubview:youpaipbgImgV];
-
- UIImageView *youpaipavatarImgV = [[UIImageView alloc] initWithFrame:CGRectMake((youpaipbgImgV.mj_w - 44.0f)/ 2.0f, (youpaipbgImgV.mj_h - 44.0f)/ 2.0f, 44.0f, 44.0f)];
- youpaipavatarImgV.layer.cornerRadius = youpaipavatarImgV.mj_w / 2.0f;
- youpaipavatarImgV.clipsToBounds = YES;
- youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
- [youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipgetRandLives[i].youpaipcover_img]];
- [youpaipbgImgV addSubview:youpaipavatarImgV];
-
- UILabel *nameL = [[UILabel alloc] initWithFrame:CGRectMake(5.0f, CGRectGetMaxY(youpaipbgImgV.frame) + 2.0f, btn.mj_w - 10.0f, 15.0f)];
- nameL.text = self.youpaipgetRandLives[i].youpaipanchor_name;
- nameL.textColor = HexColorFromRGB(0x333333);
- nameL.font = LCFont(11.0f);
- nameL.textAlignment = NSTextAlignmentCenter;
- [btn addSubview:nameL];
- }
-
- }
- return headerView;
- }
- #pragma mark - SDCycleScrollViewDelegate
- - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
- {
- YOUPAILCBannerModel* model = self.youpaipbannerArray[index];
- if (model.youpaiplink_type==1) {
- ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init];
- baseWeb.contentUrl = model.youpaiplink_url;
- [self.navigationController pushViewController:baseWeb animated:YES];
- }else if (model.youpaiplink_type==2||model.youpaiplink_type==3){
- [self youpaifpageToStr:model.youpaiplink_url];
- }
- }
- //- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
- // if (scrollView == self.collectionView && [self.scrollDelegate respondsToSelector:@selector(scrollViewDidScroll:)]) {
- // [self.scrollDelegate scrollViewDidScroll:scrollView];
- // }
- //}
- - (UICollectionView *)youpaipcollectionView{
- if (!_youpaipcollectionView) {
- UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
- flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
- flowLayout.minimumLineSpacing = 1.0f;
- flowLayout.minimumInteritemSpacing = 1.0f;
- flowLayout.sectionInset = UIEdgeInsetsMake(1.0f, 0.0f, 1.0f, 0.0f);
- SEL sel = NSSelectorFromString(@"_setRowAlignmentsOptions:");
- if ([flowLayout respondsToSelector:sel]) {
- ((void(*)(id,SEL,NSDictionary*)) objc_msgSend)(flowLayout,sel, @{@"UIFlowLayoutCommonRowHorizontalAlignmentKey":@(NSTextAlignmentLeft),@"UIFlowLayoutLastRowHorizontalAlignmentKey" : @(NSTextAlignmentLeft),@"UIFlowLayoutRowVerticalAlignmentKey" : @(NSTextAlignmentCenter)});
- }
- _youpaipcollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
- _youpaipcollectionView.delegate = self;
- _youpaipcollectionView.dataSource = self;
- _youpaipcollectionView.backgroundColor = LCBkgColor;
- [_youpaipcollectionView registerClass:[YOUPAILZLiveItemCell class] forCellWithReuseIdentifier:@"YOUPAILZLiveItemCell"];
- [_youpaipcollectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header"];
- _youpaipcollectionView.showsHorizontalScrollIndicator = NO;
- _youpaipcollectionView.showsVerticalScrollIndicator = NO;
- _youpaipcollectionView.mj_header = [LCRefreshDotGiftHeader headerWithRefreshingTarget:self refreshingAction:@selector(youpaifloadNewData)];
- }
- return _youpaipcollectionView;
- }
- - (NSMutableArray<YOUPAILZLiveListItemModel *> *)youpaipdataSource{
- if (!_youpaipdataSource) {
- _youpaipdataSource = [NSMutableArray array];
- }
- return _youpaipdataSource;
- }
- #pragma mark - request data
- - (void)youpaifloadNewData{
- if(self.youpaiptype == 3 || self.youpaiptype == 4){ // 摘星站banner
- [self youpaifrequestBannerData];
- }
- if (self.youpaiptype == 4) { // 新秀banner 新秀顶部推荐
- [self youpaifrequestBannerData];
- [self youpaifrequestGetRandLive];
- }
-
- self.youpaipcollectionView.mj_footer.hidden = YES;
- [self.youpaipcollectionView.mj_footer endRefreshing];//先结束上拉,假如有的话
- [self.youpaipcollectionView.mj_footer endRefreshingWithNoMoreData];
- self.youpaipcollectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(youpaifloadMoreData)];
- self.youpaipcurrentPage = 1;
- WeakSelf;
- [LCHttpHelper requestWithURLString:GetLiveListByCate parameters:@{@"page":@(self.youpaipcurrentPage),@"cate_id":@(self.youpaiptype)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- [weakSelf.youpaipdataSource removeAllObjects];
- weakSelf.youpaipdataSource = [YOUPAILZLiveListItemModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"] objectForKey:@"list"]];
- weakSelf.youpaiptotalPage = [[[dict objectForKey:@"data"] objectForKey:@"total_page"] integerValue];
- NSInteger currentPage = [[[dict objectForKey:@"data"] objectForKey:@"page"] integerValue];
- weakSelf.youpaipcurrentPage = currentPage;
- [weakSelf.youpaipcollectionView reloadData];
-
- // if (weakSelf.type == 1 && weakSelf.dataSource.count != 0) { // 只有推荐才初始化声网SDK
- // weakSelf.youpaipliveItemModel = weakSelf.dataSource[0];
- // [weakSelf youpaifjoin];
- // }
- [weakSelf.youpaipcollectionView lz_hideEmptyView];
- if (weakSelf.youpaipdataSource.count == 0) {
- NSString *des = [[[dict objectForKey:@"data"] objectForKey:@"des"] objectForKey:@"des"];
- NSURL *imgURL = [LCTools getImageUrlWithAddress:[[[dict objectForKey:@"data"] objectForKey:@"des"] objectForKey:@"img"]];
- [weakSelf.youpaipcollectionView lz_showEmptyViewWithUrl:imgURL content:des];
- }
- if (currentPage >= weakSelf.youpaiptotalPage) {
- [weakSelf.youpaipcollectionView.mj_footer endRefreshingWithNoMoreData];
- weakSelf.youpaipcollectionView.mj_footer.hidden = YES;
- }
- [weakSelf.youpaipcollectionView.mj_header endRefreshing];
- }else{
- [weakSelf.youpaipcollectionView.mj_header endRefreshing];
- }
- } failure:^(NSError *error) {
- [weakSelf.youpaipcollectionView.mj_header endRefreshing];
- }];
- }
- - (void)youpaifloadMoreData{
- //先结束下拉 假如有的话
- [self.youpaipcollectionView.mj_header endRefreshing];
- WeakSelf;
- [LCHttpHelper requestWithURLString:GetLiveListByCate parameters:@{@"page":@(self.youpaipcurrentPage+1),@"cate_id":@(self.youpaiptype)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
-
- NSMutableArray* modelArray = [YOUPAILZLiveListItemModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"]objectForKey:@"list"]];
- [weakSelf.youpaipdataSource addObjectsFromArray:modelArray];
-
- weakSelf.youpaiptotalPage = [[[dict objectForKey:@"data"] objectForKey:@"total_page"] integerValue];
- NSInteger currentPage = [[[dict objectForKey:@"data"] objectForKey:@"page"] integerValue];
- weakSelf.youpaipcurrentPage = currentPage;
- [weakSelf.youpaipcollectionView reloadData];
- if (currentPage>=weakSelf.youpaiptotalPage) {
- [weakSelf.youpaipcollectionView.mj_footer endRefreshingWithNoMoreData];
- weakSelf.youpaipcollectionView.mj_footer.hidden = YES;
- }
- [weakSelf.youpaipcollectionView.mj_header endRefreshing];
- }
- [weakSelf.youpaipcollectionView.mj_footer endRefreshing];
- } failure:^(NSError *error) {
- [weakSelf.youpaipcollectionView.mj_footer endRefreshing];
- }];
-
- }
- //获取banner
- - (void)youpaifrequestBannerData{
- NSString *cate_id = @"2";
- if (self.youpaiptype == 3) {
- cate_id = @"3";
- }
- WeakSelf;
- [LCHttpHelper requestWithURLString:HomeBanner parameters:@{@"cate_id":cate_id} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- weakSelf.youpaipbannerArray = [YOUPAILCBannerModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"]objectForKey:@"banner"]];
- [weakSelf.youpaipcollectionView reloadData];
- }
- } failure:^(NSError *error) {
- }];
- }
- //获取新秀推荐
- - (void)youpaifrequestGetRandLive{
- WeakSelf;
- [LCHttpHelper requestWithURLString:GetRandLive parameters:@{} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- weakSelf.youpaipgetRandLives = [YOUPAILZLiveListItemModel mj_objectArrayWithKeyValuesArray:[dict objectForKey:@"data"]];
- [weakSelf.youpaipcollectionView reloadData];
- }
- } failure:^(NSError *error) {
- }];
- }
- // 观众加入直播间
- - (void)youpaifjoinLiveWithRoomId:(NSString *)roomId is_comein_room_hide:(NSInteger)is_comein_room_hide{
- [ZCHUDHelper showWithStatus:nil];
- WeakSelf;
- [LCHttpHelper requestWithURLString:JoinLive parameters:@{@"room_id":roomId,@"is_comein_room_hide":@(is_comein_room_hide)} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- [ZCHUDHelper dismiss];
- [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom];
- YOUPAILZLiveModel *youpaipliveModel = [YOUPAILZLiveModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
- if(youpaipliveModel.youpaiptype == 0){
- YOUPAILZEndLiveHintModel *model1 = [YOUPAILZEndLiveHintModel mj_objectWithKeyValues:dict[@"data"][@"user_info"]];
-
- YOUPAILZEndLiveHintView *view = [[YOUPAILZEndLiveHintView alloc]initWithFrame:CGRectZero Model:model1];
- }else{
- [ZCHUDHelper dismiss];
- [LCSaveData saveLiveRankTopThere:youpaipliveModel.youpaiprank_top_three];
- YOUPAILZLiveAudienceVC *audienceVC = [[YOUPAILZLiveAudienceVC alloc] initWithModel:youpaipliveModel];
- [[YOUPAILZLiveManagerListUtils shared] youpaifreloadManagerListWithLiveId:youpaipliveModel.youpaiplive_id];
- [weakSelf.navigationController pushViewController:audienceVC animated:NO];
- }
- }else{
- [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- //
- //- (void)viewWillLayoutSubviews{
- // [super viewWillLayoutSubviews];
- // [UIView animateWithDuration:0.25f animations:^{
- // self.collectionView.frame = self.view.bounds;
- // }];
- //}
- - (YYImage *)icLiveZhibozhong28{
- if (!_icLiveZhibozhong28) {
- NSString *path = [[NSBundle mainBundle] pathForResource:@"ic_live_zhibozhong_28" ofType:@"gif"];
- _icLiveZhibozhong28 = [YYImage imageWithData:[NSData dataWithContentsOfFile:path]];
- }
- return _icLiveZhibozhong28;
- }
- - (YYImage *)icLiveZhibozhong38{
- if (!_icLiveZhibozhong38) {
- NSString *path = [[NSBundle mainBundle] pathForResource:@"ic_live_zhibozhong_38" ofType:@"gif"];
- _icLiveZhibozhong38 = [YYImage imageWithData:[NSData dataWithContentsOfFile:path]];
- }
- return _icLiveZhibozhong38;
- }
- - (YYImage *)youpaipicLiveUserHeader{
- if (!_youpaipicLiveUserHeader) {
- NSString *path = [[NSBundle mainBundle] pathForResource:@"ic_live_header" ofType:@"gif"];
- _youpaipicLiveUserHeader = [YYImage imageWithData:[NSData dataWithContentsOfFile:path]];
- }
- return _youpaipicLiveUserHeader;
- }
- #pragma mark - JXPagingViewListViewDelegate
- - (UIView *)listView{
- return self.view;
- }
- - (UIScrollView *)listScrollView{
- return self.youpaipcollectionView;
- }
- - (void)listViewDidScrollCallback:(void (^)(UIScrollView *))callback {
- self.scrollCallback = callback;
- }
- @end
|