新用户进入房间自动打招呼

This commit is contained in:
fengshuo
2022-06-07 16:16:27 +08:00
parent f3778b4c63
commit e74ac4c211
20 changed files with 195 additions and 59 deletions

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_new_user_greet_bg@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_new_user_greet_bg@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_new_user_greet_new@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_new_user_greet_new@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 938 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -51,7 +51,9 @@ typedef NS_ENUM(NSInteger, UserEnterRoomFromType) {
///赛事详情
UserEnterRoomFromType_Follow_Game_Detail = 8,
///跨房PK
UserEnterRoomFromType_Cross_Room_PK = 9
UserEnterRoomFromType_Cross_Room_PK = 9,
///新用户打招呼
UserEnterRoomFromType_New_User_Greet = 10
};
typedef NS_ENUM(NSInteger, LittleGamePlayStatus) {
LittleGamePlayStatus_NoIn = 0,//未加入

View File

@@ -240,6 +240,7 @@
XPMessageRemoteExtModel *extModel = [[XPMessageRemoteExtModel alloc] init];
extModel.androidBubbleUrl = userInfo.androidBubbleUrl;
extModel.iosBubbleUrl = userInfo.iosBubbleUrl;
extModel.fromSayHelloChannel = userInfo.fromSayHelloChannel;
NSMutableDictionary *remoteExt = [NSMutableDictionary dictionaryWithObject:extModel.model2dictionary forKey:[NSString stringWithFormat:@"%ld", userInfo.uid]];
message.remoteExt = remoteExt;
NIMSessionType sessionType = self.usingplaceType == SendGiftType_Room ? NIMSessionTypeChatroom : NIMSessionTypeP2P;

View File

@@ -49,10 +49,6 @@ NS_ASSUME_NONNULL_BEGIN
/// 获取房间超管列表
/// @param roomUid 房间的uid
- (void)getRoomSuperAdmin:(NSString *)roomUid;
///获取新用户打招呼成功
- (void)getNewUserStartGreet:(NSString *)roomUid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -80,6 +80,7 @@
extModel.preventKick = userInfo.userVipInfoVO.preventKick;
extModel.enterRoomEffects = userInfo.userVipInfoVO.enterRoomEffects;
extModel.gender = userInfo.gender;
extModel.fromSayHelloChannel = userInfo.fromSayHelloChannel;
NSMutableDictionary *ext = [NSMutableDictionary dictionaryWithObject:extModel.model2dictionary forKey:[NSString stringWithFormat:@"%ld", userInfo.uid]];
request.roomExt = [ext toJSONString];
@@ -200,13 +201,4 @@
[[self getView] getRoomSuperAdminScuccess:array];
}] roomUid:roomUid];
}
///
- (void)getNewUserStartGreet:(NSString *)roomUid {
[Api newUserStartGreet:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
RoomNewUserGreetModel * info = [RoomNewUserGreetModel modelWithDictionary:data.data];
[[self getView] getNewUserStartGreetSuccess:info];
}] roomUid:roomUid];
}
@end

View File

@@ -10,7 +10,7 @@
NS_ASSUME_NONNULL_BEGIN
@class RoomInfoModel;
@class UserInfoModel, NIMChatroom, RoomNewUserGreetModel;
@class UserInfoModel, NIMChatroom;
@protocol XPRoomProtocol <NSObject>
@@ -23,9 +23,6 @@ NS_ASSUME_NONNULL_BEGIN
- (void)enterRoomFail:(NSInteger)code;
///获取超管成功
- (void)getRoomSuperAdminScuccess:(NSArray *)list;
///获取新用户打招呼信息成功
- (void)getNewUserStartGreetSuccess:(RoomNewUserGreetModel *)info;
@end
NS_ASSUME_NONNULL_END

View File

