2021-11-10 18:42:27 +08:00
|
|
|
|
//
|
|
|
|
|
// XPSendGiftView.m
|
|
|
|
|
// xplan-ios
|
|
|
|
|
//
|
|
|
|
|
// Created by 冯硕 on 2021/11/9.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "XPSendGiftView.h"
|
|
|
|
|
///Third
|
|
|
|
|
#import <Masonry/Masonry.h>
|
2021-11-16 19:56:37 +08:00
|
|
|
|
#import <NIMSDK/NIMSDK.h>
|
2022-08-22 20:07:36 +08:00
|
|
|
|
#import <UIImageView+WebCache.h>
|
2021-11-10 18:42:27 +08:00
|
|
|
|
///Tool
|
|
|
|
|
#import "XPMacro.h"
|
2021-11-11 18:39:12 +08:00
|
|
|
|
#import "XPGiftPresenter.h"
|
2021-11-15 18:59:44 +08:00
|
|
|
|
#import "TTPopup.h"
|
2021-11-10 18:42:27 +08:00
|
|
|
|
#import "ThemeColor+SendGift.h"
|
2022-01-11 11:28:04 +08:00
|
|
|
|
#import "StatisticsServiceHelper.h"
|
2022-05-07 17:58:15 +08:00
|
|
|
|
#import "XPHtmlUrl.h"
|
2022-06-14 17:44:24 +08:00
|
|
|
|
#import "AccountInfoStorage.h"
|
2022-11-11 17:46:37 +08:00
|
|
|
|
#import "NSArray+Safe.h"
|
2023-01-06 14:07:30 +08:00
|
|
|
|
#import "ClientConfig.h"
|
2022-12-07 15:05:14 +08:00
|
|
|
|
#import "XCCurrentVCStackManager.h"
|
2021-11-16 16:31:24 +08:00
|
|
|
|
///Model
|
|
|
|
|
#import "GiftInfoModel.h"
|
|
|
|
|
#import "XPGiftCountModel.h"
|
|
|
|
|
#import "GiftReceiveInfoModel.h"
|
2021-11-16 19:56:37 +08:00
|
|
|
|
#import "AttachmentModel.h"
|
|
|
|
|
#import "RoomInfoModel.h"
|
2021-12-24 16:36:17 +08:00
|
|
|
|
#import "UserInfoModel.h"
|
2022-04-07 15:28:57 +08:00
|
|
|
|
#import "XPMessageRemoteExtModel.h"
|
2021-11-10 18:42:27 +08:00
|
|
|
|
///View
|
|
|
|
|
#import "XPGiftUsersView.h"
|
|
|
|
|
#import "XPGiftInfoView.h"
|
|
|
|
|
#import "XPGiftBarView.h"
|
2022-06-14 19:21:25 +08:00
|
|
|
|
#import "XPRoomHalfWebView.h"
|
2022-08-22 20:07:36 +08:00
|
|
|
|
#import "XPGraffitiGiftView.h"
|
2022-09-29 18:39:08 +08:00
|
|
|
|
#import "XPGiftHeadTypeView.h"
|
2022-10-08 19:01:20 +08:00
|
|
|
|
#import "XPGiftLuckyGiftBroadcastView.h"
|
2022-12-07 15:05:14 +08:00
|
|
|
|
#import "XPGiftTwelveStarBroadcastView.h"
|
2021-11-11 18:39:12 +08:00
|
|
|
|
///P
|
|
|
|
|
#import "XPGiftProtocol.h"
|
2021-11-15 18:59:44 +08:00
|
|
|
|
///VC
|
2022-06-08 20:20:25 +08:00
|
|
|
|
#import "XPMineHalfRechargeViewController.h"
|
2021-11-15 18:59:44 +08:00
|
|
|
|
#import "XPWebViewController.h"
|
2021-12-24 16:36:17 +08:00
|
|
|
|
#import "XPFirstRechargeViewController.h"
|
2022-01-07 15:58:18 +08:00
|
|
|
|
#import "XPNobleCenterViewController.h"
|
2021-11-10 18:42:27 +08:00
|
|
|
|
|
2022-12-07 15:05:14 +08:00
|
|
|
|
@interface XPSendGiftView ()< XPGiftBarViewDelegate, XPGiftProtocol, XPGiftInfoViewDelegate, XPGraffitiGiftViewDelegate, XPGiftUsersViewDelegate, XPGiftHeadTypeViewDelegate, XPGiftLuckyGiftBroadcastViewDelegate, XPGiftTwelveStarBroadcastViewDelegate>
|
2022-03-22 20:53:20 +08:00
|
|
|
|
///顶部的区域
|
|
|
|
|
@property (nonatomic,strong) UIView * topView;
|
|
|
|
|
///内容区域
|
|
|
|
|
@property (nonatomic,strong) UIView *contentView;
|
2022-10-08 19:01:20 +08:00
|
|
|
|
///模糊背景
|
|
|
|
|
@property (nonatomic, strong) UIVisualEffectView *effectView;
|
2021-11-10 18:42:27 +08:00
|
|
|
|
///
|
|
|
|
|
@property (nonatomic,strong) UIStackView *stackView;
|
2022-10-08 19:01:20 +08:00
|
|
|
|
///幸运礼物广播
|
|
|
|
|
@property (nonatomic, strong) XPGiftLuckyGiftBroadcastView *luckyBroadcastView;
|
2022-12-07 15:05:14 +08:00
|
|
|
|
///星座礼物广播
|
|
|
|
|
@property (nonatomic, strong) XPGiftTwelveStarBroadcastView *constellationBanner;
|
2022-09-29 18:39:08 +08:00
|
|
|
|
///礼物类型(普通/互动)
|
|
|
|
|
@property (nonatomic, strong) XPGiftHeadTypeView *headTypeView;
|
2021-11-10 18:42:27 +08:00
|
|
|
|
///送礼物的人
|
|
|
|
|
@property (nonatomic,strong) XPGiftUsersView *userView;
|
|
|
|
|
///送的什么礼物
|
|
|
|
|
@property (nonatomic,strong) XPGiftInfoView *giftInfoView;
|
|
|
|
|
///送多少礼物
|
|
|
|
|
@property (nonatomic,strong) XPGiftBarView *giftBarView;
|
2022-03-25 15:05:15 +08:00
|
|
|
|
///底部的View
|
|
|
|
|
@property (nonatomic,strong) UIView * bottomView;
|
2022-08-22 20:07:36 +08:00
|
|
|
|
///涂鸦礼物
|
|
|
|
|
@property (nonatomic,strong) XPGraffitiGiftView *graffitiView;
|
2022-06-14 17:44:24 +08:00
|
|
|
|
///房主的uid/私聊的话 就是用户的uid
|
2021-11-11 18:39:12 +08:00
|
|
|
|
@property (nonatomic,copy) NSString *roomUid;
|
2021-11-16 16:31:24 +08:00
|
|
|
|
///使用的地方
|
|
|
|
|
@property (nonatomic,assign) SendGiftType usingplaceType;
|
2022-03-22 20:53:20 +08:00
|
|
|
|
///普通礼物的重试次数
|
|
|
|
|
@property (nonatomic,assign) int normalGiftRetryCount;
|
|
|
|
|
///背包礼物的重试次数
|
|
|
|
|
@property (nonatomic,assign) int packGiftRetryCount;
|
2022-04-21 20:06:43 +08:00
|
|
|
|
@property (nonatomic,strong) NSArray<XPGiftUserInfoModel *> *userArray;
|
2022-08-23 18:01:34 +08:00
|
|
|
|
///涂鸦礼物的坐标
|
|
|
|
|
@property (nonatomic,strong) NSArray *graffitiPoint;
|
|
|
|
|
///选择了滑块的类型
|
|
|
|
|
@property (nonatomic,assign) GiftSegmentType segmentType;
|
2022-10-17 19:51:34 +08:00
|
|
|
|
///福袋礼物全服记录
|
|
|
|
|
@property (nonatomic,strong) NSArray *records;
|
2021-11-10 18:42:27 +08:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation XPSendGiftView
|
2022-03-25 15:05:15 +08:00
|
|
|
|
|
|
|
|
|
- (XPGiftPresenter *)createPresenter {
|
|
|
|
|
return [[XPGiftPresenter alloc] init];
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-10 18:42:27 +08:00
|
|
|
|
|
2022-04-21 20:06:43 +08:00
|
|
|
|
- (instancetype)initWithType:(SendGiftType)type uid:(NSString * __nullable)uid{
|
2021-11-10 18:42:27 +08:00
|
|
|
|
if (self = [super init]) {
|
2022-03-22 20:53:20 +08:00
|
|
|
|
self.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
2021-11-11 18:39:12 +08:00
|
|
|
|
self.roomUid = uid;
|
2021-11-16 16:31:24 +08:00
|
|
|
|
self.usingplaceType = type;
|
2021-11-10 18:42:27 +08:00
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-22 20:53:20 +08:00
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
[self initSubViews];
|
|
|
|
|
[self initSubViewConstraints];
|
|
|
|
|
[self initHttpRequest];
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-10 18:42:27 +08:00
|
|
|
|
#pragma mark - Private Method
|
|
|
|
|
- (void)initSubViews {
|
2022-03-22 20:53:20 +08:00
|
|
|
|
[self.view addSubview:self.topView];
|
2022-10-08 19:01:20 +08:00
|
|
|
|
[self.view addSubview:self.contentView];
|
|
|
|
|
[self.contentView addSubview:self.effectView];
|
2022-03-22 20:53:20 +08:00
|
|
|
|
[self.contentView addSubview:self.stackView];
|
2022-08-22 20:07:36 +08:00
|
|
|
|
[self.stackView addArrangedSubview:self.graffitiView];
|
2022-09-29 18:39:08 +08:00
|
|
|
|
[self.stackView addArrangedSubview:self.headTypeView];
|
2021-11-10 18:42:27 +08:00
|
|
|
|
[self.stackView addArrangedSubview:self.userView];
|
|
|
|
|
[self.stackView addArrangedSubview:self.giftInfoView];
|
|
|
|
|
[self.stackView addArrangedSubview:self.giftBarView];
|
2022-03-25 15:05:15 +08:00
|
|
|
|
[self.stackView addArrangedSubview:self.bottomView];
|
2021-11-10 18:42:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)initSubViewConstraints {
|
2022-03-22 20:53:20 +08:00
|
|
|
|
[self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.right.top.mas_equalTo(self.view);
|
|
|
|
|
make.bottom.mas_equalTo(self.contentView.mas_top);;
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.top.mas_equalTo(self.stackView.mas_top);
|
|
|
|
|
make.left.right.bottom.mas_equalTo(self.view);
|
2021-11-10 18:42:27 +08:00
|
|
|
|
}];
|
|
|
|
|
|
2022-10-08 19:01:20 +08:00
|
|
|
|
[self.effectView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.edges.mas_equalTo(self.contentView);
|
|
|
|
|
}];
|
2021-11-10 18:42:27 +08:00
|
|
|
|
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
2022-03-22 20:53:20 +08:00
|
|
|
|
make.left.right.bottom.mas_equalTo(self.contentView);
|
2021-11-10 18:42:27 +08:00
|
|
|
|
}];
|
2022-03-25 15:05:15 +08:00
|
|
|
|
|
|
|
|
|
[self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.height.mas_equalTo(kSafeAreaBottomHeight);
|
|
|
|
|
}];
|
2021-11-11 18:39:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)initHttpRequest {
|
2022-06-14 17:44:24 +08:00
|
|
|
|
[self.presenter getUserInfo:[AccountInfoStorage instance].getUid];
|
2022-03-25 15:05:15 +08:00
|
|
|
|
[self.presenter getUserWallInfo];
|
|
|
|
|
[self.presenter getNormalGiftList:self.roomUid];
|
|
|
|
|
[self.presenter getPackGiftList];
|
2022-10-17 19:51:34 +08:00
|
|
|
|
[self.presenter luckyGiftBroadcastRecord];
|
2022-12-07 15:05:14 +08:00
|
|
|
|
[self.presenter getTwelveStarLastRankFirst:self.roomUid];
|
2021-11-11 18:39:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-16 19:56:37 +08:00
|
|
|
|
#pragma mark - Send Custom Message
|
2022-08-23 18:01:34 +08:00
|
|
|
|
- (void)sendGraffitiGiftMessage {
|
|
|
|
|
if (self.segmentType == GiftSegmentType_Graffiti && self.graffitiPoint.count > 0) {
|
|
|
|
|
AttachmentModel * attachment = [[AttachmentModel alloc] init];
|
|
|
|
|
attachment.first = CustomMessageType_Graffiti_Gift;
|
|
|
|
|
attachment.second = Custom_Message_Sub_Graffiti_Gift;
|
|
|
|
|
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
|
|
|
|
|
[dic setValue:@(self.giftInfoView.lastSelectGift.giftId) forKey:@"giftId"];
|
|
|
|
|
[dic setValue:self.graffitiPoint forKey:@"drawFixedArray"];
|
|
|
|
|
attachment.data = dic;
|
|
|
|
|
[self sendCustomMessage:attachment];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-16 19:56:37 +08:00
|
|
|
|
- (void)sendCustomMessage:(GiftReceiveInfoModel *)receiveModel oringinDic:(NSDictionary *)originDic {
|
|
|
|
|
NSDictionary * dict = originDic;
|
|
|
|
|
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) {
|
2022-01-25 15:23:20 +08:00
|
|
|
|
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;
|
2022-11-11 17:46:37 +08:00
|
|
|
|
NSDictionary * obj = [luckyBagGifts safeObjectAtIndex1:i];
|
2022-01-25 15:23:20 +08:00
|
|
|
|
[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"];
|
2022-06-22 15:50:34 +08:00
|
|
|
|
if ([dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"]) {
|
|
|
|
|
[data1 setObject:[dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"] forKey:@"luckyGiftSvgaUrl"];
|
|
|
|
|
}
|
2022-01-25 15:23:20 +08:00
|
|
|
|
[data1 removeObjectForKey:@"luckyBagGifts"];
|
|
|
|
|
[data1 removeObjectForKey:@"targetUsers"];
|
2022-10-25 18:49:37 +08:00
|
|
|
|
[data1 removeObjectForKey:@"gift"];
|
2022-01-25 15:23:20 +08:00
|
|
|
|
attachment.data = data1;
|
|
|
|
|
[self sendCustomMessage:attachment];
|
|
|
|
|
}
|
2021-11-16 19:56:37 +08:00
|
|
|
|
}
|
|
|
|
|
}else { // 全麦赠送普通礼物 包含背包礼物
|
2022-01-25 15:23:20 +08:00
|
|
|
|
AttachmentModel * attachment = [[AttachmentModel alloc] init];
|
|
|
|
|
attachment.first = CustomMessageType_AllMicroSend;
|
|
|
|
|
attachment.second = Custom_Message_Sub_AllMicroSend;
|
2021-11-16 19:56:37 +08:00
|
|
|
|
[data setObject:[dict valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"];
|
2022-01-25 15:23:20 +08:00
|
|
|
|
attachment.data = data;
|
|
|
|
|
[self sendCustomMessage:attachment];
|
2021-11-16 19:56:37 +08:00
|
|
|
|
}
|
|
|
|
|
} 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) {
|
2022-01-25 15:23:20 +08:00
|
|
|
|
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"];
|
2022-06-22 15:50:34 +08:00
|
|
|
|
if ([dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"]) {
|
|
|
|
|
[data1 setObject:[dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"] forKey:@"luckyGiftSvgaUrl"];
|
|
|
|
|
}
|
2022-01-25 15:23:20 +08:00
|
|
|
|
[data1 removeObjectForKey:@"luckyBagGifts"];
|
|
|
|
|
[data1 removeObjectForKey:@"targetUsers"];
|
|
|
|
|
attachment.data = data1;
|
|
|
|
|
[self sendCustomMessage:attachment];
|
2021-11-16 19:56:37 +08:00
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
}else { // 多人非全麦 普通礼物
|
2022-01-25 15:23:20 +08:00
|
|
|
|
AttachmentModel *attachment = [[AttachmentModel alloc] init];
|
|
|
|
|
attachment.first = CustomMessageType_AllMicroSend;
|
|
|
|
|
attachment.second = Custom_Message_Sub_AllBatchSend;
|
|
|
|
|
attachment.data = data;
|
|
|
|
|
[self sendCustomMessage:attachment];
|
2021-11-16 19:56:37 +08:00
|
|
|
|
}
|
|
|
|
|
} 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) {
|
2022-01-25 15:23:20 +08:00
|
|
|
|
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"];
|
2022-06-22 15:50:34 +08:00
|
|
|
|
if ([dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"]) {
|
|
|
|
|
[data1 setObject:[dict valueForKeyPath:@"gift.luckyGiftSvgaUrl"] forKey:@"luckyGiftSvgaUrl"];
|
|
|
|
|
}
|
2022-01-25 15:23:20 +08:00
|
|
|
|
[data1 removeObjectForKey:@"luckyBagGifts"];
|
|
|
|
|
[data1 removeObjectForKey:@"targetUsers"];
|
|
|
|
|
attachment.data = data1;
|
|
|
|
|
[self sendCustomMessage:attachment];
|
2021-11-16 19:56:37 +08:00
|
|
|
|
}];
|
|
|
|
|
}else { // 一对一 普通礼物
|
2022-01-25 15:23:20 +08:00
|
|
|
|
AttachmentModel *attachment = [[AttachmentModel alloc] init];
|
|
|
|
|
attachment.first = CustomMessageType_Gift;
|
|
|
|
|
attachment.second = Custom_Message_Sub_Gift_Send;
|
2021-11-16 19:56:37 +08:00
|
|
|
|
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"];
|
2022-01-25 15:23:20 +08:00
|
|
|
|
attachment.data = data;
|
|
|
|
|
[self sendCustomMessage:attachment];
|
2021-11-16 19:56:37 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-01 10:46:14 +08:00
|
|
|
|
- (void)sendCustomMessage:(AttachmentModel *)attachment {
|
2022-04-21 20:06:43 +08:00
|
|
|
|
|
|
|
|
|
NSString *sessionID = self.usingplaceType == SendGiftType_User ? [NSString stringWithFormat:@"%ld", self.userArray.firstObject.uid] : [NSString stringWithFormat:@"%ld", [self.delegate getRoomInfo].roomId];
|
2021-12-01 10:46:14 +08:00
|
|
|
|
NIMMessage *message = [[NIMMessage alloc]init];
|
|
|
|
|
NIMCustomObject *object = [[NIMCustomObject alloc] init];
|
|
|
|
|
object.attachment = attachment;
|
|
|
|
|
message.messageObject = object;
|
2022-04-07 15:28:57 +08:00
|
|
|
|
|
|
|
|
|
UserInfoModel *userInfo = [self.delegate getUserInfo];
|
|
|
|
|
XPMessageRemoteExtModel *extModel = [[XPMessageRemoteExtModel alloc] init];
|
|
|
|
|
extModel.androidBubbleUrl = userInfo.androidBubbleUrl;
|
|
|
|
|
extModel.iosBubbleUrl = userInfo.iosBubbleUrl;
|
2022-06-07 16:16:27 +08:00
|
|
|
|
extModel.fromSayHelloChannel = userInfo.fromSayHelloChannel;
|
2022-04-07 15:28:57 +08:00
|
|
|
|
NSMutableDictionary *remoteExt = [NSMutableDictionary dictionaryWithObject:extModel.model2dictionary forKey:[NSString stringWithFormat:@"%ld", userInfo.uid]];
|
|
|
|
|
message.remoteExt = remoteExt;
|
2022-04-21 20:06:43 +08:00
|
|
|
|
NIMSessionType sessionType = self.usingplaceType == SendGiftType_Room ? NIMSessionTypeChatroom : NIMSessionTypeP2P;
|
2021-12-01 10:46:14 +08:00
|
|
|
|
//构造会话
|
2022-04-21 20:06:43 +08:00
|
|
|
|
NIMSession *session = [NIMSession session:sessionID type:sessionType];
|
2021-12-01 10:46:14 +08:00
|
|
|
|
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-16 16:31:24 +08:00
|
|
|
|
#pragma mark - Deal Send Gift Data
|
|
|
|
|
- (NSString *)dealSendGiftCount:(XPGiftCountModel *)model gift:(GiftInfoModel *)gift {
|
|
|
|
|
NSString * count = @"1";
|
|
|
|
|
if (model.isTotal) {
|
|
|
|
|
count = [NSString stringWithFormat:@"%ld", gift.count];
|
|
|
|
|
} else {
|
|
|
|
|
count = model.giftNumber;
|
|
|
|
|
}
|
2022-08-23 20:08:11 +08:00
|
|
|
|
|
|
|
|
|
if (self.segmentType == GiftSegmentType_Graffiti) {
|
|
|
|
|
count = [NSString stringWithFormat:@"%ld", self.graffitiPoint.count];
|
|
|
|
|
}
|
2021-11-16 16:31:24 +08:00
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *)dealSendGiftUids:(NSArray<NSString *> *)uids {
|
|
|
|
|
NSString *uidString = [[NSString alloc] init];
|
|
|
|
|
for (NSString *item in uids) {
|
|
|
|
|
if (uidString.length > 0) {
|
|
|
|
|
uidString = [uidString stringByAppendingString:@","];
|
|
|
|
|
}
|
|
|
|
|
uidString = [uidString stringByAppendingString:item];
|
|
|
|
|
}
|
|
|
|
|
return uidString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (RoomSendGiftType)dealRoomSendGiftType:(GiftInfoModel *)giftInfo giftCount:(XPGiftCountModel *)giftCount {
|
|
|
|
|
NSArray * uids = self.userView.selectUserArray;
|
|
|
|
|
RoomSendGiftType roomSendGiftType;
|
|
|
|
|
if (self.userView.isSelectAll) {
|
|
|
|
|
if (giftInfo.sourceType == GiftSourceType_Pack && giftCount.isTotal && giftInfo && uids.count > 1) {
|
2022-03-22 20:53:20 +08:00
|
|
|
|
[self showErrorToast:@"只能全部赠送给一人"];
|
2021-11-16 16:31:24 +08:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
roomSendGiftType = RoomSendGiftType_AllMic;
|
|
|
|
|
} else if(self.userView.selectUserArray.count > 1) {
|
|
|
|
|
if (giftInfo.sourceType == GiftSourceType_Pack && giftCount.isTotal) {
|
2022-03-22 20:53:20 +08:00
|
|
|
|
[self showErrorToast:@"只能全部赠送给一人"];
|
2021-11-16 16:31:24 +08:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
roomSendGiftType = RoomSendGiftType_MutableOnMic;
|
|
|
|
|
} else if(self.userView.selectUserArray.count == 1) {
|
|
|
|
|
roomSendGiftType = RoomSendGiftType_ToOne;
|
|
|
|
|
} else {
|
|
|
|
|
roomSendGiftType = -1;
|
|
|
|
|
}
|
|
|
|
|
return roomSendGiftType;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-15 18:59:44 +08:00
|
|
|
|
#pragma mark - Public Method
|
2021-11-17 19:29:14 +08:00
|
|
|
|
- (void)configGiftUsers:(NSArray<XPGiftUserInfoModel *> *)users {
|
2022-04-21 20:06:43 +08:00
|
|
|
|
self.userArray = users;
|
2021-11-17 19:29:14 +08:00
|
|
|
|
[self.userView configGiftUsers:users];
|
2021-11-11 18:39:12 +08:00
|
|
|
|
}
|
|
|
|
|
#pragma mark - XPGiftBarViewDelegate
|
|
|
|
|
- (void)xPGiftBarView:(XPGiftBarView *)view didClickSendGift:(XPGiftCountModel *)giftCount {
|
2021-11-16 16:31:24 +08:00
|
|
|
|
///总礼物 三要素 送礼物的人 送的什么礼物 送多少个礼物
|
|
|
|
|
NSArray * uids = self.userView.selectUserArray;
|
|
|
|
|
GiftInfoModel * giftInfo = self.giftInfoView.lastSelectGift;
|
|
|
|
|
if (self.usingplaceType == SendGiftType_Room) {
|
|
|
|
|
if (uids.count > 0) {
|
|
|
|
|
///送礼物的人
|
|
|
|
|
NSString * uidString = [self dealSendGiftUids:uids];
|
|
|
|
|
///送礼物的个数
|
|
|
|
|
NSString * giftNumber = [self dealSendGiftCount:giftCount gift:giftInfo];
|
|
|
|
|
///送的什么礼物
|
|
|
|
|
NSString * giftId = [NSString stringWithFormat:@"%ld", giftInfo.giftId];
|
|
|
|
|
///给麦上的人送礼物
|
|
|
|
|
GiftSendType sendType = GiftSendType_OnMic;
|
|
|
|
|
///礼物来源
|
|
|
|
|
GiftSourceType sourceType = giftInfo.sourceType;
|
|
|
|
|
///送一个人 还是全麦 还是多人非全麦
|
|
|
|
|
RoomSendGiftType roomSendType = [self dealRoomSendGiftType:giftInfo giftCount:giftCount];
|
|
|
|
|
if (roomSendType == -1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-03-23 19:27:30 +08:00
|
|
|
|
self.giftBarView.sendButtonIsEnable = NO;
|
2021-11-16 16:31:24 +08:00
|
|
|
|
///发送消息
|
2022-03-25 15:05:15 +08:00
|
|
|
|
[self.presenter sendGift:uidString giftNum:giftNumber sendType:sendType giftId:giftId giftSource:sourceType giftType:giftInfo.giftType roomSendType:roomSendType roomUid:self.roomUid msg:@""];
|
2021-11-16 16:31:24 +08:00
|
|
|
|
} else {
|
2022-03-22 20:53:20 +08:00
|
|
|
|
[self showErrorToast:@"请选择至少一个人"];
|
2021-11-16 16:31:24 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2022-04-21 20:06:43 +08:00
|
|
|
|
} 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:@""];
|
2021-11-16 16:31:24 +08:00
|
|
|
|
}
|
2021-11-11 18:39:12 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///充值
|
2021-11-15 18:59:44 +08:00
|
|
|
|
- (void)xPGiftBarViewDidClickRecharge:(XPGiftBarView *)view {
|
2022-12-07 15:05:14 +08:00
|
|
|
|
[self dismissViewControllerAnimated:NO completion:^{
|
2022-06-08 20:20:25 +08:00
|
|
|
|
XPMineHalfRechargeViewController * rechargeVC = [[XPMineHalfRechargeViewController alloc] init];
|
|
|
|
|
rechargeVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
2022-05-17 21:04:50 +08:00
|
|
|
|
if (self.delegate.getRoomInfo) {
|
|
|
|
|
rechargeVC.roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid];
|
|
|
|
|
}
|
2022-06-08 20:20:25 +08:00
|
|
|
|
rechargeVC.currentNav = self.delegate.getCurrentNav ? self.delegate.getCurrentNav : [XCCurrentVCStackManager shareManager].getCurrentVC.navigationController;
|
|
|
|
|
[[XCCurrentVCStackManager shareManager].getCurrentVC presentViewController:rechargeVC animated:YES completion:nil];
|
2022-12-07 15:05:14 +08:00
|
|
|
|
}];
|
2021-11-15 18:59:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-24 16:36:17 +08:00
|
|
|
|
- (void)xPGiftBarViewDidClickFirstRecharge:(XPGiftBarView *)view {
|
2022-12-07 15:05:14 +08:00
|
|
|
|
[self dismissViewControllerAnimated:NO completion:^{
|
2022-06-08 20:20:25 +08:00
|
|
|
|
XPFirstRechargeViewController * firstRechargeVC = [[XPFirstRechargeViewController alloc] initWithNavigation:[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController];
|
2022-12-07 15:05:14 +08:00
|
|
|
|
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController presentViewController:firstRechargeVC animated:YES completion:nil];
|
|
|
|
|
}];
|
2021-12-24 16:36:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-08 19:01:20 +08:00
|
|
|
|
#pragma mark - XPGiftLuckyGiftBroadcastViewDelegate
|
|
|
|
|
///点击了玩法说明
|
|
|
|
|
- (void)xPGiftLuckyGiftBroadcastViewPlayDescClick {
|
|
|
|
|
NSString * giftExplainUrl;
|
|
|
|
|
if (self.segmentType == GiftSegmentType_Lucky) {
|
|
|
|
|
giftExplainUrl = [NSString stringWithFormat:URLWithType(kLuckyGiftPlayRuleURL), [NSString stringWithFormat:@"%ld", self.giftInfoView.lastSelectGift.giftId]];
|
|
|
|
|
} else {
|
|
|
|
|
giftExplainUrl = self.giftInfoView.lastSelectGift.giftExplainUrl;
|
|
|
|
|
}
|
|
|
|
|
XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init];
|
|
|
|
|
webView.url = giftExplainUrl;
|
|
|
|
|
[TTPopup popupView:webView style:TTPopupStyleActionSheet];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - XPGiftWeekStarBroadcastViewDelegate
|
|
|
|
|
///点击了周星榜入口
|
|
|
|
|
- (void)xPGiftWeekStarBroadcastViewWeekStarClick {
|
2022-12-07 15:05:14 +08:00
|
|
|
|
[self dismissViewControllerAnimated:NO completion:^{
|
|
|
|
|
XPWebViewController * webVC = [[XPWebViewController alloc] init];
|
|
|
|
|
webVC.roomUid = self.roomUid;
|
|
|
|
|
webVC.url = URLWithType(kNewWeekStarURL);
|
|
|
|
|
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
|
|
|
|
|
}];
|
2022-10-08 19:01:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-29 18:39:08 +08:00
|
|
|
|
#pragma mark - XPGiftHeadTypeViewDelegate
|
|
|
|
|
///点击了贵族
|
|
|
|
|
- (void)xPGiftHeadTypeViewDidClickNoble:(XPGiftHeadTypeView *)view {
|
2022-12-07 15:05:14 +08:00
|
|
|
|
[self dismissViewControllerAnimated:NO completion:^{
|
|
|
|
|
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventvipEntranceGiftClick];
|
|
|
|
|
XPNobleCenterViewController * nobleVC = [[XPNobleCenterViewController alloc] initWithRoomUid:self.delegate.getRoomInfo.uid];
|
|
|
|
|
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:nobleVC animated:YES];
|
|
|
|
|
}];
|
2022-09-29 18:39:08 +08:00
|
|
|
|
}
|
|
|
|
|
///点击了首充
|
|
|
|
|
- (void)xPGiftHeadTypeViewDidClickFirstRecharge:(XPGiftHeadTypeView *)view {
|
2022-12-07 15:05:14 +08:00
|
|
|
|
[self dismissViewControllerAnimated:NO completion:^{
|
|
|
|
|
XPFirstRechargeViewController * firstRechargeVC = [[XPFirstRechargeViewController alloc] initWithNavigation:[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController];
|
|
|
|
|
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController presentViewController:firstRechargeVC animated:YES completion:nil];
|
|
|
|
|
}];
|
|
|
|
|
|
2022-09-29 18:39:08 +08:00
|
|
|
|
}
|
|
|
|
|
///点击了礼物
|
|
|
|
|
- (void)xPGiftHeadTypeViewDidClickGift:(XPGiftHeadTypeView *)view {
|
2022-10-08 19:01:20 +08:00
|
|
|
|
[self.luckyBroadcastView removeFromSuperview];
|
|
|
|
|
[self.giftInfoView giftHeadTypeHadChange:1];
|
|
|
|
|
if (!self.graffitiView.hidden) {//清空涂鸦礼物
|
|
|
|
|
[self.graffitiView clearData];
|
|
|
|
|
[self.graffitiView cratePriceAttribute];
|
|
|
|
|
[UIView animateWithDuration:0.2 animations:^{
|
|
|
|
|
self.graffitiView.hidden = YES;
|
|
|
|
|
self.giftInfoView.hidden = NO;
|
|
|
|
|
}];
|
|
|
|
|
}
|
2022-09-29 18:39:08 +08:00
|
|
|
|
}
|
|
|
|
|
///点击了互动
|
|
|
|
|
- (void)xPGiftHeadTypeViewDidClickInteraction:(XPGiftHeadTypeView *)view {
|
2022-10-08 19:01:20 +08:00
|
|
|
|
[self.luckyBroadcastView removeFromSuperview];
|
|
|
|
|
[self.giftInfoView giftHeadTypeHadChange:2];
|
2022-09-29 18:39:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-15 18:59:44 +08:00
|
|
|
|
#pragma mark - XPGiftInfoViewDelegate
|
2021-11-16 16:31:24 +08:00
|
|
|
|
- (void)xPGiftInfoView:(XPGiftInfoView *)view didClickSegment:(GiftSegmentType)type {
|
2022-08-23 18:01:34 +08:00
|
|
|
|
self.segmentType = type;
|
2021-11-16 16:31:24 +08:00
|
|
|
|
self.giftBarView.type = type;
|
2022-08-24 16:42:43 +08:00
|
|
|
|
self.giftBarView.drawGiftCount = 0;
|
2022-10-08 19:01:20 +08:00
|
|
|
|
if (type == GiftSegmentType_Lucky) {
|
2022-12-07 15:05:14 +08:00
|
|
|
|
[self.constellationBanner removeFromSuperview];
|
2022-10-08 19:01:20 +08:00
|
|
|
|
// self.presenter
|
|
|
|
|
if (!self.luckyBroadcastView.superview) {
|
|
|
|
|
[self.view addSubview:self.luckyBroadcastView];
|
|
|
|
|
[self.luckyBroadcastView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.bottom.mas_equalTo(self.contentView.mas_top);
|
|
|
|
|
make.left.right.mas_equalTo(0);
|
|
|
|
|
make.height.mas_equalTo(48);
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
} else if(type == GiftSegmentType_WeekStar) {
|
|
|
|
|
[self.luckyBroadcastView removeFromSuperview];
|
2023-01-06 14:07:30 +08:00
|
|
|
|
if ([ClientConfig shareConfig].configInfo.twelveStarSwitch) {
|
|
|
|
|
self.constellationBanner.hidden = NO;
|
|
|
|
|
if (!self.constellationBanner.superview) {
|
|
|
|
|
[self.view addSubview:self.constellationBanner];
|
|
|
|
|
[self.constellationBanner mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.bottom.mas_equalTo(self.contentView.mas_top);
|
|
|
|
|
make.left.right.mas_equalTo(0);
|
|
|
|
|
make.height.mas_equalTo(75);
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
self.constellationBanner.hidden = YES;
|
|
|
|
|
}
|
2022-10-08 19:01:20 +08:00
|
|
|
|
} else {
|
|
|
|
|
[self.luckyBroadcastView removeFromSuperview];
|
2022-12-07 15:05:14 +08:00
|
|
|
|
[self.constellationBanner removeFromSuperview];
|
2022-10-08 19:01:20 +08:00
|
|
|
|
}
|
2021-11-16 16:31:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-22 20:07:36 +08:00
|
|
|
|
- (void)xPGiftInfoView:(XPGiftInfoView *)view didClickItem:(GiftInfoModel *)info type:(GiftSegmentType)type {
|
|
|
|
|
if (type == GiftSegmentType_Graffiti) {
|
|
|
|
|
self.giftInfoView.hidden = YES;
|
|
|
|
|
self.graffitiView.hidden = NO;
|
2022-08-23 18:01:34 +08:00
|
|
|
|
self.graffitiView.price = info.goldPrice;
|
2022-08-23 20:08:11 +08:00
|
|
|
|
self.giftBarView.drawGiftCount = 0;
|
2022-08-25 21:46:54 +08:00
|
|
|
|
self.graffitiView.selectUidNumber = self.userView.selectUserArray.count;
|
2022-08-22 20:07:36 +08:00
|
|
|
|
[[SDWebImageManager sharedManager] loadImageWithURL:[NSURL URLWithString:info.giftUrl] options:SDWebImageProgressiveLoad progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
|
|
|
|
|
if (error == nil && image) {
|
|
|
|
|
self.graffitiView.image = image;
|
|
|
|
|
} else {
|
|
|
|
|
self.giftInfoView.hidden = NO;
|
|
|
|
|
}
|
|
|
|
|
}];
|
2022-08-23 20:08:11 +08:00
|
|
|
|
} else {
|
|
|
|
|
self.giftBarView.drawGiftCount = 10;
|
2022-08-22 20:07:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-24 17:31:48 +08:00
|
|
|
|
#pragma mark - XPGiftUsersViewDelegate
|
|
|
|
|
- (void)xPGiftUsersView:(XPGiftUsersView *)view didSelectUsers:(NSArray *)selectUids {
|
|
|
|
|
self.graffitiView.selectUidNumber = selectUids.count;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-23 18:01:34 +08:00
|
|
|
|
#pragma mark - XPGraffitiGiftViewDelegate
|
|
|
|
|
- (void)xPGraffitiGiftView:(XPGraffitiGiftView *)view didClickClose:(UIButton *)sender {
|
|
|
|
|
[UIView animateWithDuration:0.2 animations:^{
|
|
|
|
|
self.graffitiView.hidden = YES;
|
|
|
|
|
self.giftInfoView.hidden = NO;
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)xPGraffitiGiftView:(XPGraffitiGiftView *)view didClickChange:(UIButton *)sender {
|
|
|
|
|
[UIView animateWithDuration:0.2 animations:^{
|
|
|
|
|
self.graffitiView.hidden = YES;
|
|
|
|
|
self.giftInfoView.hidden = NO;
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)xPGraffitiGiftView:(XPGraffitiGiftView *)view didDrawCompletion:(NSArray *)pointArray {
|
|
|
|
|
self.graffitiPoint = pointArray;
|
2022-08-23 20:08:11 +08:00
|
|
|
|
self.giftBarView.drawGiftCount = self.graffitiPoint.count;
|
2022-08-23 18:01:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 15:05:14 +08:00
|
|
|
|
#pragma mark - XPGiftTwelveStarBroadcastViewDelegate
|
|
|
|
|
- (void)xPGiftTwelveStarBroadcastView:(XPGiftTwelveStarBroadcastView *)view didClickDetail:(UIButton *)sender {
|
|
|
|
|
[self dismissViewControllerAnimated:NO completion:^{
|
|
|
|
|
XPWebViewController * webVC = [[XPWebViewController alloc] init];
|
|
|
|
|
webVC.url = URLWithType(kXinZuoStarURL);
|
|
|
|
|
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-11 18:39:12 +08:00
|
|
|
|
#pragma mark - XPGiftProtocol
|
2022-06-14 17:44:24 +08:00
|
|
|
|
- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo {
|
2022-09-29 18:39:08 +08:00
|
|
|
|
self.headTypeView.isShowFirstRecharge = userInfo.isFirstCharge;
|
2022-06-14 17:44:24 +08:00
|
|
|
|
self.giftBarView.isShowFirstRecharge = userInfo.isFirstCharge;
|
|
|
|
|
self.giftInfoView.curUserNobleLevel = userInfo.userVipInfoVO.vipLevel;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-11 18:39:12 +08:00
|
|
|
|
- (void)getUserWalletInfo:(WalletInfoModel *)balanceInfo {
|
|
|
|
|
self.giftBarView.walletInfoModel = balanceInfo;
|
|
|
|
|
}
|
2021-11-15 18:59:44 +08:00
|
|
|
|
///背包礼物
|
2021-11-11 18:39:12 +08:00
|
|
|
|
- (void)getPacketGiftListSuccess:(NSArray<GiftInfoModel *> *)giftList {
|
2021-11-12 19:30:53 +08:00
|
|
|
|
self.giftInfoView.packOriginArray = giftList;
|
2021-11-11 18:39:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-22 20:53:20 +08:00
|
|
|
|
- (void)getPacketGiftListFail:(NSString *)message {
|
|
|
|
|
self.packGiftRetryCount ++;
|
|
|
|
|
if (self.packGiftRetryCount <= 10) {
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
2022-03-25 15:05:15 +08:00
|
|
|
|
[self.presenter getPackGiftList];
|
2022-03-22 20:53:20 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-15 18:59:44 +08:00
|
|
|
|
///普通礼物 /幸运礼物
|
2021-11-11 18:39:12 +08:00
|
|
|
|
- (void)getNormalGiftListSuccess:(NSArray<GiftInfoModel *> *)giftList {
|
2021-11-12 19:30:53 +08:00
|
|
|
|
self.giftInfoView.normalOriginArray = giftList;
|
2021-11-10 18:42:27 +08:00
|
|
|
|
}
|
2021-11-16 16:31:24 +08:00
|
|
|
|
|
2022-03-22 20:53:20 +08:00
|
|
|
|
- (void)getNormalGiftListFail:(NSString *)message {
|
|
|
|
|
self.normalGiftRetryCount ++;
|
|
|
|
|
if (self.normalGiftRetryCount <= 10) {
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
2022-03-25 15:05:15 +08:00
|
|
|
|
[self.presenter getNormalGiftList:self.roomUid];
|
2022-03-22 20:53:20 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-13 20:10:15 +08:00
|
|
|
|
- (void)sendGiftSuccess:(GiftReceiveInfoModel *)receiveInfo originDic:(NSDictionary *)originDic uidCount:(NSInteger)uidCount{
|
2022-03-23 19:27:30 +08:00
|
|
|
|
self.giftBarView.sendButtonIsEnable = YES;
|
2021-11-16 16:31:24 +08:00
|
|
|
|
if (receiveInfo.sourceType == GiftSourceType_Pack) {
|
|
|
|
|
///更新个数
|
2021-12-13 20:10:15 +08:00
|
|
|
|
[self.giftInfoView updatePackSource:receiveInfo numberUser:uidCount];
|
2021-11-16 16:31:24 +08:00
|
|
|
|
} else {
|
2022-03-25 15:05:15 +08:00
|
|
|
|
[self.presenter getUserWallInfo];
|
2021-11-16 16:31:24 +08:00
|
|
|
|
}
|
2021-11-16 19:56:37 +08:00
|
|
|
|
[self sendCustomMessage:receiveInfo oringinDic:originDic];
|
2022-08-23 18:01:34 +08:00
|
|
|
|
///发送涂鸦礼物消息
|
|
|
|
|
[self sendGraffitiGiftMessage];
|
|
|
|
|
if (self.segmentType == GiftSegmentType_Graffiti) {
|
|
|
|
|
NSString * title = [NSString stringWithFormat:@"发送涂鸦礼物:%@成功",self.giftInfoView.lastSelectGift.giftName];
|
|
|
|
|
[self showSuccessToast:title];
|
|
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
|
}
|
2021-11-16 16:31:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-18 16:07:30 +08:00
|
|
|
|
///送礼物失败
|
|
|
|
|
- (void)sendGiftFailWithCode:(NSInteger)code msg:(NSString *)msg {
|
2022-03-23 19:27:30 +08:00
|
|
|
|
self.giftBarView.sendButtonIsEnable = YES;
|
2022-01-18 16:07:30 +08:00
|
|
|
|
if (code == 31005) {// 余额不足
|
|
|
|
|
[self showNotSufficientFundsWithToast:msg];
|
|
|
|
|
} else if (code == 8535) {//贵族等级未达到礼物等级
|
|
|
|
|
GiftInfoModel * giftInfo = self.giftInfoView.lastSelectGift;
|
2022-03-15 16:29:16 +08:00
|
|
|
|
TTAlertConfig *config = [[TTAlertConfig alloc] init];
|
|
|
|
|
config.actionStyle = TTAlertActionConfirmStyle;
|
|
|
|
|
config.message = [NSString stringWithFormat:@"尚未达到赠送%@所需要的贵族等级哦\n所需贵族等级:%@", giftInfo.giftName, giftInfo.giftVipInfo.vipName];
|
|
|
|
|
[TTPopup alertWithConfig:config confirmHandler:^{
|
|
|
|
|
|
|
|
|
|
} cancelHandler:^{
|
|
|
|
|
|
|
|
|
|
}];
|
2022-01-18 16:07:30 +08:00
|
|
|
|
} else {
|
2022-03-22 20:53:20 +08:00
|
|
|
|
[self showErrorToast:msg];
|
2022-01-18 16:07:30 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 余额不足,是否弹首充弹窗
|
|
|
|
|
- (void)showNotSufficientFundsWithToast:(NSString *)msg {
|
|
|
|
|
if (self.delegate.getUserInfo.isFirstCharge) {
|
2022-12-07 15:05:14 +08:00
|
|
|
|
[self dismissViewControllerAnimated:NO completion:^{
|
|
|
|
|
XPFirstRechargeViewController * firstRechargeVC = [[XPFirstRechargeViewController alloc] initWithNavigation:XCCurrentVCStackManager.shareManager.getCurrentVC.navigationController];
|
|
|
|
|
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController presentViewController:firstRechargeVC animated:YES completion:nil];
|
|
|
|
|
}];
|
2022-01-18 16:07:30 +08:00
|
|
|
|
} else {
|
2022-03-22 20:53:20 +08:00
|
|
|
|
[self showErrorToast:msg];
|
2022-01-18 16:07:30 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-17 19:51:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)luckyGiftBroadcastRecordSuccess:(NSArray *)records {
|
|
|
|
|
self.records = records;
|
|
|
|
|
self.luckyBroadcastView.records = records;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 15:05:14 +08:00
|
|
|
|
- (void)getTwelveStarLastRankFirstSuccess:(GiftTwelveStarFirstModel *)model {
|
|
|
|
|
self.constellationBanner.giftInfo = model;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-22 20:53:20 +08:00
|
|
|
|
#pragma mark - Event Response
|
|
|
|
|
- (void)disMissViewRecognizer:(UITapGestureRecognizer *)tap {
|
|
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
|
}
|
2022-01-18 16:07:30 +08:00
|
|
|
|
|
2021-11-10 18:42:27 +08:00
|
|
|
|
#pragma mark - Getters And Setters
|
2022-04-21 20:06:43 +08:00
|
|
|
|
- (void)setUsingplaceType:(SendGiftType)usingplaceType {
|
|
|
|
|
_usingplaceType = usingplaceType;
|
|
|
|
|
self.giftInfoView.usingplaceType = _usingplaceType;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-04 18:22:31 +08:00
|
|
|
|
- (void)setSelectGiftId:(NSString *)selectGiftId {
|
|
|
|
|
_selectGiftId = selectGiftId;
|
|
|
|
|
self.giftInfoView.defaultSelectGiftId = selectGiftId;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-21 19:13:04 +08:00
|
|
|
|
- (void)setDelegate:(id<RoomHostDelegate>)delegate {
|
|
|
|
|
_delegate = delegate;
|
|
|
|
|
if (_delegate) {
|
|
|
|
|
self.giftInfoView.roomType = _delegate.getRoomInfo.type;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-22 20:53:20 +08:00
|
|
|
|
- (UIView *)topView {
|
|
|
|
|
if (!_topView) {
|
|
|
|
|
_topView = [[UIView alloc] init];
|
|
|
|
|
_topView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(disMissViewRecognizer:)];
|
|
|
|
|
[_topView addGestureRecognizer:tap];
|
|
|
|
|
}
|
|
|
|
|
return _topView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIView *)contentView {
|
|
|
|
|
if (!_contentView) {
|
|
|
|
|
_contentView = [[UIView alloc] init];
|
2022-10-08 19:01:20 +08:00
|
|
|
|
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, KScreenWidth, KScreenHeight) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(8, 8)];
|
|
|
|
|
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
|
|
|
|
|
maskLayer.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
|
|
|
|
|
maskLayer.path = maskPath.CGPath;
|
|
|
|
|
_contentView.layer.mask = maskLayer;
|
|
|
|
|
|
2022-03-22 20:53:20 +08:00
|
|
|
|
}
|
|
|
|
|
return _contentView;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-10 18:42:27 +08:00
|
|
|
|
- (XPGiftUsersView *)userView {
|
|
|
|
|
if (!_userView) {
|
2021-11-30 15:38:00 +08:00
|
|
|
|
_userView = [[XPGiftUsersView alloc] init];
|
2022-08-24 17:31:48 +08:00
|
|
|
|
_userView.delegate = self;
|
2021-11-10 18:42:27 +08:00
|
|
|
|
}
|
|
|
|
|
return _userView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (XPGiftInfoView *)giftInfoView {
|
|
|
|
|
if (!_giftInfoView) {
|
|
|
|
|
_giftInfoView = [[XPGiftInfoView alloc] init];
|
2021-11-15 18:59:44 +08:00
|
|
|
|
_giftInfoView.delegate = self;
|
2021-11-10 18:42:27 +08:00
|
|
|
|
}
|
|
|
|
|
return _giftInfoView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (XPGiftBarView *)giftBarView {
|
|
|
|
|
if (!_giftBarView) {
|
|
|
|
|
_giftBarView = [[XPGiftBarView alloc] init];
|
2021-11-11 18:39:12 +08:00
|
|
|
|
_giftBarView.delegate = self;
|
2021-11-10 18:42:27 +08:00
|
|
|
|
}
|
|
|
|
|
return _giftBarView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIStackView *)stackView {
|
|
|
|
|
if (!_stackView) {
|
|
|
|
|
_stackView = [[UIStackView alloc] init];
|
|
|
|
|
_stackView.axis = UILayoutConstraintAxisVertical;
|
|
|
|
|
_stackView.distribution = UIStackViewDistributionFill;
|
|
|
|
|
_stackView.alignment = UIStackViewAlignmentFill;
|
|
|
|
|
_stackView.spacing = 0;
|
|
|
|
|
_stackView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
}
|
|
|
|
|
return _stackView;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-25 15:05:15 +08:00
|
|
|
|
- (UIView *)bottomView {
|
|
|
|
|
if (!_bottomView) {
|
|
|
|
|
_bottomView = [[UIView alloc] init];
|
|
|
|
|
_bottomView.backgroundColor = [UIColor clearColor];
|
2021-11-11 18:39:12 +08:00
|
|
|
|
}
|
2022-03-25 15:05:15 +08:00
|
|
|
|
return _bottomView;
|
2021-11-11 18:39:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-22 20:07:36 +08:00
|
|
|
|
- (XPGraffitiGiftView *)graffitiView {
|
|
|
|
|
if (!_graffitiView) {
|
|
|
|
|
_graffitiView = [[XPGraffitiGiftView alloc] init];
|
|
|
|
|
_graffitiView.hidden = YES;
|
2022-08-23 18:01:34 +08:00
|
|
|
|
_graffitiView.delegate = self;
|
2022-08-22 20:07:36 +08:00
|
|
|
|
}
|
|
|
|
|
return _graffitiView;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-29 18:39:08 +08:00
|
|
|
|
- (XPGiftHeadTypeView *)headTypeView {
|
|
|
|
|
if (!_headTypeView) {
|
|
|
|
|
_headTypeView = [[XPGiftHeadTypeView alloc] init];
|
|
|
|
|
_headTypeView.delegate = self;
|
|
|
|
|
}
|
|
|
|
|
return _headTypeView;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-08 19:01:20 +08:00
|
|
|
|
- (XPGiftLuckyGiftBroadcastView *)luckyBroadcastView {
|
|
|
|
|
if (!_luckyBroadcastView) {
|
|
|
|
|
_luckyBroadcastView = [[XPGiftLuckyGiftBroadcastView alloc] init];
|
|
|
|
|
_luckyBroadcastView.delegate = self;
|
|
|
|
|
}
|
|
|
|
|
return _luckyBroadcastView;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 15:05:14 +08:00
|
|
|
|
- (XPGiftTwelveStarBroadcastView *)constellationBanner {
|
|
|
|
|
if (!_constellationBanner) {
|
|
|
|
|
_constellationBanner = [[XPGiftTwelveStarBroadcastView alloc] init];
|
|
|
|
|
_constellationBanner.delegate = self;
|
2022-10-08 19:01:20 +08:00
|
|
|
|
}
|
2022-12-07 15:05:14 +08:00
|
|
|
|
return _constellationBanner;
|
2022-10-08 19:01:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIVisualEffectView *)effectView {
|
|
|
|
|
if (!_effectView) {
|
2022-10-11 10:23:51 +08:00
|
|
|
|
UIBlurEffect *beffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
|
2022-10-08 19:01:20 +08:00
|
|
|
|
_effectView = [[UIVisualEffectView alloc] initWithEffect:beffect];
|
|
|
|
|
}
|
|
|
|
|
return _effectView;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-10 18:42:27 +08:00
|
|
|
|
@end
|