消息模块-送礼物消息
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#import "SessionToolbarView.h"
|
||||
#import "MessageCell.h"
|
||||
#import "SessionChatLimitView.h"
|
||||
#import "XPSendGiftView.h"
|
||||
///P
|
||||
#import "MessagePresenter.h"
|
||||
#import "MessageProtocol.h"
|
||||
@@ -298,6 +299,16 @@
|
||||
}
|
||||
break;
|
||||
case MessageMenuType_Gift:
|
||||
{
|
||||
XPSendGiftView * giftView = [[XPSendGiftView alloc] initWithType:SendGiftType_User uid:nil];
|
||||
XPGiftUserInfoModel * userModel = [[XPGiftUserInfoModel alloc] init];
|
||||
userModel.avatar = self.userInfo.avatar;
|
||||
userModel.nick = self.userInfo.nick;
|
||||
userModel.uid = self.session.sessionId.integerValue;
|
||||
userModel.isSelect = YES;
|
||||
[giftView configGiftUsers:@[userModel]];
|
||||
[self presentViewController:giftView animated:YES completion:nil];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "XPGiftInfoView.h"
|
||||
#import "XPSendGiftView.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSInteger, GiftSegmentType) {
|
||||
@@ -37,7 +37,8 @@ typedef NS_ENUM(NSInteger, GiftSegmentType) {
|
||||
@end
|
||||
|
||||
@interface XPGiftInfoView : UIView
|
||||
|
||||
///使用的地方
|
||||
@property (nonatomic,assign) SendGiftType usingplaceType;
|
||||
///普通礼物/幸运礼物/贵族礼物
|
||||
@property (nonatomic,strong) NSArray *normalOriginArray;
|
||||
///背包礼物
|
||||
|
@@ -380,6 +380,13 @@
|
||||
[self.giftcollectionView reloadData];
|
||||
}
|
||||
|
||||
- (void)setUsingplaceType:(SendGiftType)usingplaceType {
|
||||
_usingplaceType = usingplaceType;
|
||||
if (_usingplaceType == SendGiftType_User) {
|
||||
self.luckyGiftButton.hidden = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (UIStackView *)segmentStackView {
|
||||
if (!_segmentStackView) {
|
||||
_segmentStackView = [[UIStackView alloc] init];
|
||||
|
@@ -20,7 +20,7 @@ typedef NS_ENUM(NSInteger, SendGiftType) {
|
||||
/// 送礼物的
|
||||
/// @param type 送礼物的类型
|
||||
/// @param uid 送礼物的人
|
||||
- (instancetype)initWithType:(SendGiftType)type uid:(NSString *)uid;
|
||||
- (instancetype)initWithType:(SendGiftType)type uid:(NSString * __nullable)uid;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
+ (instancetype)new NS_UNAVAILABLE;
|
||||
|
@@ -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];
|
||||
|
Reference in New Issue
Block a user