@@ -28,6 +28,7 @@
#import "RtcManager.h"
#import "XPRoomMiniManager.h"
#import "Api+RoomPK.h"
#import "Api+Room.h"
///Model
#import "RoomInfoModel.h"
#import "MicroQueueModel.h"
@@ -45,6 +46,7 @@
#import "GiftReceiveInfoModel.h"
#import "GiftInfoModel.h"
#import "RoomPKTeamModel.h"
#import "RoomNewUserGreetModel.h"
///View
#import "XPRoomHalfWebView.h"
#import "XPAnchorAudienceUpMicView.h"
@@ -70,6 +72,8 @@
#import "XPRoomRankEntranceView.h"
#import "XPRoomAnchorRankEnterView.h"
#import "XPRoomBackMusicPlayerView.h"
#import "XPRoomNewUserGreetView.h"
#import "XPRoomHalfMessageView.h"
///PK
#import "XPAnchorFansTeamEntranceView.h"
#import "XPAnchorFansTeamViewController.h"
@@ -78,7 +82,7 @@
#import "XPWebViewController.h"
#import "XPRoomPKProgressView.h"
@interface XPRoomFunctionContainerView ()<XPAcrpssRoomPKPanelViewDelegate, XPRoomLittleGameListViewDelegate, XPAnchorPkPanelViewDelegate, XPRoomBackMusicPlayerViewDelegate>
@interface XPRoomFunctionContainerView ()<XPAcrpssRoomPKPanelViewDelegate, XPRoomLittleGameListViewDelegate, XPAnchorPkPanelViewDelegate, XPRoomBackMusicPlayerViewDelegate, XPRoomNewUserGreetViewDelegate>
///host
@property (nonatomic,weak) id<RoomHostDelegate>delegate;
///
@@ -310,6 +314,41 @@
return isGamePlaying;
}
#pragma mark -
- (void)handleNewUserGreet {
if (self.delegate.getUserInfo.fromType == UserEnterRoomFromType_New_User_Greet) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid];
[Api newUserStartGreet:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
RoomNewUserGreetModel * info = [RoomNewUserGreetModel modelWithDictionary:data.data];
if (info.roomPopup) {
XPRoomNewUserGreetView * greetView = [[XPRoomNewUserGreetView alloc] initWithFrame:CGRectMake(KScreenWidth, kSafeAreaTopHeight + 52, KScreenWidth, 80)];
greetView.delegate = self;
greetView.sayHelloUserAvatarList = info.sayHelloUserAvatarList;
[self addSubview:greetView];
[UIView animateWithDuration:.35 animations:^{
CGRect rect = greetView.frame;
rect.origin.x = 0;
greetView.frame = rect;
} completion:nil];
}
}
} roomUid:roomUid];
});
}
}
- (void)xPRoomNewUserGreetView:(XPRoomNewUserGreetView *)view didClickCheckout:(UIButton *)sender {
XPRoomHalfMessageView *halfMessageView = [[XPRoomHalfMessageView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight)];
[self addSubview:halfMessageView];
[UIView animateWithDuration:.35 animations:^{
CGRect rect = halfMessageView.frame;
rect.origin.y = 0;
halfMessageView.frame = rect;
}];
}
#pragma mark - PK
- (void)configRoomPKPanelView:(BOOL)isEnter {
RoomInfoModel * roomInfo = self.delegate.getRoomInfo;
@@ -473,6 +512,7 @@
[self showLittleGameMiniView:roomInfo.type micCount:roomInfo.mgMicNum];
[self configLittleGameState];
[self configRoomPKPanelView:YES];
[self handleNewUserGreet];
}
- (void)onRoomMiniEntered {

View File

@@ -77,6 +77,7 @@
extModel.vipIcon = userInfo.userVipInfoVO.vipIcon;
extModel.androidBubbleUrl = userInfo.androidBubbleUrl;
extModel.iosBubbleUrl = userInfo.iosBubbleUrl;
extModel.fromSayHelloChannel = userInfo.fromSayHelloChannel;
NIMMessage * message = [[NIMMessage alloc] init];
message.text = self.inputMessage;

View File

@@ -50,6 +50,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy) NSString *enterRoomEffects;
///性别
@property (nonatomic, assign) GenderType gender;
///是否符合渠道打招呼
@property (nonatomic,assign) BOOL fromSayHelloChannel;
@end
NS_ASSUME_NONNULL_END

