修改完成
This commit is contained in:
@@ -64,8 +64,11 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic,strong)NSString *giftLabelId;
|
||||
@property (nonatomic,strong)NSString *roomId;
|
||||
@property (nonatomic,assign)NSInteger selectedIndex;
|
||||
@property (nonatomic,strong)QXGiftModel *model;
|
||||
@property (nonatomic,copy)void(^selectetGiftBlock)(QXGiftModel *gift);
|
||||
@property (nonatomic,assign)QXSendGiftViewType type;
|
||||
|
||||
-(void)reloadData;
|
||||
@end
|
||||
|
||||
@interface QXSendGiftUserView : UIView<UICollectionViewDelegate,UICollectionViewDataSource>
|
||||
|
||||
@@ -44,11 +44,13 @@
|
||||
@property (nonatomic,strong)UIView *sendBgView;
|
||||
@property (nonatomic,strong)UIButton *countBtn;
|
||||
@property (nonatomic,strong)UIButton *sendBtn;
|
||||
@property (nonatomic,strong)UIButton *sendAllBtn;
|
||||
|
||||
/// 被选中的礼物
|
||||
@property (nonatomic,strong)QXGiftModel *giftModel;
|
||||
@property (nonatomic,strong)NSString *giftCount;
|
||||
|
||||
@property (nonatomic,strong)QXSendGiftCollectionView *bagGiftView;
|
||||
@end
|
||||
|
||||
@implementation QXSendGiftView
|
||||
@@ -86,6 +88,7 @@
|
||||
_type = type;
|
||||
switch (type) {
|
||||
case QXSendGiftViewTypeFind:{
|
||||
self.heartId = @"";
|
||||
if (_pitUserListView) {
|
||||
[_pitUserListView removeFromSuperview];
|
||||
_pitUserListView = nil;
|
||||
@@ -101,8 +104,42 @@
|
||||
self.containerView.frame = CGRectMake(0, self.categoryView.bottom, SCREEN_WIDTH, self.bgView.height-self.categoryView.bottom-ScaleWidth(63)-kSafeAreaBottom);
|
||||
}
|
||||
break;
|
||||
case QXSendGiftViewTypeRoom:
|
||||
case QXSendGiftViewTypeAuction:
|
||||
case QXSendGiftViewTypeRoom:{
|
||||
self.heartId = @"";
|
||||
if (_userListView) {
|
||||
[_userListView removeFromSuperview];
|
||||
_userListView = nil;
|
||||
}
|
||||
self.bgView.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(429)+kSafeAreaBottom);
|
||||
self.bgView.backgroundColor = [UIColor clearColor];
|
||||
self.bgImageView.frame = self.bounds;
|
||||
self.bgImageView.hidden = NO;
|
||||
self.categoryView.titleSelectedColor = [UIColor colorWithHexString:@"#FFFFFF"];
|
||||
self.categoryView.titleColor = [UIColor colorWithHexString:@"#E9E9E9"];
|
||||
[self.bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
|
||||
[self initPitUserListView];
|
||||
self.categoryView.frame = CGRectMake(16, ScaleWidth(44)+ScaleWidth(8), SCREEN_WIDTH-32, ScaleWidth(44));
|
||||
self.containerView.frame = CGRectMake(0, self.categoryView.bottom, SCREEN_WIDTH, self.bgView.height-self.categoryView.bottom-ScaleWidth(63)-kSafeAreaBottom);
|
||||
}
|
||||
break;
|
||||
case QXSendGiftViewTypeAuction:{
|
||||
self.heartId = @"";
|
||||
if (_userListView) {
|
||||
[_userListView removeFromSuperview];
|
||||
_userListView = nil;
|
||||
}
|
||||
self.bgView.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(429)+kSafeAreaBottom);
|
||||
self.bgView.backgroundColor = [UIColor clearColor];
|
||||
self.bgImageView.frame = self.bounds;
|
||||
self.bgImageView.hidden = NO;
|
||||
self.categoryView.titleSelectedColor = [UIColor colorWithHexString:@"#FFFFFF"];
|
||||
self.categoryView.titleColor = [UIColor colorWithHexString:@"#E9E9E9"];
|
||||
[self.bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
|
||||
[self initPitUserListView];
|
||||
self.categoryView.frame = CGRectMake(16, ScaleWidth(44)+ScaleWidth(8), SCREEN_WIDTH-32, ScaleWidth(44));
|
||||
self.containerView.frame = CGRectMake(0, self.categoryView.bottom, SCREEN_WIDTH, self.bgView.height-self.categoryView.bottom-ScaleWidth(63)-kSafeAreaBottom);
|
||||
}
|
||||
break;
|
||||
case QXSendGiftViewTypeFriend:{
|
||||
if (_userListView) {
|
||||
[_userListView removeFromSuperview];
|
||||
@@ -260,6 +297,22 @@
|
||||
make.right.top.bottom.equalTo(self.sendBgView);
|
||||
make.width.equalTo(self.sendBgView.mas_width).multipliedBy(0.5);
|
||||
}];
|
||||
|
||||
self.sendAllBtn = [[UIButton alloc] init];
|
||||
[self.sendAllBtn setTitle:QXText(@"一键全送") forState:(UIControlStateNormal)];
|
||||
[self.sendAllBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||||
self.sendAllBtn.backgroundColor = QXConfig.themeColor;
|
||||
[self.sendAllBtn addRoundedCornersWithRadius:17.5];
|
||||
self.sendAllBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.sendAllBtn addTarget:self action:@selector(sendAllAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
self.sendAllBtn.hidden = YES;
|
||||
[self.bgView addSubview:self.sendAllBtn];
|
||||
[self.sendAllBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(80);
|
||||
make.height.mas_equalTo(35);
|
||||
make.centerY.equalTo(self.sendBgView);
|
||||
make.right.equalTo(self.sendBgView.mas_left).offset(-5);
|
||||
}];
|
||||
}
|
||||
-(void)introduceAction{
|
||||
QXBaseWebViewController *vc = [[QXBaseWebViewController alloc] init];
|
||||
@@ -287,6 +340,23 @@
|
||||
self.rechargeBtn.hidden = !QXGlobal.shareGlobal.isOpenRecharge;
|
||||
[self getMyWallet];
|
||||
}
|
||||
-(void)sendAllAction{
|
||||
if (self.pitUserListView.selectedArray.count == 0) {
|
||||
showToast(@"请选择送礼对象");
|
||||
return;
|
||||
}
|
||||
if (self.pitUserListView.selectedArray.count > 1) {
|
||||
showToast(@"一键全送仅能选择一个用户");
|
||||
return;
|
||||
}
|
||||
NSString *userId = [self.pitUserListView.selectedArray componentsJoinedByString:@","];
|
||||
MJWeakSelf
|
||||
[QXMineNetwork roomBagGiftClearWithRoomId:self.roomId userId:userId heartId:self.heartId successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
[weakSelf hide];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
showToast(msg);
|
||||
}];
|
||||
}
|
||||
/// 发送礼物
|
||||
-(void)sendAction{
|
||||
MJWeakSelf
|
||||
@@ -306,44 +376,62 @@
|
||||
NSString *userId = [self.pitUserListView.selectedArray componentsJoinedByString:@","];
|
||||
|
||||
[QXMineNetwork roomSendGiftWithRoomId:self.roomId gift_id:self.giftModel.gift_id gift_num:self.giftCount to_uid:userId heart_id:self.heartId type:type pit_number:@"" successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
[weakSelf hide];
|
||||
if (type.intValue == 1) {
|
||||
if (weakSelf.roomSendSuccessBlock) {
|
||||
weakSelf.roomSendSuccessBlock(self.type,weakSelf.giftModel,userId,@"");
|
||||
}
|
||||
[weakSelf hide];
|
||||
}else{
|
||||
[weakSelf.bagGiftView reloadData];
|
||||
}
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
showToast(msg)
|
||||
}];
|
||||
}else if (self.type == QXSendGiftViewTypeAuction) {
|
||||
if (self.giftModel==nil) {
|
||||
showToast(@"请选择礼物");
|
||||
return;
|
||||
}
|
||||
self.heartId = @"";
|
||||
/// 2为背包
|
||||
[QXMineNetwork roomAuctionJoinWithAuctionId:self.auctionId user_id:[QXGlobal shareGlobal].loginModel.user_id gift_id:self.giftModel.gift_id num:self.giftCount type:type successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
[weakSelf hide];
|
||||
if (type.intValue == 1) {
|
||||
[weakSelf hide];
|
||||
if (weakSelf.roomSendSuccessBlock) {
|
||||
weakSelf.roomSendSuccessBlock(self.type,weakSelf.giftModel,[QXGlobal shareGlobal].loginModel.user_id,weakSelf.auctionId);
|
||||
weakSelf.roomSendSuccessBlock(weakSelf.type,weakSelf.giftModel,[QXGlobal shareGlobal].loginModel.user_id,weakSelf.auctionId);
|
||||
}
|
||||
}else{
|
||||
[weakSelf.bagGiftView reloadData];
|
||||
}
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
showToast(msg);
|
||||
}];
|
||||
}else if (self.type == QXSendGiftViewTypeFriend) {
|
||||
if (self.giftModel==nil) {
|
||||
showToast(@"请选择礼物");
|
||||
return;
|
||||
}
|
||||
self.auctionId = @"";
|
||||
/// 2为背包
|
||||
NSString *userId = [self.pitUserListView.selectedArray componentsJoinedByString:@","];
|
||||
NSString *type = self.categoryView.selectedIndex==0?@"2":@"1";
|
||||
[QXMineNetwork roomSendGiftWithRoomId:self.roomId gift_id:self.giftModel.gift_id gift_num:self.giftCount to_uid:userId heart_id:self.heartId type:type pit_number:@"" successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
[weakSelf hide];
|
||||
if (type.intValue == 1) {
|
||||
[weakSelf hide];
|
||||
if (weakSelf.roomSendSuccessBlock) {
|
||||
weakSelf.roomSendSuccessBlock(self.type,weakSelf.giftModel,userId,weakSelf.heartId);
|
||||
}
|
||||
}else{
|
||||
[weakSelf.bagGiftView reloadData];
|
||||
}
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
showToast(msg)
|
||||
}];
|
||||
}else{
|
||||
if (self.giftModel==nil) {
|
||||
showToast(@"请选择礼物");
|
||||
return;
|
||||
}
|
||||
/// 2为背包
|
||||
NSString *type = self.categoryView.selectedIndex==0?@"2":@"1";
|
||||
[QXDynamicNetwork dynamicGiveGiftWithId:self.dynamicId
|
||||
@@ -394,6 +482,7 @@
|
||||
}
|
||||
-(void)setPitUsers:(NSArray *)pitUsers{
|
||||
_pitUsers = pitUsers;
|
||||
self.giftModel = nil;
|
||||
self.pitUserListView.isSingle = NO;
|
||||
[self.pitUserListView.selectedArray removeAllObjects];
|
||||
self.pitUserListView.users = pitUsers;
|
||||
@@ -402,6 +491,7 @@
|
||||
-(void)setUserModel:(QXRoomPitModel *)userModel{
|
||||
_userModel = userModel;
|
||||
userModel.isSelected = YES;
|
||||
self.giftModel = nil;
|
||||
self.pitUserListView.isSingle = YES;
|
||||
[self.pitUserListView.selectedArray removeAllObjects];
|
||||
[self.pitUserListView.selectedArray addObject:userModel.user_id];
|
||||
@@ -459,6 +549,11 @@
|
||||
// }else{
|
||||
// self.funnyView.hidden = YES;
|
||||
// }
|
||||
if (index == 0) {
|
||||
self.sendAllBtn.hidden = NO;
|
||||
}else{
|
||||
self.sendAllBtn.hidden = YES;
|
||||
}
|
||||
}
|
||||
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
|
||||
return self.titles.count;
|
||||
@@ -466,6 +561,9 @@
|
||||
|
||||
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
|
||||
QXSendGiftCollectionView *subGiftView = [[QXSendGiftCollectionView alloc] initWithFrame:listContainerView.bounds];
|
||||
if (index == 0) {
|
||||
self.bagGiftView = subGiftView;
|
||||
}
|
||||
QXGiftLabelModel *md = self.titles[index];
|
||||
subGiftView.roomId = self.roomId;
|
||||
subGiftView.giftLabelId = md.id;
|
||||
@@ -576,6 +674,33 @@
|
||||
[self addSubview:self.collectionView];
|
||||
|
||||
}
|
||||
-(void)reloadData{
|
||||
if ([self.giftLabelId isExist]) {
|
||||
if ([self.giftLabelId isEqualToString:@"-10"]) {
|
||||
MJWeakSelf
|
||||
[QXMineNetwork getBagListSuccessBlock:^(NSArray * _Nonnull list) {
|
||||
[weakSelf.dataArray removeAllObjects];
|
||||
[weakSelf.dataArray addObjectsFromArray:list];
|
||||
BOOL haveGift = NO;
|
||||
for (QXGiftModel *model in list) {
|
||||
if ([weakSelf.model.gift_id isEqualToString:model.gift_id]) {
|
||||
haveGift = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (haveGift == NO) {
|
||||
weakSelf.selectedIndex = -1;
|
||||
weakSelf.model = nil;
|
||||
}
|
||||
[weakSelf.collectionView reloadData];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
}else{
|
||||
[self getGiftListWithLabel:self.giftLabelId];
|
||||
}
|
||||
}
|
||||
}
|
||||
-(void)setGiftLabelId:(NSString *)giftLabelId{
|
||||
_giftLabelId = giftLabelId;
|
||||
if ([giftLabelId isEqualToString:@"-10"]) {
|
||||
@@ -587,6 +712,7 @@
|
||||
-(void)getGiftListWithLabel:(NSString*)label{
|
||||
MJWeakSelf
|
||||
self.selectedIndex = -1;
|
||||
self.model = nil;
|
||||
[QXMineNetwork giftListWithLabel:label roomId:self.roomId successBlock:^(NSArray<QXGiftModel *> * _Nonnull list) {
|
||||
[weakSelf.dataArray removeAllObjects];
|
||||
[weakSelf.dataArray addObjectsFromArray:list];
|
||||
@@ -597,6 +723,7 @@
|
||||
}
|
||||
-(void)getBagList{
|
||||
self.selectedIndex = -1;
|
||||
self.model = nil;
|
||||
MJWeakSelf
|
||||
[QXMineNetwork getBagListSuccessBlock:^(NSArray * _Nonnull list) {
|
||||
[weakSelf.dataArray removeAllObjects];
|
||||
@@ -650,6 +777,7 @@
|
||||
return;
|
||||
}
|
||||
self.selectedIndex = indexPath.row;
|
||||
self.model = self.dataArray[indexPath.row];
|
||||
if (self.selectetGiftBlock) {
|
||||
self.selectetGiftBlock(model);
|
||||
}
|
||||
@@ -885,6 +1013,7 @@
|
||||
-(void)setUsers:(NSArray *)users{
|
||||
_users = users;
|
||||
// [self.selectedArray removeAllObjects];
|
||||
self.allBtn.selected = NO;
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
|
||||
Reference in New Issue
Block a user