// // YOUPAILCIMSessionVC.m // LiveChat // // Created by 张灿 on 2018/9/1. // Copyright © 2018年 caicai. All rights reserved. // #import "YOUPAILCIMSessionVC.h" #import "YOUPAILCGiftModel.h" #import "YOUPAIUCIMVideoVC.h" #import "YOUPAILPChatTipView.h" #import "YOUPAIZYXianNvBangModel.h" #import "YOUPAIZYXianNvBangVC.h" #import "UIViewController+TFPresent.h" #import "YOUPAIXRWalletVC.h" #import #import #import "YOUPAILZCommonGiftView.h" #import "YOUPAIBBVideoRequestVC.h" #import "LZAlertWindow.h" #import "YOUPAIHRRechargePayWindow.h" #import "YOUPAILZIMCommonWordsVC.h" #import "YOUPAILZIMCommonWordModel.h" #import "YOUPAILCIMTool.h" #import "NIMMessageMaker.h" #import "YOUPAILZSessionCommonWordCell.h" #import "YOUPAIHRWebWindow.h" #import "YOUPAILCBannerModel.h" #import "YMReportViewController.h" #import "YOUPAILCVideoResponseVC.h" #import "YOUPAILZLiveGIftModel.h" @interface YOUPAILCIMSessionVC() @property (nonatomic,strong) UIImageView *currentImgV; @property (nonatomic,strong) UIButton *xianNvBangBtn; @property(nonatomic,strong)YOUPAIZYXianNvBangModel *fairyInfo; @property (nonatomic,strong)SVGAPlayer *svgaPlayer; @property (nonatomic,strong)SVGAParser *parser; @property (nonatomic,strong) UIButton *intimateBtn; // 亲密值按钮 @property (nonatomic, weak) UICollectionView *youpaipcommonWordCollectionView; @property (nonatomic, strong) NSArray *youpaipcommonWords; @end @implementation YOUPAILCIMSessionVC //- (UIStatusBarStyle)preferredStatusBarStyle{ // return UIStatusBarStyleLightContent; //} - (void)dealloc{ [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; self.navigationController.navigationBar.hidden = NO; } - (void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; [self deletUnwantedVC]; } - (void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [[NIMSDK sharedSDK].mediaManager stopRecord]; [[NIMSDK sharedSDK].mediaManager stopPlay]; } - (void)viewDidLoad{ [super viewDidLoad]; [UMengRecordTool umengEventCountWithId:EnterChatPage]; [self youpaifrefreshUserInfo]; UIButton* xianNvBangBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth - 13 -67, KScreenWidth-150,67,91.5)]; [xianNvBangBtn setImage:[UIImage imageNamed:@"vqu_images_xiannv"] forState:UIControlStateNormal]; [xianNvBangBtn addTarget:self action:@selector(youpaifxianNvBangBtnClick) forControlEvents:(UIControlEventTouchUpInside)]; self.xianNvBangBtn = xianNvBangBtn; self.xianNvBangBtn.hidden = YES; [self.view addSubview:xianNvBangBtn]; self.tableView.backgroundColor = HexColorFromRGBA(0xFAFAFC, 1); self.svgaPlayer = [[SVGAPlayer alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.svgaPlayer.contentMode = UIViewContentModeScaleAspectFit; self.svgaPlayer.delegate = self; self.svgaPlayer.userInteractionEnabled = NO; [[[UIApplication sharedApplication] keyWindow] addSubview:self.svgaPlayer]; self.svgaPlayer.hidden = YES; self.svgaPlayer.loops = 1; self.svgaPlayer.clearsAfterStop = true; self.parser = [[SVGAParser alloc] init]; [self youpaifaddTip]; [self youpaiploadCommonWordsData]; [self youpaifrequestUserinfoData]; [self youpaifinitIntimateBtn]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youpaifintimateChangeNotification:) name:@"VQUIMIntimateChangeNotification" object:nil]; } #pragma mark - 删除不需要的视图控制器 - (void)deletUnwantedVC{ for (UIViewController *vc in self.navigationController.viewControllers) { if ([vc isKindOfClass:[YMReportViewController class]]) { [vc removeFromParentViewController]; } } } -(void)sendMessage:(NIMMessage *)message{ [super sendMessage:message]; if ([self.type isEqualToString:@"1"]) { [UMengRecordTool umengEventCountWithId:PrivateChatHome]; }else if ([self.type isEqualToString:@"2"]){ [UMengRecordTool umengEventCountWithId:PrivateChatDynamic]; }else if ([self.type isEqualToString:@"3"]){ [UMengRecordTool umengEventCountWithId:PrivateChatMessage]; } } - (void)youpaifinitIntimateBtn{ UIButton *intimateBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [intimateBtn setImage:[UIImage imageNamed:@"vqu_images_im_chat_intimate"] forState:UIControlStateNormal]; [intimateBtn setTitle:@"0°C" forState:UIControlStateNormal]; [intimateBtn setTitleColor:LZFE66A4Color forState:UIControlStateNormal]; intimateBtn.titleLabel.font = LCFont(8.0f); [intimateBtn addTarget:self action:@selector(youpaifintimateBtnClick) forControlEvents:UIControlEventTouchUpInside]; CGFloat totalHeight = 52.0f; CGFloat imageSize = 40.0f; CGFloat titleHeight = 10.0f; intimateBtn.imageEdgeInsets = UIEdgeInsetsMake(- (totalHeight - imageSize), -(imageSize/2.0f)+4.0f, 0.0, - imageSize); intimateBtn.titleEdgeInsets = UIEdgeInsetsMake(0, - imageSize, - (totalHeight - titleHeight), 0); [self.view addSubview:intimateBtn]; self.intimateBtn = intimateBtn; [intimateBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.offset(-12.0f); make.top.offset(48.0f); make.size.mas_offset(CGSizeMake(40.0f, 52.0f)); }]; NSDictionary *dict = [[YOUPAILZIntimateManager shareManager].intimateDict objectForKey:self.session.sessionId]; NSInteger grade = [[dict objectForKey:@"grade"] integerValue]; NSString *score = [dict objectForKey:@"score"]; if (score.length != 0 && ![LCSaveData getWhiteVersion]) { [self.intimateBtn setTitle:[NSString stringWithFormat:@"%@°C",score] forState:UIControlStateNormal]; self.intimateBtn.hidden = NO; }else{ [self.intimateBtn setTitle:[NSString stringWithFormat:@"%@°C",@"0.0"] forState:UIControlStateNormal]; self.intimateBtn.hidden = YES; } // @weakify(self); // [LCHttpHelper requestWithURLString:GetIntimateList parameters:@{@"ids":self.session.sessionId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { // @strongify(self); // NSDictionary* dict = (NSDictionary*)responseObject; // NSInteger code = [[dict objectForKey:@"code"] integerValue]; // if (code == 0) {//成功 // NSArray *list = [[dict objectForKey:@"data"] objectForKey:@"list"]; // for (NSDictionary *intimate in list) { // NSString *score = [NSString stringWithFormat:@"%@",[intimate objectForKey:@"score"]]; // NSString *grade = [NSString stringWithFormat:@"%@",[intimate objectForKey:@"grade"]]; // NSString *uid = [NSString stringWithFormat:@"%@",[intimate objectForKey:@"user_id"]]; // [[YOUPAILZIntimateManager shareManager].intimateDict setObject:@{ // @"score":[NSString stringWithFormat:@"%@",score], // @"grade":[NSString stringWithFormat:@"%@",grade], // } forKey:uid]; // } // // NSDictionary *dict = [[YOUPAILZIntimateManager shareManager].intimateDict objectForKey:self.session.sessionId]; // NSInteger grade = [[dict objectForKey:@"grade"] integerValue]; // NSString *score = [dict objectForKey:@"score"]; // if (score.length != 0 && ![LCSaveData getWhiteVersion]) { // [self.intimateBtn setTitle:[NSString stringWithFormat:@"%@°C",score] forState:UIControlStateNormal]; // self.intimateBtn.hidden = NO; // }else{ // [self.intimateBtn setTitle:[NSString stringWithFormat:@"%@°C",@"0.0"] forState:UIControlStateNormal]; // self.intimateBtn.hidden = YES; // } // } // } failure:^(NSError *error) { // // }]; } - (void)youpaifintimateBtnClick{ @weakify(self); [LCHttpHelper requestWithURLString:AppConfig parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { @strongify(self); NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 NSString *chatintimate = [[[dict objectForKey:@"data"]objectForKey:@"webUrl"] objectForKey:@"chatintimate"]; chatintimate = [NSString stringWithFormat:@"%@&user_id=%@",chatintimate,self.session.sessionId]; YOUPAILCBannerModel *model = [[YOUPAILCBannerModel alloc] init]; model.youpaipwindow_link = chatintimate; model.youpaipgravity = @"full"; YOUPAIHRWebWindow *window = [[YOUPAIHRWebWindow alloc] init]; window.isTouchDismiss = YES; window.youpaipurl = model.youpaipwindow_link; window.youpaipgravity = model.youpaipgravity; [self TFPresentVC:window completion:^{}]; } } failure:^(NSError *error) { }]; } - (void)youpaifintimateChangeNotification:(NSNotification *)notify{ NSDictionary *dict = [[YOUPAILZIntimateManager shareManager].intimateDict objectForKey:self.session.sessionId]; NSString *score = [dict objectForKey:@"score"]; if (score.length != 0 && ![LCSaveData getWhiteVersion]) { [self.intimateBtn setTitle:[NSString stringWithFormat:@"%@°C",score] forState:UIControlStateNormal]; self.intimateBtn.hidden = NO; }else{ [self.intimateBtn setTitle:[NSString stringWithFormat:@"%@°C",@"0.0"] forState:UIControlStateNormal]; self.intimateBtn.hidden = YES; } } ///资料卡 - (void)youpaifrequestUserinfoData{ /// 特殊用户 if ([self.session.sessionId isEqualToString:[LCSaveData getSysId]] || [self.session.sessionId isEqualToString:@"11"] || [[LCSaveData getServiceIdArr] containsObject:self.session.sessionId]) { return; } @weakify(self); [LCHttpHelper requestWithURLString:GetChatData parameters:@{@"user_id":self.session.sessionId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { @strongify(self); NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 NSDictionary *data = [dict objectForKey:@"data"]; if (data != nil && ![data isKindOfClass:NSNull.class]) { [self youpaifinitUserinfoUIWithDict:data]; } } } failure:^(NSError *error) { }]; } - (void)youpaifinitUserinfoUIWithDict:(NSDictionary *)dict{ UIButton *headerV = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 165.0f + 8.0f)]; [headerV addTarget:self action:@selector(goshowUserPage) forControlEvents:UIControlEventTouchUpInside]; UIView *bgV = [[UIView alloc] init]; bgV.backgroundColor = [UIColor whiteColor]; bgV.layer.cornerRadius = 12.0f; bgV.clipsToBounds = YES; bgV.userInteractionEnabled = NO; [headerV addSubview:bgV]; [bgV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.offset(8.0f); make.left.offset(16.0f); make.right.offset(-16.0f); make.bottom.offset(0.0f); }]; UIButton *authenticationDescBtn = [UIButton buttonWithType:UIButtonTypeCustom]; UIButton *cityDescBtn = [UIButton buttonWithType:UIButtonTypeCustom]; UIButton *infoDescBtn = [UIButton buttonWithType:UIButtonTypeCustom]; UIButton *imageDescBtn = [UIButton buttonWithType:UIButtonTypeCustom]; NSArray *contents = @[ @{@"image":[UIImage imageNamed:@"vqu_images_im_user_car_ver"],@"title":@" 认证状态:"}, @{@"image":[UIImage imageNamed:@"vqu_images_im_user_car_address"],@"title":@" 所在城市:"}, @{@"image":[UIImage imageNamed:@"vqu_images_im_user_car_info"],@"title":@" 基本信息:"}, @{@"image":[UIImage imageNamed:@"vqu_images_im_user_car_image"],@"title":@" 近期靓照:"}, ]; NSArray *btns = @[authenticationDescBtn,cityDescBtn,infoDescBtn,imageDescBtn]; for (NSInteger i = 0; i < btns.count; i ++) { NSDictionary *content = contents[i]; UIButton *btn = btns[i]; btn.userInteractionEnabled = NO; btn.frame = CGRectMake(12.0f, 8.0f + ((i + 1) * 8.0f) + i * 20.0f, 100.0f, 20.0f); [btn setImage:[content objectForKey:@"image"] forState:UIControlStateNormal]; [btn setTitle:[content objectForKey:@"title"] forState:UIControlStateNormal]; [btn setTitleColor:LZ273145Color forState:UIControlStateNormal]; btn.titleLabel.font = LCFont14; [bgV addSubview:btn]; } NSDictionary *auth = [dict objectForKey:@"auth"]; UIImageView *realPersonImgV = [[UIImageView alloc] init]; if ([[auth objectForKey:@"real_auth_status"] integerValue] == 0) { // 未认证 realPersonImgV.image = [UIImage imageNamed:@"vqu_images_im_real_person_n"]; }else{ realPersonImgV.image = [UIImage imageNamed:@"vqu_images_im_real_person"]; } [bgV addSubview:realPersonImgV]; [realPersonImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(authenticationDescBtn.mas_right).offset(4.0f); make.centerY.equalTo(authenticationDescBtn); make.size.mas_offset(CGSizeMake(64, 15)); }]; UIImageView *realNameImgV = [[UIImageView alloc] init]; if ([[auth objectForKey:@"auth_status"] integerValue] == 0) { // 未认证 realNameImgV.image = [UIImage imageNamed:@"vqu_images_im_real_name_n"]; }else{ realNameImgV.image = [UIImage imageNamed:@"vqu_images_im_real_name"]; } [bgV addSubview:realNameImgV]; [realNameImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(realPersonImgV.mas_right).offset(4.0f); make.centerY.equalTo(authenticationDescBtn); make.size.mas_offset(CGSizeMake(64, 15)); }]; UILabel *cityL = [[UILabel alloc] init]; cityL.textColor = LZ273145Color; cityL.text = [NSString stringWithFormat:@"%@市",[dict objectForKey:@"city"]]; cityL.font = LCFont(13.0f); [bgV addSubview:cityL]; [cityL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(cityDescBtn.mas_right).offset(4.0f); make.centerY.equalTo(cityDescBtn); }]; UILabel *infoL = [[UILabel alloc] init]; infoL.textColor = LZ273145Color; infoL.text = [dict objectForKey:@"base_info"]; infoL.font = LCFont(13.0f); [bgV addSubview:infoL]; [infoL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(infoDescBtn.mas_right).offset(4.0f); make.centerY.equalTo(infoDescBtn); }]; UIView *imageBgV = [[UIView alloc] init]; [bgV addSubview:imageBgV]; [imageBgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(imageDescBtn.mas_right); make.top.equalTo(imageDescBtn.mas_top); make.height.offset(49.0f); }]; NSMutableArray *imgVs = [NSMutableArray array]; NSArray *imgs = [dict objectForKey:@"albumList"]; for (NSInteger i = 0; i < imgs.count; i ++) { UIImageView *imgV = [[UIImageView alloc] init]; imgV.contentMode = UIViewContentModeScaleAspectFill; imgV.layer.cornerRadius = 10.0f; imgV.clipsToBounds = YES; imgV.backgroundColor = [UIColor redColor]; [imgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:[imgs[i] objectForKey:@"url"]]]; [imageBgV addSubview:imgV]; [imgVs addObject:imgV]; } if (imgVs.count > 1) { [imgVs mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:4.0f leadSpacing:4.0f tailSpacing:4.0f]; [imgVs mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.offset(0.0f); make.width.offset(49.0f); }]; }else if (imgVs.count == 1){ UIImageView *imgV = imgVs[0]; [imgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(4.0f); make.right.offset(-4.0f); make.width.offset(49.0f); make.top.bottom.offset(0.0f); }]; }else{ imageDescBtn.hidden = YES; imageBgV.hidden = YES; headerV.mj_h -= 57.0f; } self.tableView.tableHeaderView = headerV; } - (void)goshowUserPage{ // YOUPAILZUserShowVC *userShow = [[YOUPAILZUserShowVC alloc] init]; // userShow.youpaipuserId = self.session.sessionId; // [self.navigationController pushViewController:userShow animated:YES]; YMPersonalPageViewModel *personalPageVM = [[YMPersonalPageViewModel alloc]initWithParams:@{ ParamsId:@([self.session.sessionId intValue]) }]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_PERSONAL_PAGE) withUserInfo:@{ RouterViewModel:personalPageVM } completion:nil]; } //反色情提示 add by leo 注释 - (void)youpaifaddTip{ if ([self.session.sessionId isEqualToString:[LCSaveData getSysId]] || [self.session.sessionId isEqualToString:@"11"] || [[LCSaveData getServiceIdArr] containsObject:self.session.sessionId]) { return; } [LCHttpHelper requestWithURLString:ChatTip parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 if ([[[dict objectForKey:@"data"] allKeys] containsObject:@"fairy"]) { if ((![[LCSaveData getSysId] isEqualToString:self.session.sessionId]) && (![self.session.sessionId isEqualToString:@"11"]) ) { self.xianNvBangBtn.hidden = NO; self.fairyInfo = [YOUPAIZYXianNvBangModel mj_objectWithKeyValues:[[dict objectForKey:@"data"] objectForKey:@"fairy"]]; } }else{ self.xianNvBangBtn.hidden = YES; } NSString *tip = [[dict objectForKey:@"data"]objectForKey:@"tip"]; YOUPAILPChatTipView *chatTip = [[YOUPAILPChatTipView alloc]initWithFrame:CGRectMake(16.0f, -36.0f, KScreenWidth - 32.0f, 28.0f)]; chatTip.layer.cornerRadius = 6.0f; chatTip.clipsToBounds = YES; // chatTip.tipLabel.text = tip; [self.view addSubview:chatTip]; [chatTip ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP]; NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@",tip]]; NSTextAttachment *attch = [[NSTextAttachment alloc] init]; attch.image = [UIImage imageNamed:@"vqu_images_im_notice"]; // 设置图片大小 attch.bounds = CGRectMake(0, -1, 12, 12); // 创建带有图片的富文本 NSAttributedString *string = [NSAttributedString attributedStringWithAttachment:attch]; [attri insertAttributedString:string atIndex:0]; chatTip.tipLabel.attributedText = attri; dispatch_async(dispatch_get_main_queue(), ^{ [UIView animateWithDuration:2 animations:^{ chatTip.frame = CGRectMake(16.0f, 8.0f, KScreenWidth - 32.0f, 28.0f); }completion:^(BOOL finished) { if (finished) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [UIView animateWithDuration:1 animations:^{ chatTip.frame = CGRectMake(16.0f, -36.0f, KScreenWidth - 32.0f, 28.0f); }completion:^(BOOL finished) { if (finished) { [chatTip removeFromSuperview]; } }]; }); } }]; }); } } failure:^(NSError *error) { }]; } -(void)youpaifxianNvBangBtnClick { YOUPAIZYXianNvBangVC *VC= [[YOUPAIZYXianNvBangVC alloc]init]; // VC.delegate = self; VC.youpaipuser_id = self.session.sessionId; VC.vWidth = KScreenWidth *(320.0/375.0); VC.vHeight = (VC.vWidth*137)/320.0+165; VC.youpaipinfoModel = self.fairyInfo; VC.youpaipisChat = YES; VC.isTouchDismiss = YES; [self TFPresentVC:VC completion:^{}]; } #pragma mark - 刷新对方用户信息 - (void)youpaifrefreshUserInfo{ [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[self.session.sessionId] completion:^(NSArray * _Nullable users, NSError * _Nullable error) { // NIMUser* user = users[0]; }]; } #pragma mark - Cell事件 图片/视频点击查看 add by leo 注释 - (BOOL)onTapCell:(NIMKitEvent *)event { BOOL handled = [super onTapCell:event]; NSString *eventName = event.eventName; if ([eventName isEqualToString:NIMKitEventNameTapContent]) { NIMMessage *message = event.messageModel.message; NSDictionary *actions = [self youpaifcellActions]; NSString *value = actions[@(message.messageType)]; if (value) { SEL selector = NSSelectorFromString(value); if (selector && [self respondsToSelector:selector]) { if (message.messageType == NIMMessageTypeImage) { self.currentImgV = event.contentImage; } SuppressPerformSelectorLeakWarning([self performSelector:selector withObject:message]); handled = YES; } } } else if([eventName isEqualToString:NIMKitEventNameTapLabelLink]) { NSString *link = event.data; NSArray* tempArray = [[LCSaveData getTAppUrl] componentsSeparatedByString:@","]; for (NSString* str in tempArray) { if([link rangeOfString:str].location !=NSNotFound) { ZCBaseWebVC* base = [[ZCBaseWebVC alloc]init]; base.contentUrl = link; [self.navigationController pushViewController:base animated:YES]; } } //跳转到控制器 handled = YES; } if (!handled) { NSAssert(0, @"invalid event"); } return handled; } //头像点击事件 add by leo 注释 - (BOOL)onTapAvatar:(NIMMessage *)message{ [self.sessionInputView endEditing:YES]; // YOUPAILZUserShowVC *vc = [[YOUPAILZUserShowVC alloc] init]; // if ([message.from isEqualToString:self.session.sessionId]) { // vc.youpaipuserId = message.session.sessionId; // }else{ // vc.youpaipuserId = [LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id; // } // [self.navigationController pushViewController:vc animated:YES]; NSString *userId = @""; if ([message.from isEqualToString:self.session.sessionId]) { userId = message.session.sessionId; }else{ userId = [LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id; } YMPersonalPageViewModel *personalPageVM = [[YMPersonalPageViewModel alloc]initWithParams:@{ ParamsId:@([userId intValue]) }]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_PERSONAL_PAGE) withUserInfo:@{ RouterViewModel:personalPageVM } completion:nil]; return YES; } #pragma mark - Cell Actions 图片 视频点击事件 - (NSDictionary *)youpaifcellActions { static NSDictionary *actions = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ actions = @{@(NIMMessageTypeImage) : @"showImage:", @(NIMMessageTypeVideo) : @"showVideo:", @(NIMMessageTypeCustom): @"showCustom:"}; }); return actions; } - (void)showImage:(NIMMessage *)message { [self.view endEditing:YES]; NSMutableArray* imageArray = [NSMutableArray array]; for (int i =0; i obj2.timestamp; }]; NSInteger count = imageArray.count; NSMutableArray *photos = [NSMutableArray arrayWithCapacity:count]; for (NIMMessage *imageMessage in sortImageArray) { if (imageMessage.messageType == NIMMessageTypeImage) { NIMImageObject *object = (NIMImageObject *)imageMessage.messageObject; YBIBImageData *model = [YBIBImageData new]; model.imageURL = [NSURL URLWithString:object.url]; model.projectiveView = self.currentImgV; [photos addObject:model]; } } if (count!=0) { YBImageBrowser *browser = [YBImageBrowser new]; browser.dataSourceArray = photos; browser.currentPage = [sortImageArray indexOfObject:message]; [browser show]; } } - (void)showVideo:(NIMMessage *)message { NIMVideoObject *object = (NIMVideoObject*)message.messageObject; YOUPAILCIMVideoVC *playerViewController = [[YOUPAILCIMVideoVC alloc] initWithVideoObject:object]; [self pushEffectPresentToVC:playerViewController]; if(![[NSFileManager defaultManager] fileExistsAtPath:object.coverPath]){ //如果封面图下载了,点进视频的时候再去下一把封面图 __weak typeof(self) wself = self; [[NIMSDK sharedSDK].resourceManager download:object.coverUrl filepath:object.coverPath progress:nil completion:^(NSError *error) { if (!error) { [wself youpaifuiUpdateMessage:message]; } }]; } } //add by leo 注释 自定义消息 - (void)showCustom:(NIMMessage *)message { //普通的自定义消息点击事件可以在这里做哦~ NIMCustomObject *object = (NIMCustomObject*)message.messageObject; if ([object.attachment isKindOfClass:[YOUPAILCOneImageAttachment class]]) { YOUPAILCOneImageAttachment *attachment = (YOUPAILCOneImageAttachment *)object.attachment; if (attachment.link_type==1) {//打开H5页面 ZCBaseWebVC* web = [[ZCBaseWebVC alloc]init]; web.contentUrl = attachment.link_url; [self.navigationController pushViewController:web animated:YES]; }else if (attachment.link_type==2){//跳转本地页面 [self youpaifpageToStr:attachment.link_url]; } }else if ([object.attachment isKindOfClass:[YOUPAILCMultiImageAttachment class]]){ YOUPAILCMultiImageAttachment *attachment = (YOUPAILCMultiImageAttachment *)object.attachment; NSDictionary* dic; if ([message.localExt objectForKey:@"serial"]) { NSInteger ser = [[message.localExt objectForKey:@"serial"]integerValue]; dic = attachment.imageArray[ser]; }else{ dic = attachment.imageArray[0]; } if ([[dic objectForKey:@"link_type"] integerValue]==1) {//打开H5页面 ZCBaseWebVC* web = [[ZCBaseWebVC alloc]init]; web.contentUrl = [dic objectForKey:@"link_url"]; [self.navigationController pushViewController:web animated:YES]; }else if ([[dic objectForKey:@"link_type"] integerValue]==2){//跳转本地页面 [self youpaifpageToStr:[dic objectForKey:@"link_url"]]; } }else if([object.attachment isKindOfClass:[YOUPAILCMessageTxtAttachment class]]){ YOUPAILCMessageTxtAttachment *attachment = (YOUPAILCMessageTxtAttachment *)object.attachment; if (attachment.link_type!=0) { if (attachment.link_type==1) {//打开H5页面 ZCBaseWebVC* web = [[ZCBaseWebVC alloc]init]; web.contentUrl = attachment.link_url; [self.navigationController pushViewController:web animated:YES]; }else if (attachment.link_type==2){//跳转本地页面 [self youpaifpageToStr:attachment.link_url]; }else if(attachment.link_type==3){//执行本地逻辑 NSDictionary* dict = [attachment.link_url mj_JSONObject]; if([[dict objectForKey:@"action"]isEqualToString:@"add_qq_group"]){ NSString* qqgroup = [[dict objectForKey:@"data"]objectForKey:@"groupId"]; NSString* qqkey = [[dict objectForKey:@"data"]objectForKey:@"iosKey"]; NSString *urlStr = [NSString stringWithFormat:@"mqqapi://card/show_pslcard?src_type=internal&version=1&uin=%@&key=%@&card_type=group&source=external", qqgroup,qqkey]; NSURL *url = [NSURL URLWithString:urlStr]; if([[UIApplication sharedApplication] canOpenURL:url]){ [[UIApplication sharedApplication] openURL:url]; }else{ [ZCHUDHelper showTitle:[NSString stringWithFormat:@"你可以加入我们官方QQ群:%@",qqgroup]showtime:3.0]; } } } } }else if ([object.attachment isKindOfClass:[YOUPAILPFollowAttachment class]]){ YOUPAILPFollowAttachment *attachment = (YOUPAILPFollowAttachment *)object.attachment; //v1.0.7 type为18跳到聊天页面 if(attachment.type==16||attachment.type==17) { // LCUserShowVC* userShow = [[LCUserShowVC alloc]init]; // YOUPAILZUserShowVC* userShow = [[YOUPAILZUserShowVC alloc]init]; // userShow.youpaipuserId = [NSString stringWithFormat:@"%zd",attachment.userid]; // [self.navigationController pushViewController:userShow animated:YES]; YMPersonalPageViewModel *personalPageVM = [[YMPersonalPageViewModel alloc]initWithParams:@{ ParamsId:@(attachment.userid) }]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_PERSONAL_PAGE) withUserInfo:@{ RouterViewModel:personalPageVM } completion:nil]; } else { NSString* userId = [NSString stringWithFormat:@"%zd",attachment.userid]; if (userId) { [self goChatPageWithUserId:userId]; } } } else if (message.messageType == NIMMessageTypeCustom) { // 视频通话 [self onVideoClick]; } } - (void)goChatPageWithUserId:(NSString *)userId{ @weakify(self); // [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{ 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]; [self.navigationController pushViewController:vc animated:YES]; }]; } // } // } // } failure:^(NSError *error) { // }]; } #pragma mark - NIMInputActionDelegate 礼物 视频 语音 照片 啥的 注释by leo - (void)onCameraClick{ [self.interactor mediaShootPressed]; } - (void)onSayHiClick{ YOUPAILZIMCommonWordsVC *vc = [[YOUPAILZIMCommonWordsVC alloc] init]; vc.youpaipto_uid = self.session.sessionId; vc.youpaipdataSource = self.youpaipcommonWords; @weakify(self); [vc setYoupaipreloadDataSourceBlock:^(NSArray * _Nonnull youpaipdataSource) { @strongify(self); self.youpaipcommonWords = youpaipdataSource; [self.youpaipcommonWordCollectionView reloadData]; }]; [self.navigationController pushViewController:vc animated:YES]; } - (void)youpaiploadCommonWordsData{ if (self.sessionInputView == nil) { return; } @weakify(self); [LCHttpHelper requestWithURLString:GetCommonWord parameters:@{} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { @strongify(self); NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 [self youpaifinitCommonWordCollectionView]; self.youpaipcommonWords = [YOUPAILZIMCommonWordModel mj_objectArrayWithKeyValuesArray:[dict objectForKey:@"data"]]; [self.youpaipcommonWordCollectionView reloadData]; } } failure:^(NSError *error) { }]; } - (void)youpaifinitCommonWordCollectionView{ UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; layout.minimumLineSpacing = 0.0f; layout.minimumInteritemSpacing = 8.0f; layout.sectionInset = UIEdgeInsetsMake(0.0f, 16.0f, 0.0f, 16.0f); UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; collectionView.backgroundColor = [UIColor clearColor]; collectionView.dataSource = self; collectionView.delegate = self; collectionView.showsVerticalScrollIndicator = NO; collectionView.showsHorizontalScrollIndicator = NO; [collectionView registerClass:[YOUPAILZSessionCommonWordCell class] forCellWithReuseIdentifier:NSStringFromClass(YOUPAILZSessionCommonWordCell.class)]; [self.view addSubview:collectionView]; self.youpaipcommonWordCollectionView = collectionView; [collectionView mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.sessionInputView.mas_top).offset(0.0f); make.left.right.offset(0.0f); make.height.offset(44.0f); }]; self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 44.0f)]; } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ CGFloat width = [self.youpaipcommonWords[indexPath.item].youpaipword widthWithFont:LCFont(12.0f) constrainedToHeight:44.0f] + 16.0f; return CGSizeMake(width, 28.0f); } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ return self.youpaipcommonWords.count; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ YOUPAILZSessionCommonWordCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass(YOUPAILZSessionCommonWordCell.class) forIndexPath:indexPath]; [cell youpaifreloadWithModel:self.youpaipcommonWords[indexPath.item]]; return cell; } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ NIMSession *session = [NIMSession session:self.session.sessionId type:NIMSessionTypeP2P]; NIMMessage *imMessage = [NIMMessageMaker msgWithText:self.youpaipcommonWords[indexPath.item].youpaipword]; @weakify(self); [YOUPAILCIMTool sendMessage:imMessage sessionid:session.sessionId completion:^(NIMMessage *resultMsg,NSInteger filter,NSString *contentStr) { @strongify(self); if (filter==0) { [[[NIMSDK sharedSDK] chatManager] sendMessage:resultMsg toSession:session error:nil]; }else{ resultMsg.text = contentStr; [[[NIMSDK sharedSDK] chatManager] sendMessage:resultMsg toSession:session error:nil]; } }]; } - (void)onPhotoClick{ [self.interactor mediaPicturePressed]; } #pragma mark SVGAPlayerDelegate //- (void)svgaPlayerDidAnimatedToPercentage:(CGFloat)percentage //{ // NSLog(@"percentage == %lf",percentage); // if (percentage == 1) { //// [self.player stopAnimation]; //// self.player.hidden = YES; // } //} - (void)svgaPlayerDidFinishedAnimation:(SVGAPlayer *)player { self.svgaPlayer.hidden = YES; } - (void)onGiftClick{ [self.sessionInputView endEditing:YES]; YOUPAILZCommonGiftView *view = [YOUPAILZCommonGiftView new]; view.isTouchDismiss = YES; view.youpaipisAnchor = NO; @weakify(self); [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]; // // // }); YMAccountBalanceViewModel *accountBalanceVM = [[YMAccountBalanceViewModel alloc]initWithParams:@{ ParamsId:@([[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id intValue]) }]; YMAccountBalanceRechargePopupView *customView = [[YMAccountBalanceRechargePopupView alloc]init]; [customView ym_bindViewModel:accountBalanceVM]; YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom]; popupView.priority = 999; popupView.cornerRadius = adapt(10); popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight; popupView.positionStyle = YMPositionStyleBottom; popupView.isClickBgDismiss = YES; popupView.isHideBg = NO; popupView.bgAlpha = 0.5; [popupView pop]; @weakify(popupView) customView.dismissBlock = ^{ @strongify(popupView) [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0]; }; }]; [view setYoupaiplzgiftblock:^(YOUPAILCGiftModel * _Nonnull giftModel, NSInteger count,NSString*categoryID) { @strongify(self); [LCHttpHelper requestWithURLString:SendGift_New parameters:@{@"type":@(2),@"to_uid":self.session.sessionId,@"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) {//成功 NSInteger coin = [[[dict objectForKey:@"data"]objectForKey:@"coin"]integerValue]; // [ZCHUDHelper showTitle:@"礼物赠送成功"]; [UMengRecordTool umengEventCountWithId:GiveawayGiftMessage]; [self.svgaPlayer stopAnimation]; if (giftModel.youpaiptype == 1 && ![giftModel.youpaipsvga isEqualToString:@""]) { self.svgaPlayer.hidden = NO; } NSString* svgaName = [[giftModel.youpaipsvga componentsSeparatedByString:@"/"] lastObject]; NSLog(@"%@",giftModel.youpaipsvga); NSString* svgaCanchesPath= [[NSString alloc]initWithFormat:@"%@/%@/%@",CachesPath,@"SVGA",svgaName]; NSLog(@"%@",svgaCanchesPath); if (![LCTools giftSVGAWithSvgaUrlStr:giftModel.youpaipsvga]){ NSString* urlStr = [NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,giftModel.youpaipsvga]; @weakify(self); [self.parser parseWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) { @strongify(self); if (videoItem != nil) { self.svgaPlayer.videoItem = videoItem; [self.svgaPlayer startAnimation]; } } failureBlock:^(NSError * _Nullable error) { @strongify(self); self.svgaPlayer.hidden = YES; }]; [LCTools giftSVGAWithSvgaUrlStr:giftModel.youpaipsvga]; }else{ @weakify(self); [self.parser parseWithData:[LCTools giftSVGAWithSvgaUrlStr:giftModel.youpaipsvga] cacheKey:svgaCanchesPath completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) { @strongify(self); if (videoItem != nil) { self.svgaPlayer.videoItem = videoItem; [self.svgaPlayer startAnimation]; } } failureBlock:^(NSError * _Nonnull error) { @strongify(self); self.svgaPlayer.hidden = YES; }]; } } } failure:^(NSError *error) { }]; }]; [self TFPresentVC:view completion:^{ }]; } - (void)onVideoClick{ if ([self.session.sessionId isEqualToString:[LCSaveData getServerId]]) { [ZCHUDHelper showTitle:@"暂时不能和客服视频通话"]; return ; } if ([YOUPAILZChatRoomManager shareManager].chatroomWindow != nil && [YOUPAILZChatRoomManager shareManager].chatroomWindow.hidden == NO) { [ZCHUDHelper showTitle:@"你正在房间中,暂不可拨打视频"]; return; } [UMengRecordTool umengEventCountWithId:StartVideoMessage]; //v1.1.2 增加相机权限判断 [UCAuthorityManager cameraAuthority:^{ dispatch_async(dispatch_get_main_queue(), ^{ [self.sessionInputView endEditing:YES]; }); [ZCHUDHelper show]; if ([LCSaveData getWhiteVersion]) {//1 [LCHttpHelper requestWithURLString:UserShowPage parameters:@{@"user_id":self.session.sessionId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 NSDictionary *data = [dict objectForKey:@"data"]; YOUPAILCUserShowInfo *info = [YOUPAILCUserShowInfo mj_objectWithKeyValues:[data objectForKey:@"info"]]; YOUPAIBBVideoRequestVC* chatRequest = [[YOUPAIBBVideoRequestVC alloc]init]; YOUPAILCVideoChatModel *videoModel = [[YOUPAILCVideoChatModel alloc] init]; videoModel.youpaiproom_id = [NSString stringWithFormat:@"C%@",[LCTools randomNumberWithLength:6]]; videoModel.youpaipauditState = 1; videoModel.youpaipfrom_uid = [LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id; videoModel.youpaipfrom_nickname = [LCSaveModel getUserModel].youpaipuserinfo.youpaipnickname; videoModel.youpaipfrom_avatar = [LCSaveModel getUserModel].youpaipuserinfo.youpaipavatar; videoModel.youpaipto_uid = self.session.sessionId; videoModel.youpaipto_nickname = info.youpaipnickname; videoModel.youpaipto_avatar = info.youpaipavatar; chatRequest.youpaipvideoModel = videoModel; ZCBaseNavigationVC *nav = [[ZCBaseNavigationVC alloc]initWithRootViewController:chatRequest]; //modify by leo fix bug ios13 nav.modalPresentationStyle =0; [self.navigationController presentViewController:nav animated:YES completion:^{ [ZCHUDHelper dismiss]; }]; } } failure:^(NSError *error) { [ZCHUDHelper dismiss]; }]; }else{//0 // @"type":@"0" 代表视频通话, 1语音通话 [LCHttpHelper requestWithURLString:CallChatType parameters:@{@"to_uid":self.session.sessionId,@"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); [ZCHUDHelper dismiss]; }]; }); } } failure:^(NSError *error) { [ZCHUDHelper dismiss]; }]; } } denied:^{ 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]; dispatch_async(dispatch_get_main_queue(), ^{ [self presentViewController: systemAlert animated: YES completion: nil]; }); }]; } - (void)pushEffectPresentToVC:(UIViewController*)vc{ CATransition *transition = [CATransition animation]; transition.duration = 0.25; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]; transition.type = kCATransitionPush; transition.subtype = kCATransitionFromTop; [self.navigationController.view.layer addAnimation:transition forKey:nil]; [self.navigationController pushViewController:vc animated:NO ]; } //接收消息 - (void)onRecvMessages:(NSArray *)messages { [super onRecvMessages:messages]; NSLog(@"IM 收到消息了 🌵🥺🥺🥺🥺"); NIMMessage *message = messages.firstObject; NIMSession *session = message.session; if (![session isEqual:self.session] || !messages.count) { // if ([LCSaveData getIsVideo]) { // YOUPAILCBaseVideoCallVC *videoVC = (YOUPAILCBaseVideoCallVC *)[ZCUtils getCurrentVC]; // if([videoVC isKindOfClass:[YOUPAILCBaseVideoCallVC class]]){ // NIMCustomObject *object = (NIMCustomObject*)message.messageObject; // if ([object.attachment isKindOfClass:[YOUPAILCGiftAttachment class]]) // { // YOUPAILCGiftAttachment* attachment = (YOUPAILCGiftAttachment*)object.attachment; // // YOUPAILZLiveGIftModel *giftModel = [[YOUPAILZLiveGIftModel alloc] init]; // giftModel.youpaipavatar = attachment.from_avatar; //赠送者头像 // giftModel.youpaipnickName = attachment.from_nickname; //赠送者昵称 // giftModel.youpaipgiftImage = attachment.gift_url; //礼物图片地址 // giftModel.youpaipgiftCount = attachment.gift_count; //礼物个数 // giftModel.youpaipuser_id = attachment.from_uid; // 发送者ID // giftModel.youpaipgift_id = attachment.gift_id; // //礼物id // giftModel.youpaipgift_svga = attachment.gift_svga; // //svga地址 // giftModel.youpaipgift_type = attachment.gift_type; //礼物类型 0普通 1 svga动画礼物 // giftModel.youpaipto_uid = attachment.to_uid; // 接收者ID // [videoVC giftMsgForIm:giftModel]; // } // } //// [ZCHUDHelper showTitle:@"正在视频中"] // // }else{ // // } return; } if (message.messageType == NIMMessageTypeCustom){ NIMCustomObject *object = (NIMCustomObject*)message.messageObject; if ([object.attachment isKindOfClass:[YOUPAILCGiftAttachment class]]) { YOUPAILCGiftAttachment* attachment = (YOUPAILCGiftAttachment*)object.attachment; // [ZCHUDHelper showTitle:@"收到一个礼物"]; NSLog(@"%@",attachment.gift_url); NSLog(@"%@",attachment.gift_svga); [self.svgaPlayer stopAnimation]; if (attachment.gift_type == 1 && ![attachment.gift_svga isEqualToString:@""]) { self.svgaPlayer.hidden = NO; } NSString* svgaName = [[attachment.gift_svga componentsSeparatedByString:@"/"] lastObject]; NSString* svgaCanchesPath= [[NSString alloc]initWithFormat:@"%@/%@/%@",CachesPath,@"SVGA",svgaName]; NSLog(@"%@",svgaCanchesPath); if (![LCTools giftSVGAWithSvgaUrlStr:attachment.gift_svga]){ NSString* urlStr = [NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,attachment.gift_svga]; @weakify(self); [self.parser parseWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) { @strongify(self); if (videoItem != nil) { self.svgaPlayer.videoItem = videoItem; [self.svgaPlayer startAnimation]; } } failureBlock:^(NSError * _Nullable error) { @strongify(self); self.svgaPlayer.hidden = YES; }]; [LCTools giftSVGAWithSvgaUrlStr:attachment.gift_svga]; }else{ @weakify(self); [self.parser parseWithData:[LCTools giftSVGAWithSvgaUrlStr:attachment.gift_svga] cacheKey:svgaCanchesPath completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) { @strongify(self); if (videoItem != nil) { self.svgaPlayer.videoItem = videoItem; [self.svgaPlayer startAnimation]; } } failureBlock:^(NSError * _Nonnull error) { @strongify(self); self.svgaPlayer.hidden = YES; }]; } } } } @end