// // YOUPAILCBaseDynamicVC.m // LiveChat // // Created by 张灿 on 2018/9/7. // Copyright © 2018年 caicai. All rights reserved. // #import "YOUPAILCBaseDynamicVC.h" #import "YOUPAILCDynamicCell.h" #import "YOUPAILCReportVC.h" #import "YOUPAILZUserShowVC.h" #import "YOUPAILCGiftSendView.h" #import "YOUPAILCIMSessionVC.h" #import "YOUPAILCTabBarVC.h" #import "YOUPAILCDynamicSendVideoByLinkVC.h" #import "YOUPAILZCommonGiftView.h" #import "UIViewController+TFPresent.h" #import "YBIBVideoData.h" #import "YOUPAIXRWalletVC.h" #import "LZAlertWindow.h" #import "YOUPAIHRRechargePayWindow.h" @interface YOUPAILCBaseDynamicVC () @property(nonatomic,assign)NSInteger youpaipcurrentPage; @property(nonatomic,assign)NSInteger youpaipcurrentSize; @property(nonatomic,assign)NSInteger youpaiptotalPage; @property(nonatomic,strong)NSMutableArray* youpaipdynamicArray; @property(nonatomic,strong)NSMutableArray* youpaipdynamicIdArray; @property (nonatomic,strong) NSMutableDictionary *youpaipheightDict; @end @implementation YOUPAILCBaseDynamicVC -(void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (NSMutableDictionary *)youpaipheightDict{ if (_youpaipheightDict == nil) { _youpaipheightDict = [NSMutableDictionary dictionary]; } return _youpaipheightDict; } -(void)youpaifsetDynamicType:(NSInteger)type andGender:(NSInteger)gender { self.youpaiptype = type; self.youpaipgender = gender; [self.tableView.mj_header beginRefreshing]; } - (void)youpaifsetupTableView{ self.tableView.frame = CGRectZero; self.tableView.showsVerticalScrollIndicator = NO; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.estimatedRowHeight = 100; self.tableView.estimatedSectionFooterHeight = 0.0f; self.tableView.estimatedSectionHeaderHeight = 0.0f; self.tableView.delegate = self; self.tableView.dataSource= self; self.tableView.backgroundColor = LZFAFAFCColor; self.isAllowScroll = YES; [self.view addSubview:self.tableView]; [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.bottom.right.offset(0.0f); }]; self.tableView.mj_header = self.refreshHeader; self.tableView.mj_footer = self.noLoadMoreFooter; // self.tableView.mj_header = [LCRefreshDotGiftHeader headerWithRefreshingTarget:self refreshingAction:@selector(youpaifloadNewData)]; // MJRefreshAutoNormalFooter* normalFooter = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(youpaifloadMoreData)]; // [normalFooter setTitle:@"正在加载..." forState:(MJRefreshStateRefreshing)]; // [normalFooter setTitle:@"" forState:(MJRefreshStateNoMoreData)]; // self.tableView.mj_footer = normalFooter; // self.tableView.mj_footer.automaticallyHidden = YES; } /// 下拉刷新回调方法,具体实现代码需要子类实现 - (void)headerRefreshing{ self.youpaipcurrentPage = 1; [self getDynamicListData]; } /// 上拉加载回调方法,具体实现代码需要子类实现 - (void)footerRefreshing{ self.youpaipcurrentPage++; [self getDynamicListData]; } - (void)getDynamicListData{ [LCHttpHelper requestWithURLString:DynamicList parameters:@{ @"page":@(self.youpaipcurrentPage), @"type":@(self.youpaiptype), @"gender":@(self.youpaipgender) } needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) { NSDictionary *data = [dict dictionaryValueForKey:@"data" defaultValue:@{}]; NSArray *result = [data arrayValueForKey:@"list" defaultValue:@[]]; if (self.youpaipcurrentPage == 1) { [self.youpaipheightDict removeAllObjects]; [self.youpaipdynamicArray removeAllObjects]; [self.youpaipdynamicIdArray removeAllObjects]; } // // NSArray* array = [[dict objectForKey:@"data"]objectForKey:@"list"]; NSMutableArray* modelArray = [YOUPAILCDynamicModel mj_objectArrayWithKeyValuesArray:result]; NSMutableArray* tempArray = [NSMutableArray arrayWithArray:(NSArray*)modelArray]; for (YOUPAILCDynamicModel* model in modelArray) { if ([self.youpaipdynamicIdArray containsObject:model.youpaipdynamicId]) { [tempArray removeObject:model]; }else{ [self.youpaipdynamicIdArray addObject:model.youpaipdynamicId]; } } [self.youpaipdynamicArray addObjectsFromArray:tempArray]; // self.youpaiptotalPage = [[[dict objectForKey:@"data"]objectForKey:@"total_page"]integerValue]; // self.youpaipcurrentPage = [[[dict objectForKey:@"data"]objectForKey:@"page"]integerValue]; [self.tableView reloadData]; self.tableView.mj_footer = result.count < self.youpaipcurrentSize ? self.noLoadMoreFooter : self.loadMoreFooter; // if (self.youpaipcurrentPage>=self.youpaiptotalPage) { // [self.tableView.mj_footer endRefreshingWithNoMoreData]; // self.tableView.mj_footer.hidden = YES; // } if (self.youpaipdynamicArray.count != 0) { [self.tableView lz_hideEmptyView]; }else{ [self.tableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_dynamic_data"] content:@"暂无发布动态"]; } [self.tableView.mj_header endRefreshing]; [self.tableView.mj_footer endRefreshing]; }else{ [self.tableView.mj_header endRefreshing]; [self.tableView.mj_footer endRefreshing]; } } failure:^(NSError *error) { if(self.youpaipcurrentPage != 1){ self.youpaipcurrentPage--; } [self.tableView.mj_header endRefreshing]; [self.tableView.mj_footer endRefreshing]; }]; } - (void)youpaifloadNewData{ self.tableView.mj_footer.hidden = YES; [self.tableView.mj_footer endRefreshing];//先结束上拉,假如有的话 self.youpaipcurrentPage = 1; [LCHttpHelper requestWithURLString:DynamicList parameters:@{@"page":@(self.youpaipcurrentPage),@"type":@(self.youpaiptype),@"gender":@(self.youpaipgender)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 [self.youpaipheightDict removeAllObjects]; [self.youpaipdynamicArray removeAllObjects]; [self.youpaipdynamicIdArray removeAllObjects]; NSArray* array = [[dict objectForKey:@"data"]objectForKey:@"list"]; NSMutableArray* modelArray = [YOUPAILCDynamicModel mj_objectArrayWithKeyValuesArray:array]; NSMutableArray* tempArray = [NSMutableArray arrayWithArray:(NSArray*)modelArray]; for (YOUPAILCDynamicModel* model in modelArray) { if ([self.youpaipdynamicIdArray containsObject:model.youpaipdynamicId]) { [tempArray removeObject:model]; }else{ [self.youpaipdynamicIdArray addObject:model.youpaipdynamicId]; } } [self.youpaipdynamicArray addObjectsFromArray:tempArray]; self.youpaiptotalPage = [[[dict objectForKey:@"data"]objectForKey:@"total_page"]integerValue]; self.youpaipcurrentPage = [[[dict objectForKey:@"data"]objectForKey:@"page"]integerValue]; [self.tableView reloadData]; if (self.youpaipcurrentPage>=self.youpaiptotalPage) { [self.tableView.mj_footer endRefreshingWithNoMoreData]; self.tableView.mj_footer.hidden = YES; } if (self.youpaipdynamicArray.count != 0) { [self.tableView lz_hideEmptyView]; }else{ [self.tableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_dynamic_data"] content:@"暂无发布动态"]; } [self.tableView.mj_header endRefreshing]; }else{ [self.tableView.mj_header endRefreshing]; } } failure:^(NSError *error) { [self.tableView.mj_header endRefreshing]; }]; } - (void)youpaifloadMoreData{ //先结束下拉 假如有的话 [self.tableView.mj_header endRefreshing]; self.tableView.mj_footer.hidden = YES; [self.tableView.mj_footer endRefreshing]; self.youpaipcurrentPage+=1; // AppDelegate* app =(AppDelegate*)[UIApplication sharedApplication].delegate; // YOUPAILCTabBarVC* tabbar = [[YOUPAILCTabBarVC alloc]init]; // app.window.rootViewController = tabbar; [LCHttpHelper requestWithURLString:DynamicList parameters:@{@"page":@(self.youpaipcurrentPage),@"type":@(self.youpaiptype),@"gender":@(self.youpaipgender)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 NSArray* array = [[dict objectForKey:@"data"]objectForKey:@"list"]; NSMutableArray* modelArray = [YOUPAILCDynamicModel mj_objectArrayWithKeyValuesArray:array]; NSMutableArray* tempArray = [NSMutableArray arrayWithArray:(NSArray*)modelArray]; for (YOUPAILCDynamicModel* model in modelArray) { if ([self.youpaipdynamicIdArray containsObject:model.youpaipdynamicId]) { [tempArray removeObject:model]; }else{ [self.youpaipdynamicIdArray addObject:model.youpaipdynamicId]; } } [self.youpaipdynamicArray addObjectsFromArray:tempArray]; self.youpaiptotalPage = [[[dict objectForKey:@"data"]objectForKey:@"total_page"]integerValue]; self.youpaipcurrentPage = [[[dict objectForKey:@"data"]objectForKey:@"page"] integerValue]; [self.tableView reloadData]; if (self.youpaipcurrentPage>=self.youpaiptotalPage) { [self.tableView.mj_footer endRefreshingWithNoMoreData]; self.tableView.mj_footer.hidden = YES; } [self.tableView.mj_header endRefreshing]; }else{ [self.tableView.mj_header endRefreshing]; } } failure:^(NSError *error) { [self.tableView.mj_header endRefreshing]; }]; } - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = LZFAFAFCColor; self.youpaipdynamicArray = [NSMutableArray array]; self.youpaipdynamicIdArray = [NSMutableArray array]; [self youpaifsetupTableView]; [self.tableView.mj_header beginRefreshing]; self.youpaipcurrentPage = 1; self.youpaipcurrentSize = 10; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youpaiftoTopAction) name:@"dynamicToTop" object:nil];//置顶 } -(void)youpaiftoTopAction { if (self.youpaipdynamicArray.count != 0) { NSIndexPath* indexPat = [NSIndexPath indexPathForRow:0 inSection:0]; [self.tableView scrollToRowAtIndexPath:indexPat atScrollPosition:UITableViewScrollPositionBottom animated:YES]; } } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ CGFloat height = 9.0f; if (self.youpaipdynamicArray.count != 0) { YOUPAILCDynamicModel* model = self.youpaipdynamicArray[section]; if (model.youpaipstatus == 0) { height += 27.0f; } } return height; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return CGFLOAT_MIN; } -(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 27.0f + 9.0f)]; UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 9.0f, KScreenWidth, 27)]; headerView.backgroundColor = [UIColor whiteColor]; [v addSubview:headerView]; //bg UIView *bgView = [UIView new]; [headerView addSubview:bgView]; [bgView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(0); }]; bgView.backgroundColor = [UIColor whiteColor]; //icon UIImageView *iconImage = [UIImageView new]; [bgView addSubview:iconImage]; [iconImage mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(16); make.centerY.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(15, 15)); }]; iconImage.image = [UIImage imageNamed:@"vqu_images_D_dynamic_hint"]; iconImage.contentMode = UIViewContentModeScaleAspectFill; iconImage.clipsToBounds = YES; //title UILabel *titleLabel = [UILabel new]; [bgView addSubview:titleLabel]; [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(iconImage.mas_right).offset(6); make.centerY.mas_equalTo(0); }]; titleLabel.text = @"动态将在审核后发布"; titleLabel.textColor = HexColorFromRGB(0xFFA68B); titleLabel.font = [UIFont systemFontOfSize:12]; YOUPAILCDynamicModel* model = self.youpaipdynamicArray[section]; if (model.youpaipstatus == 0) { //1676 return v; }else{ return [UIView new]; } } - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 150; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ CGFloat height; YOUPAILCDynamicModel* model =self.youpaipdynamicArray[indexPath.section]; NSNumber* number =[self.youpaipheightDict objectForKey:model.youpaipdynamicId]; if (number && [number floatValue]>0) { height = [number floatValue]; }else{ height = [YOUPAILCDynamicCell youpaifcellHeightWithModel:self.youpaipdynamicArray[indexPath.section]]; [self.youpaipheightDict setObject:[NSNumber numberWithFloat:(float)height] forKey:model.youpaipdynamicId]; } return height; } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return self.youpaipdynamicArray.count; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ // NSLog(@"数组数量 == %ld",self.youpaipdynamicArray.count); return 1; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ YOUPAILCDynamicCell* cell = [[YOUPAILCDynamicCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YOUPAILCDynamicCell"]; YOUPAILCDynamicModel* model = self.youpaipdynamicArray[indexPath.section]; cell.youpaipdelegate = self; cell.youpaipcurrentIndex = indexPath.section; cell.youpaipdynamicModel = model; cell.backgroundColor = [UIColor whiteColor]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ //动态无响应事件 } - (void)youpaifclickReward:(YOUPAILCDynamicModel*)model{ if ([[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id isEqualToString:model.youpaipuser_id]) { [ZCHUDHelper showTitle:@"不能赠送自己"]; }else{ YOUPAILCGiftSendView* sendView = [[YOUPAILCGiftSendView alloc]initWithModel:nil type:1]; //modify by leo fix bug 20191009 sendView.youpaipalertWindow.hidden = NO; // sendView.alertWindow.rootViewController = self; sendView.youpaipsendMultiGift = ^(NSString *giftId, NSInteger count) { [LCHttpHelper requestWithURLString:DynamicSendGift parameters:@{@"num":@(count),@"dynamic_id":model.youpaipdynamicId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 [ZCHUDHelper showTitle:@"赠送成功"]; } } failure:^(NSError *error) { }]; }; [sendView youpaifshow]; } } -(void)youpaifclickImVideo:(YOUPAILCDynamicModel *)model { if ([YOUPAILZChatRoomManager shareManager].chatroomWindow != nil && [YOUPAILZChatRoomManager shareManager].chatroomWindow.hidden == NO) { [ZCHUDHelper showTitle:@"你正在房间中,暂不可拨打视频"]; return; } [UCAuthorityManager cameraAuthority:^{ [LCHttpHelper requestWithURLString:CallChatType parameters:@{@"to_uid":model.youpaipuser_id,@"skill_id":@"",@"type":@"0"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 YOUPAILCVideoChatModel* videoModel = [YOUPAILCVideoChatModel mj_objectWithKeyValues:[dict objectForKey:@"data"]]; [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom]; [[NSNotificationCenter defaultCenter] postNotificationName:@"MeCallVideo" object:nil userInfo:nil]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ YOUPAILCVideoRequestVC* chatRequest = [[YOUPAILCVideoRequestVC alloc]init]; chatRequest.youpaipvideoModel = videoModel; //modify by leo fix bug ios13 ZCBaseNavigationVC *nav = [[ZCBaseNavigationVC alloc]initWithRootViewController:chatRequest]; chatRequest.view.backgroundColor = HexColorFromRGBA(0x000000, 0.55); chatRequest.definesPresentationContext = YES; nav.modalPresentationStyle = UIModalPresentationOverCurrentContext; [self.navigationController presentViewController:nav animated:YES completion:^{ // chatRequest.view.backgroundColor = HexColorFromRGBA(0x000000, 0.55); }]; }); } } failure:^(NSError *error) { }]; } denied:^{ dispatch_async(dispatch_get_main_queue(), ^{ UIAlertController *systemAlert = [UIAlertController alertControllerWithTitle:@"请在iphone的“设置-隐私-相机”选项中,允许APP访问您的相机。" message:nil preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"现在去设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){ if ([[UIDevice currentDevice].systemVersion floatValue] < 10.0) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; } else { // 去系统设置页面 if (@available(iOS 10.0, *)) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil]; } else { // Fallback on earlier versions } } }]; UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]; [systemAlert addAction:cancelAction]; [systemAlert addAction:action]; [self presentViewController: systemAlert animated: YES completion: nil]; }); }]; } -(void)youpaifclickImChat:(YOUPAILCDynamicModel *)model{ [self goChatPageWithUserId:model.youpaipuser_id]; } - (void)goChatPageWithUserId:(NSString *)userId{ @weakify(self); if (![LCTools isGirlsRealNameAuthentication]) { return; }; NIMSession *session = [NIMSession session:userId type:NIMSessionTypeP2P]; if (session) { [ZCHUDHelper show]; [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray * _Nullable users, NSError * _Nullable error) { @strongify(self); [ZCHUDHelper dismiss]; YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session]; vc.type = @"2"; [self.navigationController pushViewController:vc animated:YES]; }]; } // [UMengRecordTool umengEventCountWithId:PrivateChatDynamic]; // [LCHttpHelper requestWithURLString:IsChat parameters:@{@"user_id":userId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { // NSDictionary* dict = (NSDictionary*)responseObject; // NSInteger code = [[dict objectForKey:@"code"] integerValue]; // if (code==0) {//成功 // NSInteger is_chat = [[[dict objectForKey:@"data"] objectForKey:@"is_chat"] integerValue]; // NSString *msg = [[dict objectForKey:@"data"] objectForKey:@"msg"]; // @strongify(self); // if (is_chat == 0) { /// 0不可以 1可以私信 // LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"再想想" handler:^(LZAlertAction *action) { // // }]; // cancelAction.cornerRadius = 5.0f; // cancelAction.color = LZ273145Color; // cancelAction.bgColor = LZF5F4F7Color; // LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"去充值" handler:^(LZAlertAction *action) { // @strongify(self); // YOUPAIHRRechargePayWindow *payWindow = [YOUPAIHRRechargePayWindow new]; // payWindow.isTouchDismiss = NO; // [self.navigationController TFPresentVC:payWindow completion:^{ // // }]; // }]; // confimAction.cornerRadius = 5.0f; // confimAction.color = [UIColor whiteColor]; // confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]]; // LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"提示" content:msg action:@[cancelAction,confimAction]]; // alert.contentTextAlignment = NSTextAlignmentCenter; // [self TFPresentVC:alert completion:^{}]; // }else{ // [UMengRecordTool umengEventCountWithId:InitiatePrivateChat]; // NIMSession *session = [NIMSession session:userId type:NIMSessionTypeP2P]; // if (session) { // [ZCHUDHelper show]; // [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray * _Nullable users, NSError * _Nullable error) { // @strongify(self); // [ZCHUDHelper dismiss]; // YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session]; // vc.type = @"2"; // [self.navigationController pushViewController:vc animated:YES]; // }]; // } // } // } // } failure:^(NSError *error) { // }]; } - (void)youpaifclickAvatar:(YOUPAILCDynamicModel*)model{ // LCUserShowVC* userShow = [[LCUserShowVC alloc]init]; // YOUPAILZUserShowVC *userShow = [[YOUPAILZUserShowVC alloc] init]; // userShow.youpaipuserId = model.youpaipuser_id; // [self.navigationController pushViewController:userShow animated:YES]; YMPersonalPageViewModel *personalPageVM = [[YMPersonalPageViewModel alloc]initWithParams:@{ ParamsId:@([model.youpaipuser_id intValue]) }]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_PERSONAL_PAGE) withUserInfo:@{ RouterViewModel:personalPageVM } completion:nil]; } -(void)youpaifclickAttention:(YOUPAILCDynamicModel *)model { if (model.youpaipis_follow == 0) {//+关注 [LCCommonHttp followUserId:model.youpaipuser_id]; model.youpaipis_follow = 1; [self.tableView reloadData]; }else{ [LCCommonHttp followUserId:model.youpaipuser_id]; model.youpaipis_follow = 0; [self.tableView reloadData]; } } - (void)youpaifclickMoreBtn:(YOUPAILCDynamicModel*)model index:(NSInteger)index{ NSMutableArray* actionArray = [NSMutableArray array]; if ([model.youpaipuser_id isEqualToString:[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id]) { ZCAlertAction* action = [ZCAlertAction actionWithTitle:@"删除" andblock:^{//删除动态 [LCHttpHelper requestWithURLString:DynamicDelete parameters:@{@"dynamic_id":model.youpaipdynamicId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 [self.youpaipdynamicArray removeObject:model]; [self.youpaipdynamicIdArray removeObject:model.youpaipdynamicId]; [self.youpaipheightDict removeObjectForKey:model.youpaipdynamicId]; [self.tableView reloadData]; } } failure:^(NSError *error) { }]; }]; [actionArray addObject:action]; }else{ if ([[LCSaveData getServiceIdArr] containsObject:[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id]) { ZCAlertAction* action1 = [ZCAlertAction actionWithTitle:@"删除整条" andblock:^{//删除动态 [LCHttpHelper requestWithURLString:DynamicDelete parameters:@{@"dynamic_id":model.youpaipdynamicId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 [self.youpaipdynamicArray removeObject:model]; [self.youpaipdynamicIdArray removeObject:model.youpaipdynamicId]; [self.youpaipheightDict removeObjectForKey:model.youpaipdynamicId]; NSIndexPath *reloadIndexPath = [NSIndexPath indexPathForRow:index inSection:0]; [self.tableView deleteRowsAtIndexPaths:@[reloadIndexPath] withRowAnimation:(UITableViewRowAnimationNone)]; } } failure:^(NSError *error) { }]; }]; [actionArray addObject:action1]; ZCAlertAction* action2 = [ZCAlertAction actionWithTitle:@"删除文字" andblock:^{//删除动态 [LCHttpHelper requestWithURLString:DynamicDeleteLower parameters:@{@"type":@"1",@"info_id":model.youpaipdynamicId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 model.youpaipcontent = @""; NSIndexPath *reloadIndexPath=[NSIndexPath indexPathForRow:index inSection:0]; [self.tableView reloadRowsAtIndexPaths:@[reloadIndexPath] withRowAnimation:UITableViewRowAnimationNone]; } } failure:^(NSError *error) { }]; }]; [actionArray addObject:action2]; } ZCAlertAction* reportAction = [ZCAlertAction actionWithTitle:@"举报该条动态" andblock:^{//举报 YOUPAILCReportVC* report = [[YOUPAILCReportVC alloc]init]; report.youpaipreport_uid = model.youpaipuser_id; report.youpaiptype = 3; [self.navigationController pushViewController:report animated:YES]; }]; [actionArray addObject:reportAction]; } ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:actionArray]; //modify by leo --fix bug ios13 20191009 //alertSheet.alertWindow.rootViewController = self; alertSheet.alertWindow.hidden = NO; [alertSheet show]; } #pragma mark-点击播放短视频 -(void)youpaiffootViewdidSendGift:(YOUPAILCDynamicModel *)model{ YOUPAILZCommonGiftView *view = [YOUPAILZCommonGiftView new]; view.isTouchDismiss = YES; view.youpaipisAnchor = NO; [view setJumToWalletBlock1:^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [[NSNotificationCenter defaultCenter] postNotificationName:@"InsufficientBalanceNotice" object:nil userInfo:nil]; YOUPAIXRWalletVC *coinRecharge = [[YOUPAIXRWalletVC alloc]init]; [self.navigationController pushViewController:coinRecharge animated:YES]; }); }]; [view setYoupaiplzgiftblock:^(YOUPAILCGiftModel * _Nonnull giftModel, NSInteger count,NSString*categoryID) { // 1 个人详情页 2.IM页面 3视频页 4.直播间 [LCHttpHelper requestWithURLString:SendGift_New parameters:@{@"type":@(3),@"to_uid":model.youpaipuser_id,@"gift_id":giftModel.youpaipid,@"num":@(count),@"gift_type_id":categoryID} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 [ZCHUDHelper showTitle:@"礼物赠送成功"]; } } failure:^(NSError *error) { }]; }]; [self TFPresentVC:view completion:^{ }]; } -(void)youpaifCelldidPlayVideo:(YOUPAILCDynamicModel *)model{ if (model.youpaipfile_url.length>0) {//废弃 // YBIBVideoData *model1 = [YBIBVideoData new]; // model1.videoURL = [NSURL URLWithString:model.file_url]; //// model1.projectiveView = self.imgViewArray[i]; // // YBImageBrowser *browser = [YBImageBrowser new]; // browser.dataSourceArray = @[model1]; // browser.currentPage = 0; // [browser show]; // YOUPAILCDynamicSendVideoByLinkVC *vc = [YOUPAILCDynamicSendVideoByLinkVC new]; // vc.videoLikesModel = model; // [self.navigationController pushViewController:vc animated:YES]; } } -(void)youpaifdeleteImage:(YOUPAILCDynamicModel *)model index:(NSInteger)index { CGFloat height = [YOUPAILCDynamicCell youpaifcellHeightWithModel:self.youpaipdynamicArray[index]]; [self.youpaipheightDict setObject:[NSNumber numberWithFloat:(float)height] forKey:model.youpaipdynamicId]; NSIndexPath *reloadIndexPath=[NSIndexPath indexPathForRow:index inSection:0]; [self.tableView reloadRowsAtIndexPaths:@[reloadIndexPath] withRowAnimation:UITableViewRowAnimationNone]; } - (void)youpaifneedUpdateCellHeight:(NSInteger)index cell:(YOUPAILCDynamicCell *)cell{ NSIndexPath *reloadIndexPath = [NSIndexPath indexPathForRow:index inSection:0]; [self.youpaipheightDict setObject:[NSNumber numberWithFloat:cell.youpaipcellHeight] forKey:cell.youpaipdynamicModel.youpaipdynamicId]; [self.tableView beginUpdates]; [self.tableView reloadRowsAtIndexPaths:@[reloadIndexPath] withRowAnimation:(UITableViewRowAnimationNone)]; [self.tableView endUpdates]; } #pragma mark - JXCategoryListContentViewDelegate - (UIView *)listView{ return self.view; } @end