Commit 74676b10 by ludi

拍一拍模块完成,待测

parent 649aff8a
Showing with 636 additions and 24 deletions
...@@ -86,6 +86,7 @@ ...@@ -86,6 +86,7 @@
#define ROOM_CID_LIVE_ROOM_TYPE_CHANGED 11009 // 切换直播类型 #define ROOM_CID_LIVE_ROOM_TYPE_CHANGED 11009 // 切换直播类型
#define ROOM_CID_BECOME_FANS_GROUP_MEMBER 11010 // 用户成为粉丝团成员 #define ROOM_CID_BECOME_FANS_GROUP_MEMBER 11010 // 用户成为粉丝团成员
#define ROOM_CID_RoomPopularChanged 11019 // 人气值变化消息 #define ROOM_CID_RoomPopularChanged 11019 // 人气值变化消息
#define ROOM_CID_receivePatAudience 11025 // 接收撩一撩信息的cid
// 更新直播间互动游戏开关状态socket // 更新直播间互动游戏开关状态socket
#define ROOM_CID_liveInteractionGameStateDidChanged 20204 #define ROOM_CID_liveInteractionGameStateDidChanged 20204
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
<key>FUSChatCenterBundle.xcscheme_^#shared#^_</key> <key>FUSChatCenterBundle.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>73</integer> <integer>74</integer>
</dict> </dict>
<key>FUSChatCenterModule.xcscheme_^#shared#^_</key> <key>FUSChatCenterModule.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>72</integer> <integer>71</integer>
</dict> </dict>
</dict> </dict>
</dict> </dict>
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
<key>FUSShowRoomBundle.xcscheme_^#shared#^_</key> <key>FUSShowRoomBundle.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>71</integer> <integer>75</integer>
</dict> </dict>
<key>FUSShowRoomModule.xcscheme_^#shared#^_</key> <key>FUSShowRoomModule.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>74</integer> <integer>73</integer>
</dict> </dict>
</dict> </dict>
</dict> </dict>
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "live_chat_patAudience_gift_follow@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "live_chat_tableviewcell_pat_icon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
...@@ -21,3 +21,4 @@ FOUNDATION_EXPORT const unsigned char FUSShowRoomModuleVersionString[]; ...@@ -21,3 +21,4 @@ FOUNDATION_EXPORT const unsigned char FUSShowRoomModuleVersionString[];
#import "FUSShowRoomCenterBunble.h" #import "FUSShowRoomCenterBunble.h"
#import "FUSCheckInDayRewardModel.h" #import "FUSCheckInDayRewardModel.h"
#import "FUSCheckInRewardItemModel.h" #import "FUSCheckInRewardItemModel.h"
#import "FUSPatAudiencePatDataModel.h"
...@@ -125,4 +125,14 @@ typedef NS_ENUM(NSInteger,FUSLiveChatModelClickType) { ...@@ -125,4 +125,14 @@ typedef NS_ENUM(NSInteger,FUSLiveChatModelClickType) {
/// cell 宽度缓存 /// cell 宽度缓存
@property (nonatomic, assign) CGFloat cellCacheWidth; @property (nonatomic, assign) CGFloat cellCacheWidth;
/// (patStatus 拍一拍状态值(0:否、1:是))
@property (nonatomic, assign) BOOL patStatus;
/// 指令(100:拍一拍, 101:惩罚-去解救, 102: 回拍。103:觀看超過3分鐘)
@property (nonatomic, assign) NSInteger order;
/// 判定是否有通用点击事件,因为后台没有返回默认的order,需要自行判定归纳全是否是order通用点击
-(BOOL)ffisClickOrderModel;
@end @end
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
{ {
self = [super init]; self = [super init];
if (self) { if (self) {
self.patStatus = NO;
} }
return self; return self;
} }
...@@ -80,4 +81,8 @@ ...@@ -80,4 +81,8 @@
return _languageContent; return _languageContent;
} }
- (BOOL)ffisClickOrderModel{
return self.order == 101;
}
@end @end
//
// FUSPatAudiencePatDataModel.h
// FUSShowRoomModule
//
// Created by aaa on 2024/9/26.
//
#import <FUSFoundation/FUSFoundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface FUSPatAudienceGiftModel : FUSBaseModel
/// 礼物ID
@property (nonatomic, copy) NSString *gid;
/// 礼物名称
@property (nonatomic, copy) NSString *giftName;
/// 礼物图标
@property (nonatomic, copy) NSString *giftUrl;
/// 礼物货币单位(3:宝石、4:寨券、5:露水)
@property (nonatomic, assign) NSInteger giftCurrency;
/// 礼物价值
@property (nonatomic, assign) NSInteger giftPrice;
/// 是否默认选择
@property (nonatomic, assign) BOOL selected;
/// 内部属性,用于区分礼物的类型,用于卡片展示,-1=关注,0=礼物
@property (nonatomic, assign) NSInteger fus_modelType;
@end
@interface FUSPatAudiencePatDataModel : FUSBaseModel
///关注(0:关闭、1:显示)
@property (nonatomic, assign) NSInteger follow;
/// 普通礼物列表
@property (nonatomic, strong) NSMutableArray<FUSPatAudienceGiftModel *> *giftList;
@end
NS_ASSUME_NONNULL_END
//
// FUSPatAudiencePatDataModel.m
// FUSShowRoomModule
//
// Created by aaa on 2024/9/26.
//
#import "FUSPatAudiencePatDataModel.h"
@implementation FUSPatAudienceGiftModel
- (instancetype)init
{
self = [super init];
if (self) {
self.fus_modelType = 0;
}
return self;
}
@end
@implementation FUSPatAudiencePatDataModel
+ (NSDictionary *)modelContainerPropertyGenericClass {
return @{@"giftList": [FUSPatAudienceGiftModel class]};
}
@end
...@@ -779,4 +779,23 @@ ...@@ -779,4 +779,23 @@
succeed:(void(^)(NSArray<NSString *> *notList))succeed succeed:(void(^)(NSArray<NSString *> *notList))succeed
failure:(void(^)(NSString *msg,NSInteger code))failure; failure:(void(^)(NSString *msg,NSInteger code))failure;
/// 回撩
/// @param roomId 房间id
/// @param type 类型(1:关注、2:送礼)
/// @param gid 礼物ID(type=2必传)
+(void)fus_livePatReplyWithRoomId:(NSString *)roomId
type:(NSInteger)type
gid:(NSString *)gid
succeed:(void(^)(NSMutableDictionary *changed))succeed
failure:(void(^)(NSString *msg,NSInteger code))failure;
/// 撩一撩用户
/// @param roomId 房间id
/// @param toUserId 撩谁
/// @param succeed 成功
/// @param failure 失败
+(void)fus_livePatUserWithRoomId:(NSString *)roomId
toUserId:(NSString *)toUserId
succeed:(void(^)(void))succeed
failure:(void(^)(NSString *msg,NSInteger code))failure;
@end @end
...@@ -2415,4 +2415,27 @@ ...@@ -2415,4 +2415,27 @@
}]; }];
} }
+ (void)fus_livePatReplyWithRoomId:(NSString *)roomId type:(NSInteger)type gid:(NSString *)gid succeed:(void (^)(NSMutableDictionary *))succeed failure:(void (^)(NSString *, NSInteger))failure{
NSDictionary *parm = @{@"roomId": roomId ?: @"",
@"type": [NSString stringWithFormat:@"%ld",type],
@"gid": gid ?: @""};
[FUSHttpHelper postRequestBinaryWithUrl:FUSShowRoomURLs.fus_URL_LIVE_PAT_REPLY params:parm success:^(NSDictionary * _Nullable dataDict, int code) {
NSMutableDictionary *changedDict = [[NSMutableDictionary alloc] initWithDictionary:dataDict[@"cv"]];
changedDict[@"rich"] = dataDict[@"rich"];
succeed(changedDict);
} failure:^(NSDictionary * _Nullable dataDict, int code) {
if (failure) failure(dataDict[@"msg"],code);
}];
}
+ (void)fus_livePatUserWithRoomId:(NSString *)roomId toUserId:(NSString *)toUserId succeed:(void (^)(void))succeed failure:(void (^)(NSString *, NSInteger))failure{
NSDictionary *parm = @{@"roomId": roomId ?: @"",
@"toUserId": toUserId};
[FUSHttpHelper postRequestBinaryWithUrl:FUSShowRoomURLs.fus_URL_LIVE_PAT_USER params:parm success:^(NSDictionary * _Nullable dataDict, int code) {
succeed();
} failure:^(NSDictionary * _Nullable dataDict, int code) {
if (failure) failure(dataDict[@"msg"],code);
}];
}
@end @end
...@@ -196,6 +196,9 @@ ...@@ -196,6 +196,9 @@
*/ */
- (NSInteger)indexForModel:(FUSLiveChatModel *)model; - (NSInteger)indexForModel:(FUSLiveChatModel *)model;
/// 取出撩一撩的范围
- (NSRange)patAudienceRangeForModelID:(NSString *)modelId;
/** /**
取出解析好的富文本 取出解析好的富文本
......
...@@ -59,6 +59,9 @@ ...@@ -59,6 +59,9 @@
*/ */
@property (nonatomic, strong) NSMutableDictionary *cellWidthDict; @property (nonatomic, strong) NSMutableDictionary *cellWidthDict;
/// 拍一拍按钮的范围
@property (nonatomic, strong) NSMutableDictionary *patAudienceRangeDict;
#pragma mark - Property:Other #pragma mark - Property:Other
/** /**
等级字典 等级字典
...@@ -182,15 +185,15 @@ ...@@ -182,15 +185,15 @@
if (lastModel.isFold && welcomeMessageFoldSwitch) { if (lastModel.isFold && welcomeMessageFoldSwitch) {
NSAttributedString *attr = [self attributedStringForModelID:model.ID]; NSAttributedString *attr = [self attributedStringForModelID:model.ID];
// NSRange nicknameRange; // NSRange nicknameRange;
// NSRange patAudienceRange; NSRange patAudienceRange = NSMakeRange(NSNotFound, 0);;
// NSRange orderBtnRange; // NSRange orderBtnRange;
// //
// if (self.nicknameRangeDict[model.ID]) { // if (self.nicknameRangeDict[model.ID]) {
// nicknameRange = [self.nicknameRangeDict[model.ID] rangeValue]; // nicknameRange = [self.nicknameRangeDict[model.ID] rangeValue];
// } // }
// if (self.patAudienceRangeDict[model.ID]) { if (self.patAudienceRangeDict[model.ID]) {
// patAudienceRange = [self.patAudienceRangeDict[model.ID] rangeValue]; patAudienceRange = [self.patAudienceRangeDict[model.ID] rangeValue];
// } }
// //
// if (self.orderBtnRangeDict[model.ID]) { // if (self.orderBtnRangeDict[model.ID]) {
// orderBtnRange = [self.orderBtnRangeDict[model.ID] rangeValue]; // orderBtnRange = [self.orderBtnRangeDict[model.ID] rangeValue];
...@@ -202,9 +205,9 @@ ...@@ -202,9 +205,9 @@
if (lastWidth != width || lastHeight != height) { if (lastWidth != width || lastHeight != height) {
[addedRefreshList addObject:model]; [addedRefreshList addObject:model];
} else { } else {
if ([lastCell respondsToSelector:@selector(fus_changeCellToModel:attributedString:height:width:completionHandler:)]) { if ([lastCell respondsToSelector:@selector(fus_changeCellToModel:attributedString:patAudienceRange:height:width:completionHandler:)]) {
[lastCell fus_changeCellToModel:model attributedString:attr height:height width:width completionHandler:^(FUSLiveChatModel *oldModel) { [lastCell fus_changeCellToModel:model attributedString:attr patAudienceRange:patAudienceRange height:height width:width completionHandler:^(FUSLiveChatModel *oldModel) {
}]; }];
} }
} }
...@@ -320,6 +323,13 @@ ...@@ -320,6 +323,13 @@
return _waitForRefreshDataList; return _waitForRefreshDataList;
} }
- (NSMutableDictionary *)patAudienceRangeDict{
if (!_patAudienceRangeDict) {
_patAudienceRangeDict = [NSMutableDictionary dictionary];
}
return _patAudienceRangeDict;
}
#pragma mark - method #pragma mark - method
#pragma mark -- 添加 #pragma mark -- 添加
// 添加 model // 添加 model
...@@ -635,6 +645,12 @@ ...@@ -635,6 +645,12 @@
return width.doubleValue; return width.doubleValue;
} }
// 取出撩一撩的范围
- (NSRange)patAudienceRangeForModelID:(NSString *)modelId{
NSRange range = [[self.patAudienceRangeDict objectForKey:modelId] rangeValue];
return range;
}
// 取出解析好的富文本 // 取出解析好的富文本
- (NSAttributedString *)attributedStringForModelID:(NSString *)modelId - (NSAttributedString *)attributedStringForModelID:(NSString *)modelId
{ {
...@@ -692,6 +708,7 @@ ...@@ -692,6 +708,7 @@
[self.cellHeightDict removeObjectForKey:model.ID]; [self.cellHeightDict removeObjectForKey:model.ID];
[self.cellWidthDict removeObjectForKey:model.ID]; [self.cellWidthDict removeObjectForKey:model.ID];
[self.cellStringDict removeObjectForKey:model.ID]; [self.cellStringDict removeObjectForKey:model.ID];
[self.patAudienceRangeDict removeObjectForKey:model.ID];
}else{ }else{
...@@ -701,6 +718,7 @@ ...@@ -701,6 +718,7 @@
[self.cellHeightDict removeObjectForKey:model.ID]; [self.cellHeightDict removeObjectForKey:model.ID];
[self.cellWidthDict removeObjectForKey:model.ID]; [self.cellWidthDict removeObjectForKey:model.ID];
[self.cellStringDict removeObjectForKey:model.ID]; [self.cellStringDict removeObjectForKey:model.ID];
[self.patAudienceRangeDict removeObjectForKey:model.ID];
}); });
...@@ -764,6 +782,18 @@ ...@@ -764,6 +782,18 @@
} }
} }
//在主线程组合生成额外按钮
NSAttributedString *orderBtnAttr = nil;
NSMutableDictionary *orderBtnRangeDict = nil;
if ([FUSLiveHelper shareInstance].liveType == FUSLiveTypeAnchor) {
if (model.patStatus == YES) {
//拍一拍
orderBtnAttr = [self fus_getPatAudienceAttr];
orderBtnRangeDict = self.patAudienceRangeDict;
}
}
CGFloat imageH = 14; CGFloat imageH = 14;
CGFloat imageW = 0; CGFloat imageW = 0;
...@@ -776,6 +806,15 @@ ...@@ -776,6 +806,15 @@
[attr appendAttributedString:contentAttr]; [attr appendAttributedString:contentAttr];
} }
// 添加按钮
if (orderBtnAttr && orderBtnAttr.length > 0 && orderBtnRangeDict) {
if ((model.ID && model.ID.length > 0) && (attr && attr.length > 0)) {
[orderBtnRangeDict setValue:[NSValue valueWithRange:NSMakeRange(attr.length, 1)] forKey:model.ID];
[attr appendAttributedString:orderBtnAttr];
}
}
[self fus_rectWithAttr:attr completed:^(CGRect rect) { [self fus_rectWithAttr:attr completed:^(CGRect rect) {
complete([[NSMutableAttributedString alloc] initWithAttributedString:attr],rect); complete([[NSMutableAttributedString alloc] initWithAttributedString:attr],rect);
}]; }];
...@@ -1271,6 +1310,11 @@ ...@@ -1271,6 +1310,11 @@
contentStr = @""; contentStr = @"";
} }
/// 拍一拍的数据
if (socketDict[@"patStatus"] != nil) {
messageModel.patStatus = [socketDict[@"patStatus"] boolValue];
}
// 循环搜索符合正则表达式的结果 // 循环搜索符合正则表达式的结果
NSArray *matchArray = nil; NSArray *matchArray = nil;
...@@ -1743,6 +1787,43 @@ ...@@ -1743,6 +1787,43 @@
return YES; return YES;
} }
/// 创建拍一拍的按钮图标
- (NSAttributedString *)fus_getPatAudienceAttr{
// 创建按钮
UIView *btnView = [[UIView alloc] init];
btnView.backgroundColor = [UIColor fus_themeColor];
UIImageView *patImageView = [[UIImageView alloc] initWithImage:[FUSShowRoomCenterBunble imageNamed:@"live_chat_tableviewcell_pat_icon"]];
patImageView.contentMode = UIViewContentModeScaleAspectFit;
patImageView.frame = CGRectMake(6, 0, _fontSize - 4, _fontSize - 4);
patImageView.centerY = (_fontSize + 2) / 2;
[btnView addSubview:patImageView];
UILabel *patTitleLabel = [[UILabel alloc] init];
patTitleLabel.font = [UIFont fus_themeFont:_fontSize - 4];
patTitleLabel.textColor = [UIColor colorWithHex:@"#22222B"];
patTitleLabel.text = [NSString fus_versionLocalString:@"撩一撩"];
[patTitleLabel sizeToFit];
patTitleLabel.x = CGRectGetMaxX(patImageView.frame) + 2;
patTitleLabel.centerY = (_fontSize + 2) / 2;
[btnView addSubview:patTitleLabel];
btnView.height = _fontSize + 2;
btnView.width = CGRectGetMaxX(patTitleLabel.frame) + 6;
btnView.layer.cornerRadius = btnView.height / 2;
UIView *btnBgView = [[UIView alloc] init];
btnBgView.userInteractionEnabled = NO;
btnBgView.frame = btnView.bounds;
btnBgView.width = btnView.width + 10;
btnBgView.height = btnView.height + 4;
[btnBgView addSubview:btnView];
btnView.center = btnBgView.center;
return [NSAttributedString attachmentStringWithContent:btnBgView contentMode:UIViewContentModeScaleAspectFit attachmentSize:btnBgView.size alignToFont:FUS_LIVE_FONT(self.fontSize) alignment:YYTextVerticalAlignmentCenter];
}
- (void)dealloc - (void)dealloc
{ {
[[NSNotificationCenter defaultCenter]removeObserver:self]; [[NSNotificationCenter defaultCenter]removeObserver:self];
......
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
*/ */
@property (nonatomic, copy) void(^onClickNicknameHandler)(FUSLiveChatModel *model); @property (nonatomic, copy) void(^onClickNicknameHandler)(FUSLiveChatModel *model);
/// 点击拍一拍回调
@property (nonatomic, copy) void(^onClickPatAudiencetHandler)(FUSLiveChatModel *model);
/** /**
允许发送通知 允许发送通知
*/ */
...@@ -57,6 +60,9 @@ ...@@ -57,6 +60,9 @@
// 创建一个系统消息 // 创建一个系统消息
- (void)fus_addSystemTip:(NSString *)tip; - (void)fus_addSystemTip:(NSString *)tip;
/// 更新一个信息
- (void)fus_UpdataMessageWithModel:(FUSLiveChatModel *)model;
/** /**
滚动到底部 滚动到底部
......
...@@ -166,6 +166,8 @@ ...@@ -166,6 +166,8 @@
NSAttributedString *attr = [self.dataSourceHelper attributedStringForModelID:model.ID]; NSAttributedString *attr = [self.dataSourceHelper attributedStringForModelID:model.ID];
NSRange patAudienceRange = [self.dataSourceHelper patAudienceRangeForModelID:model.ID];
CGFloat height = [self.dataSourceHelper heightForModelID:model.ID]; CGFloat height = [self.dataSourceHelper heightForModelID:model.ID];
CGFloat width = [self.dataSourceHelper widthForModelID:model.ID]; CGFloat width = [self.dataSourceHelper widthForModelID:model.ID];
...@@ -186,7 +188,7 @@ ...@@ -186,7 +188,7 @@
showBackground = YES; showBackground = YES;
} }
[cell fus_setupCellWithModel:model attributedString:attr height:height width:width showBackground:showBackground]; [cell fus_setupCellWithModel:model attributedString:attr patAudienceRange:patAudienceRange height:height width:width showBackground:showBackground];
[cell setOnClickNicknameWithModel:^(FUSLiveChatModel *model) { [cell setOnClickNicknameWithModel:^(FUSLiveChatModel *model) {
...@@ -195,6 +197,13 @@ ...@@ -195,6 +197,13 @@
} }
}]; }];
[cell setOnClickPatAudienceWithModel:^(FUSLiveChatModel *model) {
// 点击了撩一撩
if (weakSelf.onClickPatAudiencetHandler) {
weakSelf.onClickPatAudiencetHandler(model);
}
}];
return cell; return cell;
} }
...@@ -395,6 +404,11 @@ ...@@ -395,6 +404,11 @@
[self.dataSourceHelper fus_addSystemTip:tip]; [self.dataSourceHelper fus_addSystemTip:tip];
} }
/// 更新一个信息
- (void)fus_UpdataMessageWithModel:(FUSLiveChatModel *)model{
[self.dataSourceHelper fus_updateMessageWithModel:model];
}
#pragma mark - method #pragma mark - method
- (void)fus_scrollToBottom{ - (void)fus_scrollToBottom{
......
...@@ -21,14 +21,18 @@ ...@@ -21,14 +21,18 @@
@property (nonatomic, copy) void(^onClickNicknameWithModel)(FUSLiveChatModel *); @property (nonatomic, copy) void(^onClickNicknameWithModel)(FUSLiveChatModel *);
@property (nonatomic, copy) void(^onClickPatAudienceWithModel)(FUSLiveChatModel *);
- (void)fus_setupCellWithModel:(FUSLiveChatModel *)model - (void)fus_setupCellWithModel:(FUSLiveChatModel *)model
attributedString:(NSAttributedString *)attr attributedString:(NSAttributedString *)attr
patAudienceRange:(NSRange)patAudienceRange
height:(CGFloat)height height:(CGFloat)height
width:(CGFloat)width width:(CGFloat)width
showBackground:(BOOL)showBackground; showBackground:(BOOL)showBackground;
- (void)fus_changeCellToModel:(FUSLiveChatModel *)model - (void)fus_changeCellToModel:(FUSLiveChatModel *)model
attributedString:(NSAttributedString *)attr attributedString:(NSAttributedString *)attr
patAudienceRange:(NSRange)patAudienceRange
height:(CGFloat)height height:(CGFloat)height
width:(CGFloat)width width:(CGFloat)width
completionHandler:(void(^)(FUSLiveChatModel *oldModel))completionHandler; completionHandler:(void(^)(FUSLiveChatModel *oldModel))completionHandler;
......
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
// 背景 View // 背景 View
@property (nonatomic, strong) UIImageView *bgView; @property (nonatomic, strong) UIImageView *bgView;
/// 拍一拍的范围
@property (nonatomic, assign) NSRange patAudienceRange;
@end @end
@implementation FUSLiveChatTableViewCell @implementation FUSLiveChatTableViewCell
...@@ -90,26 +93,54 @@ ...@@ -90,26 +93,54 @@
[_bgView addSubview:_contentLabel]; [_bgView addSubview:_contentLabel];
// 添加点击 // 添加点击
[_contentLabel addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onTapContentLabel:)]]; // [_contentLabel addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onTapContentLabel:)]];
} // ludy:新版本由这个替代
MJWeakSelf
_contentLabel.textTapAction = ^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
if (weakSelf.model.patStatus == 1 && range.location == weakSelf.patAudienceRange.location) {
// 撩一撩
if ([FUSLiveHelper shareInstance].liveType == FUSLiveTypeAudience) {
// 如果是观众端,那么直接无视
return;
}
// 点击事件 if (weakSelf.onClickPatAudienceWithModel) {
- (void)onTapContentLabel:(UITapGestureRecognizer *)tap weakSelf.onClickPatAudienceWithModel(weakSelf.model);
{ }
if ((![NSString isNull:_model.uid] && _model.uid.integerValue != 0) }
|| _model.clickType == FUSLiveChatModelClickTypeDewGift else {
|| (_model.clickType == FUSLiveChatModelClickTypeOtherLiveRoom && ![NSString isNull:_model.toUid])) { //其他情况
if (self.onClickNicknameWithModel) self.onClickNicknameWithModel(_model); if ((![NSString isNull:weakSelf.model.uid] && weakSelf.model.uid.integerValue != 0)
|| weakSelf.model.clickType == FUSLiveChatModelClickTypeDewGift
|| (weakSelf.model.clickType == FUSLiveChatModelClickTypeOtherLiveRoom && ![NSString isNull:weakSelf.model.toUid])) {
// 能nickname的就交付给nickname
if (weakSelf.onClickNicknameWithModel) weakSelf.onClickNicknameWithModel(weakSelf.model);
} }
}
};
} }
// 点击事件
//- (void)onTapContentLabel:(UITapGestureRecognizer *)tap
//{
// if ((![NSString isNull:_model.uid] && _model.uid.integerValue != 0)
// || _model.clickType == FUSLiveChatModelClickTypeDewGift
// || (_model.clickType == FUSLiveChatModelClickTypeOtherLiveRoom && ![NSString isNull:_model.toUid])) {
// if (self.onClickNicknameWithModel) self.onClickNicknameWithModel(_model);
// }
//}
- (void)fus_setupCellWithModel:(FUSLiveChatModel *)model - (void)fus_setupCellWithModel:(FUSLiveChatModel *)model
attributedString:(NSAttributedString *)attr attributedString:(NSAttributedString *)attr
patAudienceRange:(NSRange)patAudienceRange
height:(CGFloat)height height:(CGFloat)height
width:(CGFloat)width width:(CGFloat)width
showBackground:(BOOL)showBackground showBackground:(BOOL)showBackground
{ {
_patAudienceRange = patAudienceRange;
if (attr.length && [self.contentLabel.attributedText isEqualToAttributedString:attr]) { if (attr.length && [self.contentLabel.attributedText isEqualToAttributedString:attr]) {
// 设置 frame // 设置 frame
_contentLabel.frame = CGRectMake(CELL_LEADING_SPACE, CELL_MARGIN, width, height); _contentLabel.frame = CGRectMake(CELL_LEADING_SPACE, CELL_MARGIN, width, height);
...@@ -166,7 +197,12 @@ ...@@ -166,7 +197,12 @@
_contentLabel.alpha = 1; _contentLabel.alpha = 1;
} }
- (void)fus_changeCellToModel:(FUSLiveChatModel *)model attributedString:(NSAttributedString *)attr height:(CGFloat)height width:(CGFloat)width completionHandler:(void(^)(FUSLiveChatModel *oldModel))completionHandler - (void)fus_changeCellToModel:(FUSLiveChatModel *)model
attributedString:(NSAttributedString *)attr
patAudienceRange:(NSRange)patAudienceRange
height:(CGFloat)height
width:(CGFloat)width
completionHandler:(void(^)(FUSLiveChatModel *oldModel))completionHandler
{ {
if (_isChanging) { if (_isChanging) {
return; return;
...@@ -188,7 +224,7 @@ ...@@ -188,7 +224,7 @@
} }
// 设置 lable // 设置 lable
[self fus_setupCellWithModel:model attributedString:attr height:height width:width showBackground:showBackground]; [self fus_setupCellWithModel:model attributedString:attr patAudienceRange:patAudienceRange height:height width:width showBackground:showBackground];
// 持有当前内容 // 持有当前内容
self.currentString = model.msg; self.currentString = model.msg;
// 设置 frame // 设置 frame
......
...@@ -382,6 +382,12 @@ typedef NS_ENUM(NSInteger, FUSFunctionMode) { ...@@ -382,6 +382,12 @@ typedef NS_ENUM(NSInteger, FUSFunctionMode) {
/// @param url 动画图片url /// @param url 动画图片url
- (void)fus_startHeadViewReceiveGiftAnimWithImgUrl:(NSString *)url; - (void)fus_startHeadViewReceiveGiftAnimWithImgUrl:(NSString *)url;
/// 显示点击关注的动画,给外面某些比如一个接口就是送礼并且自动关注的动作调用
-(void)fus_showClickLikeAnimateWithIsFollow:(BOOL)isFollow;
/// 接收富豪等级变化通知
-(void)fus_recieveRichLevelChangeWithUID:(NSString *)uid newLevel:(NSString *)newLevel;
#pragma mark - 直播间最小化最大化关闭操作 #pragma mark - 直播间最小化最大化关闭操作
/// 退出当前直播间 /// 退出当前直播间
- (void)fus_exitRoomCompelete:(void(^)(void))compelete; - (void)fus_exitRoomCompelete:(void(^)(void))compelete;
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#import "FUSVideoChatUserInfoView.h" #import "FUSVideoChatUserInfoView.h"
#import "FUSHalfWebView.h" #import "FUSHalfWebView.h"
#import "FUSRoomFirstChargeAlertView.h" #import "FUSRoomFirstChargeAlertView.h"
#import "FUSPatAudiencePromptAlertView.h"
#import "FUSLiveManagerViewController.h" #import "FUSLiveManagerViewController.h"
...@@ -327,6 +328,9 @@ FUSLinkMicUserListDelegate ...@@ -327,6 +328,9 @@ FUSLinkMicUserListDelegate
/// 半屏网页的管理,内部全是弱引用,放心添加网页 /// 半屏网页的管理,内部全是弱引用,放心添加网页
@property (nonatomic, strong) FUSLiveFunctionViewHalfWebManager *halfWebManager; @property (nonatomic, strong) FUSLiveFunctionViewHalfWebManager *halfWebManager;
/// 观众端拍一拍的弹窗
@property (nonatomic, strong) FUSPatAudiencePromptAlertView *patAudienceProptAlertView;
@end @end
@implementation FUSLiveFunctionView @implementation FUSLiveFunctionView
...@@ -777,6 +781,33 @@ FUSLinkMicUserListDelegate ...@@ -777,6 +781,33 @@ FUSLinkMicUserListDelegate
_chatTableView.enableSendNotification = YES; _chatTableView.enableSendNotification = YES;
[_chatViewBgView addSubview:_chatTableView]; [_chatViewBgView addSubview:_chatTableView];
__weak typeof(_chatTableView) weakChatTableView = _chatTableView;
__weak typeof(_pusherChatTableView) weakPusherChatTableView = _pusherChatTableView;
[_chatTableView setOnClickPatAudiencetHandler:^(FUSLiveChatModel *model) {
if ([NSString isNullWithString:model.realUid]) {
return;
}
model.patStatus = NO;
[weakChatTableView fus_UpdataMessageWithModel:model];
[weakPusherChatTableView fus_UpdataMessageWithModel:model];
[FUSLiveHttpHelper fus_livePatUserWithRoomId:[FUSLiveHelper shareInstance].roomInfoModel.roomId toUserId:model.realUid succeed:^{
} failure:^(NSString *msg, NSInteger code) {
// -20109为已经拍过这个用户了,所以不需要重新显示了
if (code != -20109) {
// 拍失败则重新显示
model.patStatus = YES;
[weakChatTableView fus_UpdataMessageWithModel:model];
[weakPusherChatTableView fus_UpdataMessageWithModel:model];
}
[FUSDialogView fus_showDialog:msg];
}];
}];
[_chatTableView setOnClickNicknameHandler:^(FUSLiveChatModel *model) { [_chatTableView setOnClickNicknameHandler:^(FUSLiveChatModel *model) {
[weakSelf endEditing:YES]; [weakSelf endEditing:YES];
...@@ -1019,6 +1050,33 @@ FUSLinkMicUserListDelegate ...@@ -1019,6 +1050,33 @@ FUSLinkMicUserListDelegate
_pusherChatTableView.enableSendNotification = NO; _pusherChatTableView.enableSendNotification = NO;
[bgView addSubview:_pusherChatTableView]; [bgView addSubview:_pusherChatTableView];
__weak typeof(_chatTableView) weakChatTableView = _chatTableView;
__weak typeof(_pusherChatTableView) weakPusherChatTableView = _pusherChatTableView;
[_pusherChatTableView setOnClickPatAudiencetHandler:^(FUSLiveChatModel *model) {
if ([NSString isNullWithString:model.realUid]) {
return;
}
model.patStatus = NO;
[weakChatTableView fus_UpdataMessageWithModel:model];
[weakPusherChatTableView fus_UpdataMessageWithModel:model];
[FUSLiveHttpHelper fus_livePatUserWithRoomId:[FUSLiveHelper shareInstance].roomInfoModel.roomId toUserId:model.realUid succeed:^{
} failure:^(NSString *msg, NSInteger code) {
// -20109为已经拍过这个用户了,所以不需要重新显示了
if (code != -20109) {
// 拍失败则重新显示
model.patStatus = YES;
[weakChatTableView fus_UpdataMessageWithModel:model];
[weakPusherChatTableView fus_UpdataMessageWithModel:model];
}
[FUSDialogView fus_showDialog:msg];
}];
}];
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
[_pusherChatTableView setOnClickNicknameHandler:^(FUSLiveChatModel *model) { [_pusherChatTableView setOnClickNicknameHandler:^(FUSLiveChatModel *model) {
[weakSelf endEditing:YES]; [weakSelf endEditing:YES];
...@@ -1868,6 +1926,9 @@ FUSLinkMicUserListDelegate ...@@ -1868,6 +1926,9 @@ FUSLinkMicUserListDelegate
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fus_receivePKStateDidChanged:) name:FUSLiveNotificationKeys.fus_FUS_LIVE_ROOM_PK_STATUS object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fus_receivePKStateDidChanged:) name:FUSLiveNotificationKeys.fus_FUS_LIVE_ROOM_PK_STATUS object:nil];
// 接收主播直播拍一拍用户消息
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fus_receivePatAudienceUpNotification:) name:STR(ROOM_CID_receivePatAudience) object:nil];
//每进一个直播间静音状态都复原 //每进一个直播间静音状态都复原
[[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:PLAYER_SOUND_MUTE]; [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:PLAYER_SOUND_MUTE];
[self.pkHelper registNotification]; [self.pkHelper registNotification];
...@@ -2997,6 +3058,26 @@ FUSLinkMicUserListDelegate ...@@ -2997,6 +3058,26 @@ FUSLinkMicUserListDelegate
} }
} }
/// 观众端接收拍一拍的消息
-(void)fus_receivePatAudienceUpNotification:(NSNotification *)notification {
FUSSocketMessageModel *socketModel = notification.object;
if (FUSLiveHelper.shareInstance.liveType != FUSLiveTypeAudience) {
return;
}
NSDictionary *dict = [socketModel fus_getJsonDict];
NSString *roomId = [dict[@"roomId"] stringValue];
if (![FUSLiveHelper.shareInstance.roomInfoModel.roomId isEqualToString:roomId]) {
return;
}
[self.patAudienceProptAlertView fus_dismissWithAnimation];
self.patAudienceProptAlertView = nil;
self.patAudienceProptAlertView = [FUSPatAudiencePromptAlertView fus_showWithData:dict showOn:[self fus_viewWithLayer:FUSLiveFunctionLayerAutoPopView]];
}
- (void)fus_showKeywordEffectNofitication:(NSNotification *)notification { - (void)fus_showKeywordEffectNofitication:(NSNotification *)notification {
FUSSocketMessageModel *socketModel = notification.object; FUSSocketMessageModel *socketModel = notification.object;
...@@ -4819,6 +4900,30 @@ FUSLinkMicUserListDelegate ...@@ -4819,6 +4900,30 @@ FUSLinkMicUserListDelegate
[self.headView fus_startHeadViewReceiveGiftAnimWithImgUrl:url]; [self.headView fus_startHeadViewReceiveGiftAnimWithImgUrl:url];
} }
/// 显示点击关注的动画,给外面某些比如一个接口就是送礼并且自动关注的动作调用
- (void)fus_showClickLikeAnimateWithIsFollow:(BOOL)isFollow{
if (FUSLiveHelper.shareInstance.roomInfoModel.liked.boolValue == isFollow) {
return;
}
if (self.pkHelper.pkLiveState == FUSPKLiveStatePK) {
return;
}
// 判断键盘当前是否是编辑状态
if (_isEditing == YES) {
_keyBoardHideNeedShowLikeNotice = YES;
return;
}else{
_keyBoardHideNeedShowLikeNotice = NO;
}
[self.headView fus_showClickLikeAnimateWithIsFollow:isFollow];
}
- (void)fus_recieveRichLevelChangeWithUID:(NSString *)uid newLevel:(NSString *)newLevel{
[self.userListViewModel fus_reloadUserDataWithUID:uid newLevel:newLevel inPay:nil];
}
/** /**
设置热力值 设置热力值
......
...@@ -204,4 +204,7 @@ typedef NS_ENUM(NSInteger, FUSLiveHeadViewType) { ...@@ -204,4 +204,7 @@ typedef NS_ENUM(NSInteger, FUSLiveHeadViewType) {
- (void)fus_updateUserListModel:(id)userListModel; - (void)fus_updateUserListModel:(id)userListModel;
/// 显示点击关注的动画,给外面某些比如一个接口就是送礼并且自动关注的动作调用
-(void)fus_showClickLikeAnimateWithIsFollow:(BOOL)isFollow;
@end @end
...@@ -612,6 +612,10 @@ NSString * const kDidHotScoreChangeNotification = @"kDidHotScoreChangeNotificati ...@@ -612,6 +612,10 @@ NSString * const kDidHotScoreChangeNotification = @"kDidHotScoreChangeNotificati
} }
} }
- (void)fus_showClickLikeAnimateWithIsFollow:(BOOL)isFollow{
[self.portraitView fus_showClickLikeAnimateWithIsFollow:isFollow];
}
/** /**
获取追踪按钮在 Window 上的 rect 获取追踪按钮在 Window 上的 rect
......
...@@ -81,6 +81,9 @@ ...@@ -81,6 +81,9 @@
*/ */
- (void)fus_onClickLikeButton:(UIButton *)sender; - (void)fus_onClickLikeButton:(UIButton *)sender;
/// 显示点击关注的动画,给外面某些比如一个接口就是送礼并且自动关注的动作调用
-(void)fus_showClickLikeAnimateWithIsFollow:(BOOL)isFollow;
- (void)fus_anchorOffline:(BOOL)offline; - (void)fus_anchorOffline:(BOOL)offline;
......
...@@ -785,6 +785,47 @@ ...@@ -785,6 +785,47 @@
}]; }];
} }
/// 显示点击关注的动画,给外面某些比如一个接口就是送礼并且自动关注的动作调用
-(void)fus_showClickLikeAnimateWithIsFollow:(BOOL)isFollow{
if (isFollow) {
// 设置图片动画
CGFloat framePerSecond = 12.0;
NSMutableArray *imageArr = [NSMutableArray array];
for (int i = 0; i <= 5; i++) {
UIImage *image = [FUSShowRoomCenterBunble imageNamed:[NSString stringWithFormat:@"live_head_follow_btn_anim_%d", i]];
if (image) {
[imageArr addObject:image];
}
}
CGFloat duration = imageArr.count / framePerSecond;
self.likeBtn.imageView.animationImages = imageArr;
self.likeBtn.imageView.animationDuration = duration;
self.likeBtn.imageView.animationRepeatCount = 1;
[self.likeBtn.imageView startAnimating];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.likeBtn.imageView stopAnimating];
[FUSDialogView fus_showDialog:[NSString fus_localString:@"追踪成功"]];
[[FUSLiveHelper shareInstance]roomInfoModel].liked = @"1";
[[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveNotificationKeys.fus_FocusBaoFang_Refresh object:@{@"roomId":self.currentModel.roomId,@"like":@(YES)}];
[self fus_dismissLikeButtonWithAnimation:YES];
self.likeBtn.enabled = YES;
});
}else {
// ludy:这个居然是取消,我也不知道前面的人怎么写的,很夸张
[self fus_showLikeButtonWithAnimation:YES];
}
}
/** /**
手势点击 Portrait View 手势点击 Portrait View
*/ */
......
//
// FUSPatAudienceGiftCell.swift
// FUSShowRoomModule
//
// Created by aaa on 2024/9/26.
//
import UIKit
@objcMembers public class FUSPatAudienceGiftCell: FUSSwiftCollectionViewCell {
static public func fus_getCellIdentifier() -> String {
return "FUSPatAudienceGiftCell"
}
public var itemSelect: Bool = false {
didSet{
bgImageView.layer.borderWidth = itemSelect ? 1 : 0
}
}
let bgImageView = UIImageView()
let iconImageView = UIImageView()
let nameLabel = UILabel()
let costBtn = UIButton(type: .custom)
public override func makeUI() {
super.makeUI()
self.backgroundColor = .clear
self.contentView.backgroundColor = .clear
bgImageView.layer.cornerRadius = 4
bgImageView.backgroundColor = .init(hex: "#EEECEC")
bgImageView.layer.borderColor = UIColor.fus_theme().cgColor
bgImageView.layer.borderWidth = 0
bgImageView.layer.masksToBounds = true
self.contentView.addSubview(bgImageView)
bgImageView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
bgImageView.addSubview(iconImageView)
iconImageView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(7)
make.centerX.equalToSuperview()
make.size.equalTo(CGSizeMake(30, 30))
}
nameLabel.font = .fus_themeFont(11)
nameLabel.textColor = .fus_textColorRich()
bgImageView.addSubview(nameLabel)
nameLabel.snp.makeConstraints { make in
make.top.equalTo(iconImageView.snp.bottom).offset(4)
make.centerX.equalToSuperview()
}
costBtn.titleLabel?.font = .fus_themeMediumFont(12)
bgImageView.addSubview(costBtn)
costBtn.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(nameLabel.snp.bottom).offset(0)
make.height.equalTo(18)
}
costBtn.imageView?.snp.makeConstraints { make in
make.size.equalTo(CGSizeMake(12, 12))
}
}
public func fus_setup(model: FUSPatAudienceGiftModel) {
if model.fus_modelType == -1 {
iconImageView.image = FUSShowRoomCenterBunble.imageNamed("live_chat_patAudience_gift_follow")
nameLabel.text = .fus_versionLocalString("关注")
costBtn.setImage(nil, for: .normal)
costBtn.setTitle(.fus_versionLocalString("免费"), for: .normal)
costBtn.setTitleColor(.fus_textColorMedium(), for: .normal)
}else if model.fus_modelType == 0 {
iconImageView.setWebImageWithSubURLString(model.giftUrl)
nameLabel.text = model.giftName
costBtn.setImage(fus_getCurrencyImage(giftCurrency: model.giftCurrency), for: .normal)
costBtn.setTitle(" \(model.giftPrice)", for: .normal)
costBtn.setTitleColor(.fus_theme(), for: .normal)
}
}
func fus_getCurrencyImage(giftCurrency: Int) -> UIImage? {
switch giftCurrency{
case 3:
return .fus_diamonIcon()
case 5:
return .fus_dewIcon()
case 6:
return .fus_diamonIcon()
default:
return nil
}
}
}
//
// FUSPatAudiencePromptAlertView.h
// FUSShowRoomModule
//
// Created by aaa on 2024/9/25.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface FUSPatAudiencePromptAlertView : UIView
+(FUSPatAudiencePromptAlertView *)fus_showWithData:(NSDictionary *)dataDict showOn:(UIView * _Nullable )onView;
-(void)fus_dismissWithAnimation;
@end
NS_ASSUME_NONNULL_END
...@@ -364,6 +364,12 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -364,6 +364,12 @@ NS_ASSUME_NONNULL_BEGIN
/// 设置新人7天签到提醒 /// 设置新人7天签到提醒
+ (NSString *)fus_URL_USER_NOVICE_CHECKIN_REMIND_SET; + (NSString *)fus_URL_USER_NOVICE_CHECKIN_REMIND_SET;
/// 回拍 类型(1:关注、2:送礼)
+ (NSString *)fus_URL_LIVE_PAT_REPLY;
/// 拍一拍用户
+ (NSString *)fus_URL_LIVE_PAT_USER;
@end @end
......
...@@ -489,6 +489,14 @@ ...@@ -489,6 +489,14 @@
+ (NSString *)fus_URL_GET_IM_SEND_CHAT_RESULT { + (NSString *)fus_URL_GET_IM_SEND_CHAT_RESULT {
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/imchat/getInSendChatResult.html"]; return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/imchat/getInSendChatResult.html"];
} }
/// 回拍 类型(1:关注、2:送礼)
+ (NSString *)fus_URL_LIVE_PAT_REPLY{
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/live/pat/reply"];
}
/// 拍一拍用户
+ (NSString *)fus_URL_LIVE_PAT_USER{
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/live/pat/user"];
}
#pragma mark -- PK #pragma mark -- PK
// 房间PK信息 // 房间PK信息
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
<key>FUSUserCenterModule.xcscheme_^#shared#^_</key> <key>FUSUserCenterModule.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>75</integer> <integer>76</integer>
</dict> </dict>
<key>FUSUserCenterModuleBundle.xcscheme_^#shared#^_</key> <key>FUSUserCenterModuleBundle.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>76</integer> <integer>72</integer>
</dict> </dict>
</dict> </dict>
</dict> </dict>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment