feat: 基本完成礼物支持嵌入元素功能

This commit is contained in:
P
2024-11-22 13:47:34 +08:00
parent 9fe30ce255
commit 786f15cae7
9 changed files with 352 additions and 186 deletions

View File

@@ -158,6 +158,8 @@ typedef NS_ENUM(NSUInteger, CustomMessageSubGift) {
Custom_Message_Sub_Gift_ChannelNotify = 32,
///发送 福袋 礼物
Custom_Message_Sub_Gift_LuckySend = 34,
///发送 嵌入式礼物
Custom_Message_Sub_Gift_EmbeddedStyle = 35,
};
///first = CustomMessageType_Account

View File

@@ -263,7 +263,7 @@
layout.itemSize = CGSizeMake(kGetScaleWidth(88), kGetScaleWidth(88)); // item
layout.minimumLineSpacing = 20; //
if (iPhoneXSeries) {
layout.minimumInteritemSpacing = 11.5; //
layout.minimumInteritemSpacing = 10; //
} else {
layout.minimumInteritemSpacing = 4;
}

View File

@@ -35,7 +35,6 @@
#import "AttachmentModel.h"
#import "XPGiftBigPrizeModel.h"
#import "XPGiftBannerUserInfoModel.h"
#import "GiftReceiveInfoModel.h"
#import "XPMessageRemoteExtModel.h"
#import "DatingInfoModel.h"
#import "AcrossRoomPKPrizeModel.h"
@@ -91,8 +90,7 @@ XPRoomStarKitchenBannerViewDelegate,
PAGViewListener,
XPRoomAnchorRankBannerViewDelegate,
PIRoomGiftBroadcastWindowDelegate,
PIUniversalBannerViewDelegate,
HWDMP4PlayDelegate>
PIUniversalBannerViewDelegate>
///
///
@property (nonatomic,strong) XPRoomAnimationHitView * lowLevelView;
@@ -187,6 +185,11 @@ HWDMP4PlayDelegate>
///CP
@property (nonatomic, strong) AttachmentModel *cpAttachment;
@property(nonatomic, strong) GiftReceiveInfoModel *mp4TempReceiveInfoModel;
@property(nonatomic, strong) NetImageView *mp4AvatarLoader_1;
@property(nonatomic, strong) NetImageView *mp4AvatarLoader_2;
@property(nonatomic, strong) NSMutableArray *embeddedTargetDatas;
@end
@implementation XPRoomAnimationView
@@ -303,9 +306,58 @@ HWDMP4PlayDelegate>
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_Gift) {
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
if (attachment.second == Custom_Message_Sub_Gift_EmbeddedStyle) {
receiveInfo.targetUid = [[attachment.data objectForKey:@"recvUserUid"] stringValue];
receiveInfo.targetNick = [attachment.data objectForKey:@"recvUserNick"];
receiveInfo.targetAvatar = [attachment.data objectForKey:@"recvUserAvatar"];
receiveInfo.avatar = [attachment.data objectForKey:@"sendUserAvatar"];
receiveInfo.nick = [attachment.data objectForKey:@"sendUserNick"];
receiveInfo.uid = [[attachment.data objectForKey:@"sendUserUid"] stringValue];
} else if (attachment.second == Custom_Message_Sub_Gift_Send) {
receiveInfo.targetUsers = @[];
NSLog(@"******************* %@", receiveInfo.targetAvatar);
}
if (!_embeddedTargetDatas) {
_embeddedTargetDatas = @[].mutableCopy;
}
receiveInfo.isLuckyBagGift = attachment.second == Custom_Message_Sub_Gift_LuckySend;
receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
receiveInfo.isComboBatch = attachment.second == Custom_Message_Sub_AllMicroSend;
[self receiveGiftHandleSendGiftAnimation:attachment];
if (receiveInfo.isLuckyBagGift) {
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
if (receiveInfo.viewUrl.length > 0) {
[self playLuckyGiftEffectWithVapUrl:receiveInfo.viewUrl];
} else {
NSString * svgaString = receiveInfo.luckyGiftSvgaUrl.length > 0 ? receiveInfo.luckyGiftSvgaUrl : receiveInfo.gift.luckyGiftSvgaUrl;
NSURL * luckyGiftSvgaUrl = [NSURL URLWithString:svgaString];
if (luckyGiftSvgaUrl.absoluteString.length > 0) {
[self playLuckyGiftEffect:luckyGiftSvgaUrl];
}
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (receiveInfo.gift.notifyFull) {
return;
}
[self receiveGift:receiveInfo];
});
} else {
if (receiveInfo.gift.notifyFull) {
return;
}
[self.embeddedTargetDatas insertObject:receiveInfo atIndex:0];
[self receiveGift:receiveInfo];
}
} else if (attachment.first == CustomMessageType_AllMicroSend) { //
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
receiveInfo.isComboBatch = attachment.second == Custom_Message_Sub_AllMicroSend;
receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
[self receiveGiftHandleSendGiftAnimation:attachment];
if (receiveInfo.isLuckyBagGift) {
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
@@ -319,32 +371,15 @@ HWDMP4PlayDelegate>
}
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self receiveGift:receiveInfo];
});
} else {
[self receiveGift:receiveInfo];
}
} else if (attachment.first == CustomMessageType_AllMicroSend) { //
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
receiveInfo.isComboBatch = attachment.second == Custom_Message_Sub_AllMicroSend;
receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
[self receiveGiftHandleSendGiftAnimation:attachment];
if (receiveInfo.isLuckyBagGift) {
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
if (receiveInfo.viewUrl.length > 0) {
[self playLuckyGiftEffectWithVapUrl:receiveInfo.viewUrl];
} else {
NSString * svgaString = receiveInfo.luckyGiftSvgaUrl.length > 0 ? receiveInfo.luckyGiftSvgaUrl : receiveInfo.gift.luckyGiftSvgaUrl;
NSURL * luckyGiftSvgaUrl = [NSURL URLWithString:svgaString];
if (luckyGiftSvgaUrl.absoluteString.length > 0) {
[self playLuckyGiftEffect:luckyGiftSvgaUrl];
if (receiveInfo.gift.notifyFull) {
return;
}
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self receiveGift:receiveInfo];
});
} else {
if (receiveInfo.gift.notifyFull) {
return;
}
[self receiveGift:receiveInfo];
}
} else if (attachment.first == CustomMessageType_LuckyBag ) {//
@@ -1606,6 +1641,14 @@ HWDMP4PlayDelegate>
if ([self isInSudGame]) {return;}
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
if (attachment.second == Custom_Message_Sub_Gift_EmbeddedStyle) {
receiveInfo.targetUid = [[attachment.data objectForKey:@"recvUserUid"] stringValue];
receiveInfo.targetNick = [attachment.data objectForKey:@"recvUserNick"];
receiveInfo.targetAvatar = [attachment.data objectForKey:@"recvUserAvatar"];
receiveInfo.avatar = [attachment.data objectForKey:@"sendUserAvatar"];
receiveInfo.nick = [attachment.data objectForKey:@"sendUserNick"];
receiveInfo.uid = [[attachment.data objectForKey:@"sendUserUid"] stringValue];
}
GiftInfoModel * giftInfo = receiveInfo.gift ? receiveInfo.gift : receiveInfo.giftInfo;
if (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend || attachment.second == Custom_Message_Sub_Gift_LuckySend) {
NSString * giftId = [NSString stringWithFormat:@"%ld", receiveInfo.luckyGiftList.giftList.firstObject.giftId];
@@ -1657,7 +1700,9 @@ HWDMP4PlayDelegate>
} else {
targetUids = receiveInfo.targetUids;
if (targetUids.count <= 0) {
targetUids = [receiveInfo.targetUsers valueForKeyPath:@"uid"];
if (receiveInfo.targetUsers) {
targetUids = [receiveInfo.targetUsers valueForKeyPath:@"uid"];
}
if (targetUids.count <=0) {
targetUids = @[receiveInfo.targetUid];
}
@@ -2212,15 +2257,6 @@ HWDMP4PlayDelegate>
[self.svgaQueue addObject:receiveInfo];
}
}
// if (self.animationListA.count > 0 && self.isPlayOfB == NO && self.isPlayOfA == NO) {
// [self createGiftBannerViewAnimation:self.animationListA.firstObject];
// }
// if(self.svgaQueue.count > 0 && self.isLargeGiftAnimating == NO){
// [self createGiftSvgaAnimation:self.svgaQueue.firstObject];
//
// }
if (self.giftEffectTimer == nil && self.svgaQueue.count > 0) {
[self startHandleGiftEffectTimer];
}
@@ -2234,14 +2270,17 @@ HWDMP4PlayDelegate>
@kWeakify(self);
dispatch_source_set_event_handler(_timer, ^{
@kStrongify(self)
NSLog(@"******************* 当前队列个数: %@", @(self.svgaQueue.count));
if (self.svgaQueue.count > 0) {
dispatch_sync(dispatch_get_main_queue(), ^{
if(self.isLargeGiftAnimating == NO){
GiftReceiveInfoModel * receiveModel = [self.svgaQueue firstObject];
[self createGiftSvgaAnimation:receiveModel];
[self.svgaQueue removeObject:receiveModel];
GiftReceiveInfoModel * receiveModel = [self.svgaQueue xpSafeObjectAtIndex:0];
if (receiveModel) {
[self createGiftSvgaAnimation:receiveModel];
[self.svgaQueue removeObjectAtIndex:0];
NSLog(@"******************* 执行播放 %@, self.svgaQueue num: %@", receiveModel.targetAvatar, @(self.svgaQueue.count));
}
}
});
}else {
dispatch_source_cancel(_timer);
@@ -2252,7 +2291,6 @@ HWDMP4PlayDelegate>
self.giftEffectTimer = _timer;
}
-(void)createGiftSvgaAnimation:(GiftReceiveInfoModel *)receiveInfo{
GiftInfoModel *giftInfo = receiveInfo.gift != nil ? receiveInfo.gift : receiveInfo.giftInfo;
if (!giftInfo) {
giftInfo = [[XPGiftStorage shareStorage] findGiftInfo: receiveInfo.giftId];
@@ -2263,6 +2301,7 @@ HWDMP4PlayDelegate>
[self playGiftEffectWithPagUrl:giftInfo.viewUrl];
}else{
[self largeGiftStopCarEffect:giftInfo.goldPrice];
self.mp4TempReceiveInfoModel = receiveInfo;
[self playGiftEffectWithVapUrl:giftInfo.viewUrl];
}
}
@@ -2432,26 +2471,27 @@ HWDMP4PlayDelegate>
}
[self.vapGiftEffectView setMute:NO];
[self.vapGiftEffectView playHWDMP4:vapUrl repeatCount:1 delegate:self];
return;
}
[self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) {
if (videoUrl.length) {
self.vapGiftEffectView.hidden = NO;
if (self.vapGiftEffectView.superview == nil) {
[self.middleLevelView addSubview:self.vapGiftEffectView];
[self.vapGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
}else {
@kWeakify(self);
[self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) {
@kStrongify(self);
if (videoUrl.length) {
self.vapGiftEffectView.hidden = NO;
if (self.vapGiftEffectView.superview == nil) {
[self.middleLevelView addSubview:self.vapGiftEffectView];
[self.vapGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
}
[self.vapGiftEffectView setMute:NO];
[self.vapGiftEffectView playHWDMP4:videoUrl repeatCount:1 delegate:self];
}
[self.vapGiftEffectView setMute:NO];
[self.vapGiftEffectView playHWDMP4:videoUrl repeatCount:1 delegate:self];
}
} failureBlock:^(NSError * _Nullable error) {
self.vapGiftEffectView.hidden = YES;
}];
} failureBlock:^(NSError * _Nullable error) {
self.vapGiftEffectView.hidden = YES;
}];
}
}
/// SVGA
@@ -2540,6 +2580,7 @@ HWDMP4PlayDelegate>
encodingUrl = [encodingUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSString *fileName = [[encodingUrl componentsSeparatedByString:@"/"] lastObject];
NSString *fullPath = [self.GiftDynamicEffectListPath stringByAppendingPathComponent:fileName];
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
vapUrl = fullPath;
self.luckyVapGiftEffectView.hidden = NO;
@@ -2553,29 +2594,29 @@ HWDMP4PlayDelegate>
}
[self.luckyVapGiftEffectView setMute:NO];
[self.luckyVapGiftEffectView playHWDMP4:vapUrl repeatCount:1 delegate:self];
return;
}
[self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) {
if (videoUrl.length) {
self.luckyVapGiftEffectView.hidden = NO;
if (self.luckyVapGiftEffectView.superview == nil) {
[self.middleLevelView addSubview:self.luckyVapGiftEffectView];
[self.luckyVapGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
} else {
@kWeakify(self);
[self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) {
@kStrongify(self);
if (videoUrl.length) {
self.luckyVapGiftEffectView.hidden = NO;
if (self.luckyVapGiftEffectView.superview == nil) {
[self.middleLevelView addSubview:self.luckyVapGiftEffectView];
[self.luckyVapGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
}
[self.luckyVapGiftEffectView setMute:NO];
[self.luckyVapGiftEffectView playHWDMP4:videoUrl repeatCount:1 delegate:self];
}
[self.luckyVapGiftEffectView setMute:NO];
[self.luckyVapGiftEffectView playHWDMP4:videoUrl repeatCount:1 delegate:self];
}
} failureBlock:^(NSError * _Nullable error) {
self.luckyVapGiftEffectView.hidden = YES;
}];
} failureBlock:^(NSError * _Nullable error) {
self.luckyVapGiftEffectView.hidden = YES;
}];
}
}
#pragma mark -
- (void)svgaPlayerDidFinishedAnimation:(SVGAPlayer *)player {
if (player == self.giftEffectView) {
@@ -2680,7 +2721,6 @@ HWDMP4PlayDelegate>
}];
}
[self.wishGiftEffectView mas_updateConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(x);
make.top.mas_equalTo(y);
@@ -2726,6 +2766,7 @@ HWDMP4PlayDelegate>
} else if (container == self.vapGiftEffectView) {
[self.vapGiftEffectView removeFromSuperview];
self.vapGiftEffectView = nil;
self.mp4TempReceiveInfoModel = nil;
if (self.isLargeGiftAnimating == YES) {
self.isLargeGiftAnimating = NO;
}
@@ -2751,10 +2792,10 @@ HWDMP4PlayDelegate>
} else if (container == self.vapGiftEffectView) {
[self.vapGiftEffectView removeFromSuperview];
self.vapGiftEffectView = nil;
self.mp4TempReceiveInfoModel = nil;
if (self.isLargeGiftAnimating == YES) {
self.isLargeGiftAnimating = NO;
}
} else if(container == self.luckyVapGiftEffectView) {
[self.luckyVapGiftEffectView removeFromSuperview];
self.luckyVapGiftEffectView = nil;
@@ -2768,7 +2809,76 @@ HWDMP4PlayDelegate>
if (self.isLargeGiftAnimating == YES) {
self.isLargeGiftAnimating = NO;
}
self.mp4TempReceiveInfoModel = nil;
}
- (void)loadVapImageWithURL:(NSString *)urlStr context:(NSDictionary *)context completion:(VAPImageCompletionBlock)completionBlock {
if (self.mp4TempReceiveInfoModel) {
dispatch_async(dispatch_get_main_queue(), ^{
QGVAPSourceInfo *info = (QGVAPSourceInfo *)context[@"resource"];
if ([info.contentTag isEqualToString:@"avatar1"]) {
if ([NSString isEmpty:self.mp4TempReceiveInfoModel.avatar]) {
completionBlock(kImage(@"common_avatar"), nil, @"dafeult image");
} else {
NSString *path = @"";
switch (self.mp4TempReceiveInfoModel.gift.showAvatarType) {
case 1: // 使 avatar
case 3:
path = self.mp4TempReceiveInfoModel.avatar;
break;
case 2: // 使 target avatar
path = self.mp4TempReceiveInfoModel.targetAvatar;
break;
default:
completionBlock(kImage(@"common_avatar"), nil, @"dafeult image");
return;
break;
}
self.mp4AvatarLoader_1 = [[NetImageView alloc] init];
[self.mp4AvatarLoader_1 loadImageWithUrl:path completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
completionBlock(image, nil, urlStr);
}];
}
}
else if ([info.contentTag isEqualToString:@"avatar2"] ) {
GiftReceiveInfoModel *infoModel = self.mp4TempReceiveInfoModel;// [self.embeddedTargetDatas lastObject];
if (!infoModel || [NSString isEmpty:infoModel.targetAvatar]) {
completionBlock(kImage(@"common_avatar"), nil, @"dafeult image");
} else {
self.mp4AvatarLoader_2 = [[NetImageView alloc] init];
[self.mp4AvatarLoader_2 loadImageWithUrl:infoModel.targetAvatar completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
completionBlock(image, nil, urlStr);
}];
}
} else {
completionBlock(nil, nil, @"completionBlock");
}
});
}
}
- (NSString *)contentForVapTag:(NSString *)tag resource:(QGVAPSourceInfo *)info {
NSString *name1 = @"";
switch (self.mp4TempReceiveInfoModel.gift.showAvatarType) {
case 1: // 使 avatar
case 3:
name1 = self.mp4TempReceiveInfoModel.nick;
break;
case 2: // 使 target avatar
name1 = self.mp4TempReceiveInfoModel.targetNick;
break;
default:
break;
}
NSDictionary *extraInfo = @{@"name1" : [NSString isEmpty:name1] ? @"" : name1,
@"name2" : [NSString isEmpty:self.mp4TempReceiveInfoModel.targetNick] ? @"" : self.mp4TempReceiveInfoModel.targetNick,
// @"id1" : [NSString isEmpty:self.mp4TempReceiveInfoModel.uid] ? @"" : self.mp4TempReceiveInfoModel.uid ,
// @"id2" : [NSString isEmpty:infoModel.targetUid] ? @"" : infoModel.targetUid
};
return [NSString isEmpty:extraInfo[tag]] ? @" " : extraInfo[tag];
}
#pragma mark - PAGViewListener
/**
* Notifies the beginning of the animation. It can be called from either the UI thread or the thread

View File

@@ -32,6 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface GiftComboManager : NSObject
@property (nonatomic, strong) GiftReceiveInfoModel *sendGiftReceiveInfo;
@property(nonatomic, copy) void(^handleComboSuccess)(GiftReceiveInfoModel *receiveModel, NSMutableDictionary *originDic);
// 单例方法
+ (instancetype)sharedManager;

View File

@@ -483,9 +483,20 @@
- (void)handleSendGiftSuccess:(GiftReceiveInfoModel *)receive
sourceData:(BaseModel *)response {
// self.combo += 1;
if (self.actionCallback) {
self.actionCallback(ComboAction_Combo_Count_Update);
}
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:response.data];
[dic setObject:@(self.combo) forKey:@"comboCount"];
if (self.handleComboSuccess) {
self.handleComboSuccess(receive, dic);
}
return;
self.sendGiftReceiveInfo = receive;
if (self.actionCallback) {
@@ -533,8 +544,6 @@
[attachment.data setObject:@(self.combo) forKey:@"comboCount"];
[self sendCustomMessage:attachment];
}
self.combo += 1;
}
- (void)sendCustomMessage:(AttachmentModel *)attachment {

View File

@@ -131,6 +131,9 @@ typedef NS_ENUM(NSUInteger, RoomSendGiftType) {
@property (nonatomic, strong) i18nGiftNameMap *i18nGiftNameMap;
@property(nonatomic, assign) NSInteger showAvatarType; // 是否需要塞头像0-否1-送礼者2-收礼者3-左送右收
@property(nonatomic, assign) BOOL notifyFull; // 该礼物动画是否全房间播放
@end
@interface GiftPanelTabModel : PIBaseModel
@@ -144,6 +147,8 @@ typedef NS_ENUM(NSUInteger, RoomSendGiftType) {
@property (nonatomic, copy) NSArray <GiftInfoModel *> *gifts;
- (GiftType)tabGiftType;
@end

View File

@@ -56,12 +56,12 @@ NS_ASSUME_NONNULL_BEGIN
///目标的昵称
@property (nonatomic,copy) NSString *targetNick;
@property (nonatomic,strong) NSArray<NSNumber *> *targetUids;
///礼物信息
///礼物信息 - 来自礼物 API
@property (nonatomic,strong) GiftInfoModel *gift;
///礼物信息
@property (nonatomic,strong) GiftInfoModel *giftInfo;
///送礼物的人uid
@property(nonatomic, assign)NSString * uid;
@property(nonatomic, assign)NSString *uid;
///礼物的id
@property (nonatomic,copy) NSString *giftId;
///送礼物的人
@@ -135,7 +135,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) NSInteger receiveGiftNumberUser;
@property (nonatomic, assign) NSInteger bgLevel; /// 1,2,3 对应非 VIP 背景456 对应 VIP 背景
@property (nonatomic, assign) NSInteger bgLevel; // 1,2,3 对应非 VIP 背景456 对应 VIP 背景
- (NSInteger)receiveUserCount;

View File

@@ -283,119 +283,149 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
}
}
- (void)sendCustomMessage:(GiftReceiveInfoModel *)receiveModel oringinDic:(NSDictionary *)originDic {
- (void)sendCustomMessage:(GiftReceiveInfoModel *)receiveModel
oringinDic:(NSDictionary *)originDic {
NSDictionary * dict = originDic;
NSMutableDictionary *data = [NSMutableDictionary dictionary];
[data addEntriesFromDictionary:dict];
if (receiveModel.roomSendGiftType == RoomSendGiftType_AllMic) { //
NSMutableDictionary *data = [NSMutableDictionary dictionary];
[data addEntriesFromDictionary:dict];
if (receiveModel.gift.giftType == GiftType_Lucky) { //
NSArray *luckyBagGifts = (NSArray *)[data objectForKey:@"luckyBagGifts"];
if (luckyBagGifts.count >0) {
for (int i = 0; i < luckyBagGifts.count; i++) {
NSMutableDictionary * data1 = [NSMutableDictionary dictionary];
[data1 addEntriesFromDictionary:dict];
AttachmentModel * attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_AllMicroSend;
attachment.second = Custom_Message_Sub_AllMicroLuckySend;
NSDictionary * obj = [luckyBagGifts xpSafeObjectAtIndex:i];
[data1 setObject:i == 0 ? @(YES):@(NO) forKey:@"isShowAnimation"];
[data1 setObject:obj forKey:@"luckyGiftList"];
[data1 setObject:receiveModel.gift.giftName forKey:@"giftName"];
[data1 setObject:[obj valueForKeyPath:@"user.uid"] forKey:@"targetUid"];
[data1 setObject:[dict valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"];
if ([dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"]) {
[data1 setObject:[dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"] forKey:@"luckyGiftSvgaUrl"];
}
[data1 removeObjectForKey:@"luckyBagGifts"];
[data1 removeObjectForKey:@"targetUsers"];
[data1 removeObjectForKey:@"gift"];
attachment.data = data1;
[self sendCustomMessage:attachment];
}
}
[self sendLuckyBagGifts:receiveModel
data:data
firstType:CustomMessageType_AllMicroSend
secondType:Custom_Message_Sub_AllMicroLuckySend
isToOne:NO];
}else { //
AttachmentModel * attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_AllMicroSend;
attachment.second = Custom_Message_Sub_AllMicroSend;
[data setObject:[dict valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"];
attachment.data = data;
[self sendCustomMessage:attachment];
if (receiveModel.gift.showAvatarType > 0) {
[self handleEmbeddedValueGiftsMessage:receiveModel
oringinDic:data
isToOne:NO];
} else {
[self sendGiftToAllMessage:data];
}
}
} else if (receiveModel.roomSendGiftType == RoomSendGiftType_MutableOnMic) { //
NSMutableDictionary *data = [NSMutableDictionary dictionary];
[data addEntriesFromDictionary:dict];
if (receiveModel.gift.giftType == GiftType_Lucky) { //
NSArray *luckyBagGifts = (NSArray *)[data objectForKey:@"luckyBagGifts"];
if (luckyBagGifts.count >0) {
//
[luckyBagGifts enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSMutableDictionary * data1 = [NSMutableDictionary dictionary];
[data1 addEntriesFromDictionary:dict];
AttachmentModel * attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_AllMicroSend;
attachment.second = Custom_Message_Sub_AllBatchMicroLuckySend;
[data1 setObject:idx == 0 ? @(YES):@(NO) forKey:@"isShowAnimation"];
[data1 setObject:obj forKey:@"luckyGiftList"];
[data1 setObject:receiveModel.gift.giftName forKey:@"giftName"];
[data1 setObject:[obj valueForKeyPath:@"user.uid"] forKey:@"targetUid"];
[data1 setObject:[dict valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"];
if ([dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"]) {
[data1 setObject:[dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"] forKey:@"luckyGiftSvgaUrl"];
}
[data1 removeObjectForKey:@"luckyBagGifts"];
[data1 removeObjectForKey:@"targetUsers"];
attachment.data = data1;
[self sendCustomMessage:attachment];
}];
}
}else { //
AttachmentModel *attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_AllMicroSend;
attachment.second = Custom_Message_Sub_AllBatchSend;
attachment.data = data;
[self sendCustomMessage:attachment];
[self sendLuckyBagGifts:receiveModel
data:data
firstType:CustomMessageType_AllMicroSend
secondType:Custom_Message_Sub_AllBatchMicroLuckySend
isToOne:NO];
} else { //
if (receiveModel.gift.showAvatarType > 0) {
[self handleEmbeddedValueGiftsMessage:receiveModel
oringinDic:data
isToOne:NO];
} else {
[self sendGiftToMultipleMessage:data];
}
}
} else if (receiveModel.roomSendGiftType == RoomSendGiftType_ToOne) { //
NSMutableDictionary *data = [NSMutableDictionary dictionary];
[data addEntriesFromDictionary:dict];
if (receiveModel.gift.giftType == GiftType_Lucky) { //
NSArray *luckyBagGifts = (NSArray *)[data objectForKey:@"luckyBagGifts"];
[luckyBagGifts enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSMutableDictionary * data1 = [NSMutableDictionary dictionary];
[data1 addEntriesFromDictionary:dict];
AttachmentModel * attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_Gift;
attachment.second = Custom_Message_Sub_Gift_LuckySend;
[data1 setObject:idx == 0 ? @(YES):@(NO) forKey:@"isShowAnimation"];
[data1 setObject:obj forKey:@"luckyGiftList"];
[data1 setObject:receiveModel.gift.giftName forKey:@"giftName"];
[data1 setObject:[obj valueForKeyPath:@"user.uid"] forKey:@"targetUid"];
[data1 setObject:[obj valueForKeyPath:@"user.nick"] forKey:@"targetNick"];
[data1 setObject:[dict valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"];
if ([dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"]) {
[data1 setObject:[dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"] forKey:@"luckyGiftSvgaUrl"];
}
[data1 removeObjectForKey:@"luckyBagGifts"];
[data1 removeObjectForKey:@"targetUsers"];
attachment.data = data1;
[self sendCustomMessage:attachment];
}];
[self sendLuckyBagGifts:receiveModel
data:data
firstType:CustomMessageType_Gift
secondType:Custom_Message_Sub_Gift_LuckySend
isToOne:NO];
}else { //
AttachmentModel *attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_Gift;
attachment.second = Custom_Message_Sub_Gift_Send;
NSDictionary *targetUsers = ((NSArray *)[data objectForKey:@"targetUsers"]).firstObject;
[data setObject:[targetUsers valueForKeyPath:@"uid"] forKey:@"targetUid"];
[data setObject:[targetUsers valueForKeyPath:@"nick"] forKey:@"targetNick"];
[data setObject:[targetUsers valueForKeyPath:@"avatar"] forKey:@"targetAvatar"];
attachment.data = data;
[self sendCustomMessage:attachment];
if (receiveModel.gift.showAvatarType > 0) {
[self handleEmbeddedValueGiftsMessage:receiveModel
oringinDic:data
isToOne:YES];
} else {
[self sendGiftToOneMessage:data];
}
}
}
}
- (void)handleEmbeddedValueGiftsMessage:(GiftReceiveInfoModel *)receiveModel
oringinDic:(NSMutableDictionary *)data
isToOne:(BOOL)isToOne {
// second = 31
@kWeakify(self);
NSArray *targetUsers = [data objectForKey:@"targetUsers"];
__block NSTimeInterval delay = 0.0;
for (NSDictionary *obj in targetUsers) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@kStrongify(self);
AttachmentModel *attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_Gift;
attachment.second = Custom_Message_Sub_Gift_Send;
[data setObject:[[obj objectForKey:@"uid"] stringValue] forKey:@"targetUid"];
[data setObject:[obj objectForKey:@"nick"] forKey:@"targetNick"];
[data setObject:[obj objectForKey:@"avatar"] forKey:@"targetAvatar"];
[data removeObjectForKey:@"targetUsers"];
attachment.data = data;
[self sendCustomMessage:attachment];
});
delay += 0.1;
}
}
- (void)sendGiftToOneMessage:(NSMutableDictionary *)data {
AttachmentModel *attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_Gift;
attachment.second = Custom_Message_Sub_Gift_Send;
NSDictionary *targetUsers = ((NSArray *)[data objectForKey:@"targetUsers"]).firstObject;
[data setObject:[targetUsers valueForKeyPath:@"uid"] forKey:@"targetUid"];
[data setObject:[targetUsers valueForKeyPath:@"nick"] forKey:@"targetNick"];
[data setObject:[targetUsers valueForKeyPath:@"avatar"] forKey:@"targetAvatar"];
attachment.data = data;
[self sendCustomMessage:attachment];
}
- (void)sendGiftToMultipleMessage:(NSMutableDictionary *)data {
AttachmentModel *attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_AllMicroSend;
attachment.second = Custom_Message_Sub_AllBatchSend;
attachment.data = data.copy;
[self sendCustomMessage:attachment];
}
- (void)sendGiftToAllMessage:(NSMutableDictionary *)data {
AttachmentModel * attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_AllMicroSend;
attachment.second = Custom_Message_Sub_AllMicroSend;
[data setObject:[data valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"];
attachment.data = data;
[self sendCustomMessage:attachment];
}
- (void)sendLuckyBagGifts:(GiftReceiveInfoModel *)receiveModel
data:(NSMutableDictionary *)data
firstType:(NSUInteger)first
secondType:(NSUInteger)second
isToOne:(BOOL)isToOne {
@kWeakify(self);
NSArray *luckyBagGifts = (NSArray *)[data objectForKey:@"luckyBagGifts"];
[luckyBagGifts enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
@kStrongify(self);
NSMutableDictionary *tempData = [NSMutableDictionary dictionaryWithDictionary:data.copy];
AttachmentModel * attachment = [[AttachmentModel alloc] init];
attachment.first = (int)first;
attachment.second = (int)second;
[tempData setObject:idx == 0 ? @(YES):@(NO) forKey:@"isShowAnimation"];
[tempData setObject:obj forKey:@"luckyGiftList"];
[tempData setObject:receiveModel.gift.giftName forKey:@"giftName"];
[tempData setObject:[obj valueForKeyPath:@"user.uid"] forKey:@"targetUid"];
if (isToOne) {
[tempData setObject:[obj valueForKeyPath:@"user.nick"] forKey:@"targetNick"];
}
[tempData setObject:[data valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"];
if ([tempData valueForKeyPath:@"gift.luckyGiftSvgaUrl"]) {
[tempData setObject:[data valueForKeyPath:@"gift.luckyGiftSvgaUrl"] forKey:@"luckyGiftSvgaUrl"];
}
attachment.data = tempData;
[self sendCustomMessage:attachment];
}];
}
- (void)sendCustomMessage:(AttachmentModel *)attachment {
NSString *sessionID = self.usingplaceType == SendGiftType_User ? [NSString stringWithFormat:@"%ld", self.userArray.firstObject.uid] : [NSString stringWithFormat:@"%ld", [self.delegate getRoomInfo].roomId];
NIMMessage *message = [[NIMMessage alloc]init];
@@ -881,7 +911,9 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
}
}
- (void)sendGiftSuccess:(GiftReceiveInfoModel *)receiveInfo originDic:(NSDictionary *)originDic uidCount:(NSInteger)uidCount{
- (void)sendGiftSuccess:(GiftReceiveInfoModel *)receiveInfo
originDic:(NSDictionary *)originDic
uidCount:(NSInteger)uidCount{
self.giftBarView.sendButtonIsEnable = YES;
if (receiveInfo.sourceType == GiftSourceType_Pack) {
///
@@ -896,6 +928,11 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
@kStrongify(self);
if (self) {
[[GiftComboManager sharedManager] resetCombo];
@kWeakify(self);
[[GiftComboManager sharedManager] setHandleComboSuccess:^(GiftReceiveInfoModel * _Nonnull receiveModel, NSMutableDictionary * _Nonnull originDic) {
@kStrongify(self);
[self sendCustomMessage:receiveInfo oringinDic:originDic.copy];
}];
[self sendCustomMessage:receiveInfo oringinDic:originDic];
}
});

View File

@@ -2122,6 +2122,8 @@ XPCandyTreeInsufficientBalanceViewDelegate>
//
- (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error {
NSLog(@"******************* sendMessage Raw Attach Content: %@, %ld", [[(AttachmentModel *)[(NIMCustomObject *)message.messageObject attachment] data] objectForKey:@"targetAvatar"], (long)message.messageType);
if (message.yidunAntiSpamRes) {
NSDictionary * spamRes = message.yidunAntiSpamRes.toJSONObject;
id spamResExt = ((NSString *)spamRes[@"ext"]).toJSONObject;