View File

@@ -118,12 +118,14 @@
if ([message.from isEqualToString:uid]) {
nick = @"我:";
}
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
///
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:model.defUser newUser:model.newUser fromSayHelloChannel:model.fromSayHelloChannel]];
if ([self isCurrentRoomSuperAdmin:message.from]) {
[attribute appendAttributedString:[self createLocalImageAttribute:@"common_super_admin"]];
}
///
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:model.defUser newUser:model.newUser]];
if (model.vipIcon) {//icon
[attribute appendAttributedString:[self createUrlImageAttribute:model.vipIcon]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
@@ -202,6 +204,9 @@
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
NSDictionary * dic = [(NSDictionary *)messageExt.roomExt.toJSONObject objectForKey:message.from];
XPMessageRemoteExtModel * extModel = [XPMessageRemoteExtModel modelWithDictionary:dic];
///
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:extModel.defUser newUser:extModel.newUser fromSayHelloChannel:extModel.fromSayHelloChannel]];
if ([self isCurrentRoomSuperAdmin:message.from]) {
[attribute appendAttributedString:[self createLocalImageAttribute:@"common_super_admin"]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
@@ -229,7 +234,7 @@
if (extModel.fromType > 0) {
if (extModel.fromType == UserEnterRoomFromType_Home_Recommend) {
[attribute appendAttributedString:[self createTextAttribute:@"根据首页推荐" color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]];
} else if(extModel.fromType == UserEnterRoomFromType_Follow_User) {
} else if(extModel.fromType == UserEnterRoomFromType_Follow_User || extModel.fromType == UserEnterRoomFromType_New_User_Greet) {
[attribute appendAttributedString:[self createTextAttribute:@"跟随" color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createNickAtrribute:extModel.fromNick uid:extModel.fromUid.integerValue]];
} else if(extModel.fromType == UserEnterRoomFromType_Follow_Game_Detail) {
@@ -685,7 +690,7 @@
giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:info.giftId];
}
///
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:sendInfo.defUser newUser:sendInfo.newUser]];
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:sendInfo.defUser newUser:sendInfo.newUser fromSayHelloChannel:sendInfo.fromSayHelloChannel]];
//nick
[attribute appendAttributedString:[self createNickAtrribute:info.nick uid:info.uid.integerValue]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
@@ -778,7 +783,7 @@
giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:info.giftId];
}
///
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:sendInfo.defUser newUser:sendInfo.newUser]];
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:sendInfo.defUser newUser:sendInfo.newUser fromSayHelloChannel:sendInfo.fromSayHelloChannel]];
//nick
[attribute appendAttributedString:[self createNickAtrribute:info.nick uid:info.uid.integerValue]];
[attribute appendAttributedString:[self createSapceAttribute:2]];;
@@ -840,7 +845,7 @@
return NO;
}
- (NSAttributedString *)createOfficalAndNewuserAttribute:(UserLevelType)levelType newUser:(BOOL)newUser {
- (NSAttributedString *)createOfficalAndNewuserAttribute:(UserLevelType)levelType newUser:(BOOL)newUser fromSayHelloChannel:(BOOL)fromSayHelloChannel{
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
//offical
if (levelType == UserLevelType_Offical) {
@@ -848,8 +853,13 @@
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
if (newUser) {
[attribute appendAttributedString: [self createLocalImageAttribute:@"common_new_user"]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
if (fromSayHelloChannel) {
[attribute appendAttributedString:[self createLocalImageAttribute:@"room_new_user_greet_new"]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
} else {
[attribute appendAttributedString: [self createLocalImageAttribute:@"common_new_user"]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
}
return attribute;
}

View File

@@ -8,9 +8,17 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPRoomNewUserGreetView : UIView
@class XPRoomNewUserGreetView;
@protocol XPRoomNewUserGreetViewDelegate <NSObject>
///点击查看
- (void)xPRoomNewUserGreetView:(XPRoomNewUserGreetView *)view didClickCheckout:(UIButton *)sender;
@end
@interface XPRoomNewUserGreetView : UIView
@property (nonatomic,strong) NSArray<NSString *> *sayHelloUserAvatarList;
///代理
@property (nonatomic,weak) id<XPRoomNewUserGreetViewDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -11,13 +11,11 @@
///Tool
#import "ThemeColor.h"
#import "NetImageView.h"
#import "XPMacro.h"
@interface XPRoomNewUserGreetView ()
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UIStackView *avatarStackView;
///
@property (nonatomic,strong) NetImageView *firstAvatarView;
///
@@ -30,6 +28,7 @@
@property (nonatomic,strong) UIButton *checkButton;
///
@property (nonatomic,strong) UIButton *closeButton;
@property (nonatomic,strong) NSArray<NetImageView *> *avatarViewList;
@end
@implementation XPRoomNewUserGreetView
@@ -45,43 +44,94 @@
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.backImageView];
[self.backImageView addSubview:self.firstAvatarView];
[self.backImageView addSubview:self.secondAvatarView];
[self.backImageView addSubview:self.thirdAvatarView];
[self.backImageView addSubview:self.titleLabel];
[self.backImageView addSubview:self.checkButton];
[self.backImageView addSubview:self.closeButton];
self.avatarViewList = @[self.firstAvatarView, self.secondAvatarView, self.thirdAvatarView];
}
- (void)initSubViewConstraints {
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(345, 80));
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(self);
}];
[self.firstAvatarView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(44, 44));
make.left.mas_equalTo(self.backImageView).offset(13);
make.centerY.mas_equalTo(self.backImageView);
}];
[self.secondAvatarView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerY.mas_equalTo(self.firstAvatarView);
make.left.mas_equalTo(self.firstAvatarView.mas_right).offset(-6);
}];
[self.thirdAvatarView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.centerY.mas_equalTo(self.firstAvatarView);
make.left.mas_equalTo(self.secondAvatarView.mas_right).offset(-6);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.thirdAvatarView.mas_right).offset(12);
make.top.mas_equalTo(self.firstAvatarView);
}];
[self.checkButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(80, 20));
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(8);
make.centerX.mas_equalTo(self.titleLabel);
}];
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(22, 22));
make.top.right.mas_equalTo(self.backImageView);
}];
}
#pragma mark - Event Response
- (void)closeButtonAction:(UIButton *)sender {
[UIView animateWithDuration:.35 animations:^{
CGRect frame = self.frame;
frame.origin.x = -KScreenWidth;
self.frame= frame;
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
- (void)checkButtonAction:(UIButton *)sender {
[self closeButtonAction:sender];
if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomNewUserGreetView:didClickCheckout:)]) {
[self.delegate xPRoomNewUserGreetView:self didClickCheckout:sender];
}
}
#pragma mark - Getters And Setters
- (void)setSayHelloUserAvatarList:(NSArray<NSString *> *)sayHelloUserAvatarList {
for (int i = 0; i < sayHelloUserAvatarList.count; i++) {
NSString * avatar = [sayHelloUserAvatarList objectAtIndex:i];
if (i < self.avatarViewList.count) {
NetImageView * imageView = [self.avatarViewList objectAtIndex:i];
imageView.imageUrl = avatar;
}
}
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@""];
_backImageView.image = [UIImage imageNamed:@"room_new_user_greet_bg"];
}
return _backImageView;
}
- (UIStackView *)avatarStackView {
if (!_avatarStackView) {
_avatarStackView = [[UIStackView alloc] init];
_avatarStackView.axis = UILayoutConstraintAxisHorizontal;
_avatarStackView.distribution = UIStackViewDistributionFill;
_avatarStackView.alignment = UIStackViewAlignmentFill;
_avatarStackView.spacing = 10;
}
return _avatarStackView;
}
- (NetImageView *)firstAvatarView {
if (!_firstAvatarView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
@@ -154,8 +204,8 @@
- (UIButton *)closeButton {
if (!_closeButton) {
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_closeButton setImage:[UIImage imageNamed:@"icon_unattention"] forState:UIControlStateNormal];
[_closeButton setImage:[UIImage imageNamed:@"icon_small_attention"] forState:UIControlStateSelected];
[_closeButton setImage:[UIImage imageNamed:@"room_setting_tag_close"] forState:UIControlStateNormal];
[_closeButton setImage:[UIImage imageNamed:@"room_setting_tag_close"] forState:UIControlStateSelected];
[_closeButton addTarget:self action:@selector(closeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _closeButton;

View File

@@ -105,7 +105,7 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
return [self openRoom:roomUid fromNick:nil fromType:0 fromUid:nil viewController:viewController];
}
+ (BOOL)openRoom:(NSString*)roomUid fromNick:(NSString * __nullable)fromNick fromType:(UserEnterRoomFromType)fromType fromUid:(NSString * __nullable)fromUid viewController:(UIViewController*)viewController {
+ (BOOL) openRoom:(NSString*)roomUid fromNick:(NSString * __nullable)fromNick fromType:(UserEnterRoomFromType)fromType fromUid:(NSString * __nullable)fromUid viewController:(UIViewController*)viewController {
XPRoomViewController * roomVC = [[self alloc] init];
roomVC.roomUid = roomUid;
roomVC.fromUid = fromUid;
@@ -521,9 +521,6 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
[[XPRoomMiniManager shareManager] configUserInfo:nil];
[[XPRoomMiniManager shareManager] configCurrentMusic:nil isPlaying:NO];
}
if (userInfo.fromSayHelloChannel) {///
[self.presenter getNewUserStartGreet:[NSString stringWithFormat:@"%ld", roomInfo.uid]];
}
} else { //
if ([self.roomUid isEqualToString:[NSString stringWithFormat:@"%ld", userInfo.uid]]) { //
if (roomInfo.roomId > 0) { // 使
@@ -583,11 +580,6 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
self.isRequestSuperAdmin = YES;
self.superMangerList = list;
}
- (void)getNewUserStartGreetSuccess:(RoomNewUserGreetModel *)info {
}
#pragma mark - NIMChatroomManagerDelegate
- (void)chatroomBeKicked:(NIMChatroomBeKickedResult *)result {
if (result.reason == 2) {

View File

@@ -337,6 +337,7 @@ NSString * const kUserFirstLoginKey = @"kUserFirstLoginKey";
#pragma mark -
- (void)initQuickEnterRoom {
BOOL isNotFirstLogin = [[NSUserDefaults standardUserDefaults] boolForKey:kUserFirstLoginKey];
isNotFirstLogin = NO;
if (isNotFirstLogin) {
[self.presenter getShortCutRecommendRoom];
} else {

View File

@@ -121,7 +121,7 @@
- (void)startButtonAction:(UIButton *)sender {
[TTPopup dismiss];
if (self.greetInfo.roomUid.length > 0) {
[XPRoomViewController openRoom:self.greetInfo.roomUid fromNick:self.greetInfo.sayHelloUserNickname fromType:UserEnterRoomFromType_Follow_User fromUid:self.greetInfo.roomUid viewController:self.currentVC];
[XPRoomViewController openRoom:self.greetInfo.roomUid fromNick:self.greetInfo.sayHelloUserNickname fromType:UserEnterRoomFromType_New_User_Greet fromUid:self.greetInfo.roomUid viewController:self.currentVC];
}
}