消息模块-送礼物消息

This commit is contained in:
fengshuo
2022-04-21 20:06:43 +08:00
parent bbca6afefc
commit 181d34c2e6
5 changed files with 50 additions and 7 deletions

View File

@@ -59,6 +59,8 @@
@property (nonatomic,assign) int normalGiftRetryCount;
///
@property (nonatomic,assign) int packGiftRetryCount;
///
@property (nonatomic,strong) NSArray<XPGiftUserInfoModel *> *userArray;
@end
@implementation XPSendGiftView
@@ -71,7 +73,7 @@
NSLog(@"六面板销毁了");
}
- (instancetype)initWithType:(SendGiftType)type uid:(NSString *)uid{
- (instancetype)initWithType:(SendGiftType)type uid:(NSString * __nullable)uid{
if (self = [super init]) {
self.modalPresentationStyle = UIModalPresentationOverFullScreen;
self.roomUid = uid;
@@ -227,7 +229,8 @@
}
- (void)sendCustomMessage:(AttachmentModel *)attachment {
NSString *sessionID = [NSString stringWithFormat:@"%ld", [self.delegate getRoomInfo].roomId];
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];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachment;
@@ -239,9 +242,9 @@
extModel.iosBubbleUrl = userInfo.iosBubbleUrl;
NSMutableDictionary *remoteExt = [NSMutableDictionary dictionaryWithObject:extModel.model2dictionary forKey:[NSString stringWithFormat:@"%ld", userInfo.uid]];
message.remoteExt = remoteExt;
NIMSessionType sessionType = self.usingplaceType == SendGiftType_Room ? NIMSessionTypeChatroom : NIMSessionTypeP2P;
//
NIMSession *session = [NIMSession session:sessionID type:NIMSessionTypeChatroom];
NIMSession *session = [NIMSession session:sessionID type:sessionType];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
}
@@ -292,6 +295,7 @@
#pragma mark - Public Method
- (void)configGiftUsers:(NSArray<XPGiftUserInfoModel *> *)users {
self.userArray = users;
[self.userView configGiftUsers:users];
}
#pragma mark - XPGiftBarViewDelegate
@@ -323,6 +327,21 @@
[self showErrorToast:@"请选择至少一个人"];
return;
}
} else if(self.usingplaceType == SendGiftType_User) {
///
NSString * uidString = [self dealSendGiftUids:uids];
///
NSString * giftNumber = [self dealSendGiftCount:giftCount gift:giftInfo];
///
NSString * giftId = [NSString stringWithFormat:@"%ld", giftInfo.giftId];
///
GiftSendType sendType = GiftSendType_Chat;
///
GiftSourceType sourceType = giftInfo.sourceType;
///
RoomSendGiftType roomSendType = RoomSendGiftType_ToOne;
self.giftBarView.sendButtonIsEnable = NO;
[self.presenter sendGift:uidString giftNum:giftNumber sendType:sendType giftId:giftId giftSource:sourceType giftType:giftInfo.giftType roomSendType:roomSendType roomUid:self.roomUid msg:@""];
}
}
@@ -452,6 +471,11 @@
self.giftInfoView.curUserNobleLevel = self.delegate.getUserInfo.userVipInfoVO.vipLevel;
}
- (void)setUsingplaceType:(SendGiftType)usingplaceType {
_usingplaceType = usingplaceType;
self.giftInfoView.usingplaceType = _usingplaceType;
}
- (UIView *)topView {
if (!_topView) {
_topView = [[UIView alloc] init];