1077 lines
43 KiB
Objective-C
Executable File
1077 lines
43 KiB
Objective-C
Executable File
//
|
||
// RoomGiftView.m
|
||
// QiaoYuYueWan
|
||
//
|
||
// Created by aa on 2019/7/19.
|
||
// Copyright © 2019 QiaoYuYueWan. All rights reserved.
|
||
//
|
||
|
||
#import "BJRoomGiftAlert.h"
|
||
#import "BJRoomGiftModel.h"
|
||
#import "BJGiftItemCell.h"
|
||
#import "BJGiftUserCell.h"
|
||
#import "BAButton.h"
|
||
#import "HLHorizontalPageLayout.h"
|
||
#import "QQCorner.h"
|
||
#import "BJWebVC.h"
|
||
#import "YYLuckyCircleView.h"
|
||
#import "BJGiftBlindItemCell.h"
|
||
#import "SPBlindXunlehuiVC.h"
|
||
|
||
@interface BJRoomGiftAlert ()<SVGAPlayerDelegate, UICollectionViewDataSource, UICollectionViewDelegate,UIGestureRecognizerDelegate, JXCategoryViewDelegate>
|
||
|
||
// 各个区域
|
||
@property (nonatomic, strong) UIView *mainView; //弹出动画主要靠它
|
||
@property (nonatomic, strong) UIView *userBgView; // h:60
|
||
@property (nonatomic, strong) UIView *btnChangeBgView; // h:30
|
||
@property (nonatomic, strong) UIView *giftCollBgView; // h: (appw/4 +10) x 2
|
||
@property (nonatomic, strong) UIView *pageCtrlBgView; // h:20
|
||
@property (nonatomic, strong) UIView *botBtnBgView; // h:40
|
||
|
||
@property(nonatomic, strong) UILabel *giftDescLabel;
|
||
|
||
//座位相关
|
||
@property(nonatomic, strong) UICollectionView *usersCollectionView;//顶部选人
|
||
@property(nonatomic, strong) UIButton *selectAllButton;//全麦
|
||
|
||
//礼物类型切换
|
||
@property (nonatomic, strong) NSArray *titles;
|
||
@property (nonatomic, strong) JXCategoryTitleView *categoryView;
|
||
|
||
@property (nonatomic, strong) UIButton *bagAllSendBtn; //一键全送按钮
|
||
|
||
//礼物列表
|
||
@property (nonatomic, strong) UICollectionView *collectView;//礼物
|
||
@property (nonatomic, strong) UICollectionView *blindCollectView;//盲盒礼物
|
||
@property (nonatomic, strong) UIPageControl *pageControl; ///< 礼物翻页指示器
|
||
@property (nonatomic, strong) UIView *jieshaoView;
|
||
@property (nonatomic, copy) NSString *jieshaoUrlStr;
|
||
|
||
//底部按钮
|
||
@property(nonatomic, strong) UIButton *chargeButton;//左下角充值按钮
|
||
@property (nonatomic, strong) UIButton *handselBUtton; ///< 赠送按钮
|
||
@property (nonatomic, strong) UIButton *giftNumButton; ///< 赠送倍率
|
||
|
||
//值
|
||
@property (nonatomic, strong) RCMicRoomViewModel *viewModel; //语音房model,可以拿到实时的座位数据
|
||
|
||
@property (nonatomic, strong) NSMutableArray<RCMicParticipantViewModel *> *userModels; ///< 聊天室内成员列表
|
||
|
||
@property(nonatomic, assign) NSInteger nowGiftType; //当前显示的礼物类型: 1礼物,2背包
|
||
@property (nonatomic, strong) NSMutableArray<BJRoomGiftModel *> *nowModels; //礼物collection 正在使用的数组
|
||
|
||
//结果
|
||
@property (nonatomic, assign) NSInteger wantSendNum; //用户当前想送入礼物数量 -1表示全部
|
||
@property (nonatomic, strong) BJRoomGiftModel *nowSelectedGift; ///用户当前想赠送的礼物 重写get方法,不要主动赋值!!!
|
||
@property (nonatomic, strong) NSArray<NSString *> *nowSendUids; ///用户当前想赠送的人 重写get方法,不要主动赋值!!!
|
||
|
||
@property (nonatomic, assign) CGFloat giftItemW;
|
||
@property (nonatomic, assign) CGFloat mainH;
|
||
|
||
@property (nonatomic, assign) NSInteger currentIndex;
|
||
|
||
//交友厅,帮他插队,需要额外传个要帮的人的id
|
||
@property (nonatomic, copy) NSString *help_uid;
|
||
|
||
@property(nonatomic, strong) UIImageView *downAvatarImgV;
|
||
@property(nonatomic, strong) UILabel *downNicknameLab;
|
||
|
||
@property(nonatomic, assign) NSInteger blindIndex; //盲盒礼物下标
|
||
|
||
@end
|
||
|
||
@implementation BJRoomGiftAlert
|
||
|
||
#pragma mark - ybb
|
||
|
||
- (NSMutableArray<BJRoomGiftModel *> *)nowModels {
|
||
if (!_nowModels) {
|
||
_nowModels = NSMutableArray.array;
|
||
}
|
||
return _nowModels;
|
||
}
|
||
|
||
- (NSMutableArray<RCMicParticipantViewModel *> *)userModels {
|
||
if (!_userModels) {
|
||
_userModels = NSMutableArray.array;
|
||
}
|
||
return _userModels;
|
||
}
|
||
|
||
- (void)setWantSendNum:(NSInteger)wantSendNum {
|
||
_wantSendNum = wantSendNum;
|
||
|
||
if (wantSendNum == -1) {
|
||
[self.giftNumButton setTitle:@"全部" forState:UIControlStateNormal];
|
||
}else {
|
||
NSString *btnText = [NSString stringWithFormat:@"x%@", @(wantSendNum).stringValue];
|
||
[self.giftNumButton setTitle:btnText forState:UIControlStateNormal];
|
||
}
|
||
}
|
||
|
||
- (BJRoomGiftModel *)nowSelectedGift {
|
||
for (BJRoomGiftModel *model in self.nowModels) {
|
||
if (model.isItemSelected) {
|
||
return model;
|
||
break;
|
||
}
|
||
}
|
||
|
||
return nil;
|
||
}
|
||
- (void)setNowSelectedGift:(BJRoomGiftModel *)nowSelectedGift {
|
||
// [SVProgressHUD showInfoWithStatus:@"开发注意,不要主动赋值"];
|
||
}
|
||
|
||
- (NSArray<NSString *> *)nowSendUids {
|
||
NSMutableArray *mutArr = NSMutableArray.array;
|
||
for (RCMicParticipantViewModel *model in self.userModels) {
|
||
if (model.isGiftSelected) {
|
||
[mutArr addObject:C_string(model.participantInfo.userId)];
|
||
}
|
||
}
|
||
return mutArr.copy;
|
||
}
|
||
- (void)setNowSendUids:(NSArray<NSString *> *)nowSendUids {
|
||
// [SVProgressHUD showInfoWithStatus:@"开发注意,不要主动赋值"];
|
||
}
|
||
|
||
#pragma mark - 初始化
|
||
- (instancetype)initWithRoomModel:(RCMicRoomViewModel *)model {
|
||
if (self = [super initWithFrame:UIScreen.mainScreen.bounds]) {
|
||
_viewModel = model;
|
||
self.blindIndex = 0;
|
||
self.currentIndex = 1;
|
||
self.giftItemW = APPW/4;
|
||
self.mainH = 50+ (self.giftItemW+40)*2 +40+34;
|
||
|
||
[self initDefaultValue];
|
||
[self initAllSubView];
|
||
|
||
[self initUserView];
|
||
[self initTwoBtnView];
|
||
[self initGiftCollection];
|
||
[self initToolView];
|
||
|
||
[self initJieshaoView];
|
||
}
|
||
return self;
|
||
}
|
||
|
||
- (void)initDefaultValue {
|
||
self.nowGiftType = 1; //默认为普通礼物
|
||
self.wantSendNum = 1; //默认送出数量是1
|
||
self.titles = @[@"热门", @"趣味", @"情侣", @"麦位", @"爵位", @"挂件", @"背包"];
|
||
}
|
||
|
||
- (void)initAllSubView {
|
||
self.backgroundColor = UIColor.clearColor;
|
||
|
||
//底部返回按钮
|
||
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
backBtn.frame = self.bounds;
|
||
backBtn.backgroundColor = UIColor.clearColor;
|
||
[backBtn setTitle:@"" forState:UIControlStateNormal];
|
||
[backBtn addTarget:self action:@selector(dissmissAction) forControlEvents:UIControlEventTouchUpInside];
|
||
[self addSubview:backBtn];
|
||
|
||
//内容view
|
||
_mainView = [[UIView alloc] initWithFrame:CGRectMake(0, APPH, APPW, _mainH)];
|
||
[self addSubview:_mainView];
|
||
|
||
UIImageView *bgImgV = [ControlCreator createImageView:_mainView rect:_mainView.bounds imageName:@"room_gift_bg" backguoundColor:nil];
|
||
bgImgV.contentMode = UIViewContentModeScaleToFill;
|
||
|
||
//user bg
|
||
_userBgView = [[UIView alloc] initWithFrame:CGRectMake(0, APPH-_mainH-60, APPW, 55)];
|
||
// _userBgView.backgroundColor = HEXCOLORA(0x000000, 0.8);
|
||
// _userBgView.layer.cornerRadius = 10.f;
|
||
[self addSubview:_userBgView];
|
||
|
||
UIImageView *userbgImgV = [ControlCreator createImageView:_userBgView rect:_userBgView.bounds imageName:@"room_gift_user_bg" backguoundColor:nil];
|
||
userbgImgV.contentMode = UIViewContentModeScaleToFill;
|
||
|
||
//btn bg
|
||
_btnChangeBgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 65)];
|
||
[_mainView addSubview:_btnChangeBgView];
|
||
//gift coll bg
|
||
_giftCollBgView = [[UIView alloc] initWithFrame:CGRectMake(0, _btnChangeBgView.bottom, APPW, (_giftItemW+20)*2)];
|
||
[_mainView addSubview:_giftCollBgView];
|
||
//page ctrl bg
|
||
_pageCtrlBgView = [[UIView alloc] initWithFrame:CGRectMake(0, _giftCollBgView.bottom, APPW, 20)];
|
||
[_mainView addSubview:_pageCtrlBgView];
|
||
//tool bg
|
||
_botBtnBgView = [[UIView alloc] initWithFrame:CGRectMake(0, _pageCtrlBgView.bottom, APPW, 40)];
|
||
[_mainView addSubview:_botBtnBgView];
|
||
}
|
||
|
||
- (void)initUserView {
|
||
[ControlCreator createLabel:_userBgView rect:CGRectMake(10, 0, 40, _userBgView.height) text:@"送给:" font:YBBoldFont(14) color:HEXCOLOR(0xFFFFFF) backguoundColor:nil align:NSTextAlignmentCenter lines:1];
|
||
[_userBgView addSubview:self.usersCollectionView];
|
||
[_userBgView addSubview:self.selectAllButton];
|
||
_selectAllButton.frame = CGRectMake(ScreenWidth-58-15, 13.5, 58, 28);
|
||
_usersCollectionView.frame = CGRectMake(15+50, 2, ScreenWidth-15-75-50, 53);
|
||
|
||
[self.usersCollectionView registerClass:[BJGiftUserCell class] forCellWithReuseIdentifier:@"RoomUsersCollectionViewCell"];
|
||
|
||
_downAvatarImgV = [ControlCreator createImageView:_userBgView rect:CGRectMake(10, 10, 40, 40) imageName:nil backguoundColor:nil];
|
||
_downAvatarImgV.layer.cornerRadius = 20;
|
||
_downAvatarImgV.layer.masksToBounds = YES;
|
||
_downAvatarImgV.contentMode = UIViewContentModeScaleAspectFill;
|
||
_downAvatarImgV.hidden = YES;
|
||
|
||
_downNicknameLab = [ControlCreator createLabel:_userBgView rect:CGRectMake(60, 0, 200, 60) text:nil font:YBMediumFont(14) color:kWhiteColor backguoundColor:nil align:NSTextAlignmentLeft lines:1];
|
||
_downAvatarImgV.hidden = YES;
|
||
|
||
// [ControlCreator createView:_userBgView rect:CGRectMake(0, _userBgView.height-0.5, ScreenWidth, 0.5) backguoundColor:HEXCOLORA(0xFFFFFF, 0.3)];
|
||
}
|
||
|
||
- (void)initTwoBtnView {
|
||
[_btnChangeBgView addSubview:self.giftDescLabel];
|
||
self.giftDescLabel.frame = CGRectMake(15, 5, ScreenWidth-30, 25);
|
||
|
||
[_btnChangeBgView addSubview:self.categoryView];
|
||
self.categoryView.frame = CGRectMake(0, 20, ScreenWidth, 50);
|
||
|
||
// [_btnChangeBgView addSubview:self.bagAllSendBtn];
|
||
// self.bagAllSendBtn.frame = CGRectMake(ScreenWidth-76-15, (_btnChangeBgView.height-30)/2, 76, 30);
|
||
}
|
||
|
||
- (void)initGiftCollection {
|
||
|
||
[_giftCollBgView addSubview:self.collectView];
|
||
[_giftCollBgView addSubview:self.blindCollectView];
|
||
self.blindCollectView.hidden = YES;
|
||
|
||
self.collectView.frame = _giftCollBgView.bounds;
|
||
self.blindCollectView.frame = _giftCollBgView.bounds;
|
||
[self.collectView registerClass:[BJGiftItemCell class] forCellWithReuseIdentifier:@"BJGiftViewCell"];
|
||
[self.blindCollectView registerNib:[UINib nibWithNibName:@"BJGiftBlindItemCell" bundle:nil] forCellWithReuseIdentifier:@"BJGiftBlindItemCell"];
|
||
|
||
[_pageCtrlBgView addSubview:self.pageControl];
|
||
self.pageControl.frame = _pageCtrlBgView.bounds;
|
||
}
|
||
|
||
- (void)initToolView {
|
||
|
||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(APPW-116-15, 0, 116, 36)];
|
||
// container.backgroundColor = [kWhiteColor colorWithAlphaComponent:0.1];
|
||
// container.layer.cornerRadius = 17;
|
||
// container.layer.masksToBounds = YES;
|
||
// container.layer.borderWidth = 0.5;
|
||
// container.layer.borderColor = mainDeepColor.CGColor;
|
||
[_botBtnBgView addSubview:container];
|
||
|
||
UIImageView *botBG = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 116, 36)];
|
||
botBG.image = ImageNamed(@"room_gift_bot_send_bg");
|
||
botBG.contentMode = UIViewContentModeScaleToFill;
|
||
[container addSubview:botBG];
|
||
|
||
[container addSubview:self.giftNumButton];//赠送倍率
|
||
[container addSubview:self.handselBUtton];//赠送按钮
|
||
self.giftNumButton.frame = CGRectMake(0, 0, 58, 36);
|
||
self.handselBUtton.frame = CGRectMake(58, 0, 58, 36);
|
||
|
||
[_botBtnBgView addSubview:self.chargeButton];
|
||
self.chargeButton.frame = CGRectMake(10, 4, 170, 30);
|
||
|
||
// [self.handselBUtton styleGradiBlueColor];
|
||
// self.handselBUtton.layer.cornerRadius = 17;
|
||
|
||
[_botBtnBgView addSubview:self.bagAllSendBtn];
|
||
self.bagAllSendBtn.frame = CGRectMake(container.left-76-10, 0, 76, 36);
|
||
|
||
// self.chargeButton.backgroundColor = HEXCOLORA(0xFFFFFF, 0.1);
|
||
|
||
}
|
||
|
||
- (void)initJieshaoView {
|
||
UIView *jieshaoView = [[UIView alloc] initWithFrame:CGRectMake(15, APPH-_mainH-60-75, ScreenWidth-30, 70)];
|
||
jieshaoView.hidden = YES;
|
||
jieshaoView.layer.masksToBounds = YES;
|
||
jieshaoView.layer.cornerRadius = 20;
|
||
[self addSubview:jieshaoView];
|
||
self.jieshaoView = jieshaoView;
|
||
|
||
UIImageView *bgImgV = [[UIImageView alloc] initWithFrame:jieshaoView.bounds];
|
||
// bgImgV.image = ImageNamed(@"blind_jieshao_bg");
|
||
// bgImgV.contentMode = UIViewContentModeScaleToFill;
|
||
[jieshaoView addSubview:bgImgV];
|
||
bgImgV.backgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(ScreenWidth-30, 70) direction:FXGradientChangeDirectionHorizontal startColor:mainLightColor endColor:mainDeepColor];
|
||
|
||
[ControlCreator createLabel:jieshaoView rect:CGRectMake(19, 15, 100, 16) text:@"趣味礼物" font:YBMediumFont(14) color:kBlackColor backguoundColor:nil align:NSTextAlignmentLeft lines:1];
|
||
|
||
[ControlCreator createLabel:jieshaoView rect:CGRectMake(19, 38, 200, 12) text:@"赠送趣味礼盒,随礼开出不同礼物!" font:YBFont(11) color:kBlackColor backguoundColor:nil align:NSTextAlignmentLeft lines:1];
|
||
|
||
UIButton *btn = [ControlCreator createButton:jieshaoView rect:CGRectMake(jieshaoView.width-90-20, 17, 90, 36) text:@"玩法介绍" font:YBMediumFont(12) color:kBlackColor backguoundColor:HEXCOLOR(0xFFFFFF) imageName:nil target:self action:@selector(onJieshao)];
|
||
btn.layer.cornerRadius = 18;
|
||
btn.layer.masksToBounds = YES;
|
||
}
|
||
|
||
-(void)onJieshao {
|
||
[self dissmissAction];
|
||
|
||
BJWebVC *vc = [[BJWebVC alloc] init];
|
||
vc.webUrl = [NSString stringWithFormat:@"%@%@", VERSION_HTTPS_SERVER, self.jieshaoUrlStr];
|
||
[vc pushSelf];
|
||
}
|
||
|
||
#pragma mark - public
|
||
|
||
//弹框显示方法
|
||
- (void)bj_showGiftAlertWithTargetUser:(nullable NSString *)uid helpUid:(nullable NSString *)helpUid {
|
||
self.help_uid = helpUid;
|
||
|
||
//显示出来
|
||
[MainWindow() addSubview:self];
|
||
[UIView animateWithDuration:0.2 animations:^{
|
||
self.mainView.y = APPH-self.mainH;
|
||
}];
|
||
|
||
//刷新麦位信息
|
||
[self refreshUserSeatUIWith:uid];
|
||
|
||
//请求数据,刷新礼物消息、 余额
|
||
[self loadAndRefreshGiftUI];
|
||
|
||
_downAvatarImgV.hidden = _downNicknameLab.hidden = YES;
|
||
_usersCollectionView.hidden = _selectAllButton.hidden = NO;
|
||
}
|
||
|
||
- (void)bj_showMicDownGiftWithDict:(NSDictionary *)dict {
|
||
self.help_uid = @"";
|
||
//显示出来
|
||
[MainWindow() addSubview:self];
|
||
[UIView animateWithDuration:0.2 animations:^{
|
||
self.mainView.y = APPH-self.mainH;
|
||
}];
|
||
|
||
_downAvatarImgV.hidden = _downNicknameLab.hidden = NO;
|
||
_usersCollectionView.hidden = _selectAllButton.hidden = YES;
|
||
|
||
[_downAvatarImgV sd_setImageWithURL:[NSURL URLWithString:[dict safeStringForKey:@"head_pic"]] placeholderImage:kDefaultUserIcon];
|
||
_downNicknameLab.text = [dict safeStringForKey:@"nick_name"];
|
||
|
||
[self.userModels removeAllObjects];
|
||
NSDictionary *infoDict = @{@"mc_user_info":dict};
|
||
RCMicParticipantInfo *info = [RCMicParticipantInfo initWithDict:infoDict];
|
||
RCMicParticipantViewModel *model = [[RCMicParticipantViewModel alloc] initWithParticipantInfo:info];
|
||
model.isGiftSelected = YES;
|
||
[self.userModels addObject:model];
|
||
|
||
//请求数据,刷新礼物消息、 余额
|
||
[self loadAndRefreshGiftUI];
|
||
}
|
||
|
||
#pragma mark - 刷新麦位的信息
|
||
- (void)refreshUserSeatUIWith:(NSString *)defaultUid {
|
||
[self.userModels removeAllObjects];
|
||
for (int i=0; i<10; i++) {
|
||
RCMicParticipantViewModel *object = [_viewModel.participantDataSource objectForKey:@(i).stringValue];
|
||
if (object) {
|
||
object.isGiftSelected = NO; //先不用深拷贝,重置为NO试试
|
||
[self.userModels addObject:object];
|
||
}
|
||
|
||
//没有指定送礼物对象,房主在的话,就是房主
|
||
// if (defaultUid.length==0 && i==0 && object.userInfo.userId.length>0) {
|
||
// object.isGiftSelected = YES;
|
||
// }
|
||
|
||
//匹配到指定的人
|
||
if (defaultUid.length>0 && [object.participantInfo.userId isEqualToString:defaultUid]) {
|
||
object.isGiftSelected = YES;
|
||
}
|
||
}
|
||
|
||
[self.usersCollectionView reloadData];
|
||
|
||
self.selectAllButton.selected = NO;
|
||
}
|
||
|
||
#pragma mark - 请求礼物接口,并刷新
|
||
- (void)loadAndRefreshGiftUI {
|
||
NSDictionary *dict = @{@"type":@(self.currentIndex)};
|
||
NSMutableDictionary *paras = [NSMutableDictionary dictionary];
|
||
[paras addEntriesFromDictionary:dict];
|
||
|
||
// [SVProgressHUD showWithStatus:nil];
|
||
[RCMicHTTP postWithURLString:@"/api/gift/get_room_gift_list" parameters:paras response:^(RCMicHTTPResult *result) {
|
||
// [SVProgressHUD dismiss];
|
||
if (result.success) {
|
||
if (result.errorCode == 200 && [result.content isKindOfClass:NSDictionary.class]) {
|
||
[self refreshGiftListWhenGetResult:result.content]; //
|
||
}else {
|
||
[SVProgressHUD showInfoWithStatus:result.message];
|
||
}
|
||
}else {
|
||
[SVProgressHUD showInfoWithStatus:@"获取最新礼物列表网络错误"];
|
||
}
|
||
}];
|
||
}
|
||
|
||
- (void)refreshGiftListWhenGetResult:(NSDictionary *)dict {
|
||
//获取上次选中的礼物id,如果有
|
||
NSString *lastGiftId = self.nowSelectedGift.gid;
|
||
|
||
[self.nowModels removeAllObjects];
|
||
//普通礼物
|
||
NSArray *norGiftArr = [dict safeArrayForKey:@"gift_list"];
|
||
for (NSDictionary *each in norGiftArr) {
|
||
BJRoomGiftModel *model = [BJRoomGiftModel mj_objectWithKeyValues:each];
|
||
if (lastGiftId.length>0 && [model.gid isEqualToString:lastGiftId]) {
|
||
model.isItemSelected = YES;
|
||
}
|
||
[_nowModels addObject:model];
|
||
}
|
||
[self.collectView reloadData];
|
||
[self.blindCollectView reloadData];
|
||
|
||
//刷新分页控制器
|
||
[self refreshPageCtrl];
|
||
|
||
//刷新余额
|
||
NSString *moneyLeft = [dict safeStringForKey:@"integral"];
|
||
if (_nowGiftType != 2) {
|
||
[self.chargeButton setTitle:[NSString stringWithFormat:@"%ld 去充值>", [moneyLeft integerValue]] forState:UIControlStateNormal];
|
||
[self.chargeButton setImage:ImageNamed(@"room_gift_coin") forState:UIControlStateNormal];
|
||
}else {
|
||
NSString *bagPrice = [dict safeStringForKey:@"user_pack_gift_price"];
|
||
[self.chargeButton setTitle:[NSString stringWithFormat:@"总价值:%@", bagPrice] forState:UIControlStateNormal];
|
||
[self.chargeButton setImage:ImageNamed(@"") forState:UIControlStateNormal];
|
||
}
|
||
|
||
}
|
||
|
||
#pragma mark - action
|
||
- (void)dissmissAction {
|
||
[UIView animateWithDuration:0.2 animations:^{
|
||
self.mainView.y = APPH;
|
||
|
||
} completion:^(BOOL finished) {
|
||
[self removeFromSuperview];
|
||
}];
|
||
}
|
||
|
||
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
|
||
if (index == 1){
|
||
self.currentIndex = 5;
|
||
}else if (index == 2){
|
||
self.currentIndex = 3;
|
||
}else if (index == 3){
|
||
self.currentIndex = 7;
|
||
}else if (index == 4){
|
||
self.currentIndex = 6;
|
||
}else if (index == 5){
|
||
self.currentIndex = 8;
|
||
}else if (index == 6){
|
||
self.currentIndex = 2;
|
||
}else{
|
||
self.currentIndex = index+1;
|
||
}
|
||
|
||
self.collectView.hidden = NO;
|
||
self.blindCollectView.hidden = YES;
|
||
self.nowGiftType = 1;
|
||
self.bagAllSendBtn.hidden = YES;
|
||
self.jieshaoView.hidden = YES;
|
||
if (index == 6) {
|
||
self.nowGiftType = 2;
|
||
//狸猫隐藏一键全送
|
||
self.bagAllSendBtn.hidden = NO;
|
||
}
|
||
if (index == 1) {
|
||
//盲盒
|
||
self.collectView.hidden = YES;
|
||
self.blindCollectView.hidden = NO;
|
||
self.jieshaoView.hidden = NO;
|
||
self.jieshaoUrlStr = @"index.php/index/index/page_show?id=13";
|
||
}
|
||
self.wantSendNum = 1;
|
||
[self loadAndRefreshGiftUI];
|
||
}
|
||
|
||
- (void)refreshPageCtrl {
|
||
if (self.nowModels.count > 0) {
|
||
NSInteger pageCount = self.nowModels.count/8;
|
||
if (self.nowModels.count%8 > 0) {
|
||
pageCount ++;
|
||
}
|
||
self.pageControl.numberOfPages = pageCount;
|
||
self.pageControl.currentPage = 0;
|
||
}else {
|
||
self.pageControl.numberOfPages = 0;
|
||
}
|
||
}
|
||
|
||
- (void)selectAllUserBtnTouched:(UIButton *)sender {
|
||
sender.selected = !sender.selected;
|
||
BOOL needSelectAll = sender.selected;
|
||
|
||
for (RCMicParticipantViewModel *model in self.userModels) {
|
||
if (model.participantInfo.userId.length > 0) {
|
||
model.isGiftSelected = needSelectAll;
|
||
}
|
||
}
|
||
[_usersCollectionView reloadData];
|
||
|
||
// if (_selectAllButton.isSelected) {
|
||
//// [_selectAllButton styleGradiBlueColor];
|
||
// _selectAllButton.backgroundColor = mainDeepColor;
|
||
// }else {
|
||
// _selectAllButton.backgroundColor = [kWhiteColor colorWithAlphaComponent:0.3];
|
||
// }
|
||
}
|
||
|
||
- (void)topUpButtonClick:(UIButton *)sender{
|
||
if ([sender.titleLabel.text containsString:@"充值"]) {
|
||
! self.topUpButtonClickBlock ?: self.topUpButtonClickBlock();
|
||
[self dissmissAction];
|
||
}else{
|
||
|
||
}
|
||
}
|
||
|
||
- (void)giftNumButtonClick:(UIButton *)sender {
|
||
UIAlertController *sheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
|
||
NSArray<NSString *> *titleArr = @[@"99",@"66", @"30", @"10", @"5", @"3", @"1"];
|
||
//幸运礼物
|
||
// if (self.currentIndex == 3) {
|
||
// titleArr = @[@"999", @"520", @"188", @"99", @"66", @"10", @"1"];
|
||
// }
|
||
if (_nowGiftType == 2) {
|
||
[sheet addAction:[UIAlertAction actionWithTitle:@"全部" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
||
self.wantSendNum = -1;
|
||
}]];
|
||
}
|
||
for (NSString *btnText in titleArr) {
|
||
NSString *fixText = [NSString stringWithFormat:@"x%@", btnText];
|
||
[sheet addAction:[UIAlertAction actionWithTitle:fixText style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
||
self.wantSendNum = btnText.integerValue;
|
||
}]];
|
||
}
|
||
|
||
[sheet addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
|
||
[UIViewController.currentViewController presentViewController:sheet animated:YES completion:nil];
|
||
}
|
||
|
||
#pragma mark - 确定按钮
|
||
|
||
- (void)sendGiftBtntouched {
|
||
BJRoomGiftModel *finalGift = self.nowSelectedGift;
|
||
NSArray *finalUids = self.nowSendUids;
|
||
NSInteger finalSendNum = self.wantSendNum;
|
||
|
||
if (finalUids.count==0) {
|
||
[SVProgressHUD showInfoWithStatus:@"请选择送给谁"];
|
||
return;
|
||
}
|
||
|
||
if (finalGift == nil) {
|
||
[SVProgressHUD showInfoWithStatus:@"请选择要送出的礼物"];
|
||
return;
|
||
}
|
||
|
||
//背包礼物的限制
|
||
if (_nowGiftType == 2) {
|
||
//一键全送 的判断逻辑不在这
|
||
|
||
if (_wantSendNum == -1 && finalUids.count>1) {
|
||
[SVProgressHUD showInfoWithStatus:@"全部送出礼物只能选择一个人"];
|
||
return;
|
||
}
|
||
}
|
||
|
||
finalGift.sendUids = finalUids;
|
||
finalGift.giftBagType = _nowGiftType;
|
||
finalGift.userSendNum = finalSendNum;
|
||
if (_nowGiftType==2 && finalSendNum==-1) {
|
||
finalGift.userSendNum = finalGift.num.integerValue;
|
||
}
|
||
|
||
//总结:礼物 数量 对象 类型
|
||
NSString *tip = [NSString stringWithFormat:@"礼物:%@, 类型:%@, 数量%@, 给谁:%@", finalGift.gift_name, finalGift.giftBagType==2?@"背包":@"普通", @(finalGift.userSendNum).stringValue, finalGift.sendUids.mj_JSONString];
|
||
NSLog(@"%@", tip);
|
||
|
||
if ([finalGift.gift_price integerValue] >= 5000) {
|
||
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"确定送出该礼物吗?" message:nil preferredStyle:UIAlertControllerStyleAlert];
|
||
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
||
[self readySendGift:finalGift];
|
||
}]];
|
||
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
|
||
[[UIViewController currentViewController] presentViewController:alert animated:YES completion:nil];
|
||
}else {
|
||
[self readySendGift:finalGift];
|
||
}
|
||
}
|
||
|
||
- (void)readySendGift:(BJRoomGiftModel *)model {
|
||
NSString *fixUids = [model.sendUids componentsJoinedByString:@","];
|
||
NSDictionary *dict = @{@"rid":C_string(_viewModel.roomInfo.roomId),
|
||
@"gid":C_string(model.gid),
|
||
@"num":@(model.userSendNum),
|
||
@"to_uid_list":C_string(fixUids),
|
||
@"pack":@(model.giftBagType),
|
||
};
|
||
NSMutableDictionary *paras = [NSMutableDictionary dictionary];
|
||
[paras addEntriesFromDictionary:dict];
|
||
|
||
if (self.help_uid.length > 0) {
|
||
[paras setObject:self.help_uid forKey:@"help_uid"];
|
||
}
|
||
|
||
// [SVProgressHUD showWithStatus:nil];
|
||
[RCMicHTTP postWithURLString:@"/api/gift/send_gift" parameters:paras response:^(RCMicHTTPResult *result) {
|
||
// [SVProgressHUD dismiss];
|
||
if (result.success) {
|
||
// [SVProgressHUD showInfoWithStatus:@"送礼物成功"];
|
||
//收到socket之后,会有聊天消息和全屏动画
|
||
//请求数据,刷新礼物消息、 余额
|
||
if (result.errorCode == 200) {
|
||
[self loadAndRefreshGiftUI];
|
||
if (self.judgeBoxBlock) {
|
||
self.judgeBoxBlock();
|
||
}
|
||
//幸运礼物
|
||
if (self.currentIndex == 3 || self.currentIndex == 5) {
|
||
YYLuckyCircleView *view = [[YYLuckyCircleView alloc] initWithFrame:CGRectMake(ScreenWidth-66-15, ScreenHeight-66-110, 66, 66)];
|
||
view.imgStr = model.base_image;
|
||
view.paramsDict = paras;
|
||
view.moneyStr = [result.content safeStringForKey:@"integral"];
|
||
view.viewModel = self.viewModel;
|
||
[KEYWINDOW addSubview:view];
|
||
|
||
[self removeFromSuperview];
|
||
}
|
||
|
||
//自己送礼物的托盘,用接口展示
|
||
NSArray *arr = [result.content safeArrayForKey:@"data"];
|
||
for (NSDictionary *dict in arr) {
|
||
//礼物托盘
|
||
self.viewModel.receivedGiftTuopan? self.viewModel.receivedGiftTuopan(dict) : nil;
|
||
}
|
||
|
||
}else if (result.errorCode == 302) {
|
||
//频繁不提示
|
||
}else {
|
||
[MBProgressHUD showAutoMessage:result.message];
|
||
}
|
||
}
|
||
|
||
}];
|
||
}
|
||
|
||
- (void)sendAllBagBtn {
|
||
NSArray *finalUids = self.nowSendUids;
|
||
if (finalUids.count==0) {
|
||
[SVProgressHUD showInfoWithStatus:@"请选择送给谁"];
|
||
return;
|
||
}
|
||
if (finalUids.count>1) {
|
||
[SVProgressHUD showInfoWithStatus:@"一键全送只能选一个人"];
|
||
return;
|
||
}
|
||
|
||
BJRoomGiftModel *finalGift = [[BJRoomGiftModel alloc] init];
|
||
finalGift.sendUids = finalUids;
|
||
finalGift.isBagSendAll = YES;
|
||
|
||
[self readyBagSendAll:finalGift giftArr:[self.nowModels copy]];
|
||
}
|
||
|
||
- (void)readyBagSendAll:(BJRoomGiftModel *)model giftArr:(NSArray *)giftArr {
|
||
NSString *nick_name = @"";
|
||
for (RCMicParticipantViewModel *model in self.userModels) {
|
||
if (model.isGiftSelected) {
|
||
nick_name = model.participantInfo.nick_name;
|
||
}
|
||
}
|
||
NSString *str = [NSString stringWithFormat:@"礼物将一键全送给%@用户,是否赠送(如发现礼物套现,买卖等行为,将封禁账号)", nick_name];
|
||
__weak __typeof(self)weakSelf = self;
|
||
UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:str preferredStyle:UIAlertControllerStyleAlert];
|
||
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
||
|
||
NSDictionary *dict = @{@"rid":C_string(weakSelf.viewModel.roomInfo.roomId),
|
||
@"recived_uid":C_string(model.sendUids.firstObject),
|
||
};
|
||
NSMutableDictionary *paras = [NSMutableDictionary dictionary];
|
||
[paras addEntriesFromDictionary:dict];
|
||
|
||
if (self.help_uid.length > 0) {
|
||
[paras setObject:self.help_uid forKey:@"help_uid"];
|
||
}
|
||
|
||
// [SVProgressHUD showWithStatus:nil];
|
||
[RCMicHTTP postWithURLString:@"/api/gift/send_all_pack_gift" parameters:paras response:^(RCMicHTTPResult *result) {
|
||
[SVProgressHUD dismiss];
|
||
if (result.success) {
|
||
if (result.errorCode == 200) {
|
||
if (self.judgeBoxBlock) {
|
||
self.judgeBoxBlock();
|
||
}
|
||
[self dissmissAction];
|
||
}else {
|
||
[SVProgressHUD showInfoWithStatus:result.message];
|
||
}
|
||
}else {
|
||
[SVProgressHUD showInfoWithStatus:@"网络错误"];
|
||
}
|
||
}];
|
||
|
||
}]];
|
||
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
|
||
[[UIViewController currentViewController] presentViewController:alert animated:YES completion:nil];
|
||
}
|
||
|
||
#pragma mark UICollectionView delegate
|
||
|
||
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
|
||
return 1;
|
||
}
|
||
|
||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
||
if ([collectionView isEqual:_usersCollectionView]) {
|
||
return self.userModels.count;
|
||
}
|
||
else if([collectionView isEqual:_collectView]){
|
||
return self.nowModels.count;
|
||
}else if ([collectionView isEqual:_blindCollectView]){
|
||
return self.nowModels.count;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||
//麦位
|
||
if ([collectionView isEqual:_usersCollectionView]) {
|
||
BJGiftUserCell *cell = [BJGiftUserCell cellWithCollectionView:collectionView forIndexPath:indexPath];
|
||
RCMicParticipantViewModel *model = self.userModels[indexPath.item];
|
||
cell.model = model;
|
||
return cell;
|
||
}
|
||
|
||
//礼物
|
||
if([collectionView isEqual:_collectView]){
|
||
BJRoomGiftModel *model = self.nowModels[indexPath.item];
|
||
|
||
BJGiftItemCell *cell = [BJGiftItemCell cellWithCollectionView:collectionView forIndexPath:indexPath];
|
||
model.giftBagType = _nowGiftType;
|
||
cell.model = model;
|
||
return cell;
|
||
}
|
||
|
||
//盲盒礼物
|
||
if([collectionView isEqual:_blindCollectView]){
|
||
BJRoomGiftModel *model = self.nowModels[indexPath.item];
|
||
|
||
BJGiftBlindItemCell *cell = [BJGiftBlindItemCell cellWithCollectionView:collectionView forIndexPath:indexPath];
|
||
|
||
if ([model.gift_name isEqualToString:@"中级盲盒"]) {
|
||
UILongPressGestureRecognizer *longGes = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressAction:)];
|
||
[cell addGestureRecognizer:longGes];
|
||
_blindIndex = indexPath.item;
|
||
|
||
cell.xylLab.hidden = NO;
|
||
}else {
|
||
cell.xylLab.hidden = YES;
|
||
}
|
||
|
||
model.giftBagType = _nowGiftType;
|
||
cell.model = model;
|
||
return cell;
|
||
}
|
||
|
||
return nil;
|
||
}
|
||
|
||
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
|
||
|
||
//点击座位
|
||
if ([collectionView isEqual:_usersCollectionView]) {
|
||
RCMicParticipantViewModel *model = self.userModels[indexPath.item];
|
||
|
||
//空座位不能点
|
||
if (model.participantInfo.userId.length == 0) {
|
||
return;
|
||
}
|
||
|
||
model.isGiftSelected = !model.isGiftSelected;
|
||
BJGiftUserCell *userCell = (BJGiftUserCell *)[collectionView cellForItemAtIndexPath:indexPath];
|
||
userCell.model = model;
|
||
}
|
||
|
||
//点击礼物
|
||
if (collectionView==self.collectView) {
|
||
//暴力取消上次,如果有
|
||
for (BJRoomGiftModel *model in self.nowModels) {
|
||
model.isItemSelected = NO;
|
||
}
|
||
for (BJGiftItemCell *showCell in collectionView.visibleCells) {
|
||
[showCell changeUISelected:NO];
|
||
}
|
||
|
||
//选中
|
||
BJRoomGiftModel *model = _nowModels[indexPath.item];
|
||
model.isItemSelected = YES;
|
||
|
||
BJGiftItemCell *nowCell = (BJGiftItemCell *)[collectionView cellForItemAtIndexPath:indexPath];
|
||
nowCell.model = model;
|
||
}
|
||
|
||
//点击盲盒礼物
|
||
if (collectionView==self.blindCollectView) {
|
||
//暴力取消上次,如果有
|
||
for (BJRoomGiftModel *model in self.nowModels) {
|
||
model.isItemSelected = NO;
|
||
}
|
||
for (BJGiftBlindItemCell *showCell in collectionView.visibleCells) {
|
||
[showCell changeUISelected:NO];
|
||
}
|
||
|
||
//选中
|
||
BJRoomGiftModel *model = _nowModels[indexPath.item];
|
||
model.isItemSelected = YES;
|
||
|
||
if (indexPath.item == 0) {
|
||
self.wantSendNum = 1;
|
||
}
|
||
|
||
BJGiftBlindItemCell *nowCell = (BJGiftBlindItemCell *)[collectionView cellForItemAtIndexPath:indexPath];
|
||
nowCell.model = model;
|
||
}
|
||
}
|
||
|
||
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
|
||
if ([scrollView isEqual:_collectView]) {
|
||
float x = scrollView.contentOffset.x/CGRectGetWidth(self.collectView.frame);
|
||
self.pageControl.currentPage = ceilf(x);
|
||
}
|
||
}
|
||
|
||
- (void)longPressAction:(UIGestureRecognizer *)recognizer {
|
||
//长按手势只执行一次
|
||
if (recognizer.state == UIGestureRecognizerStateBegan) {
|
||
BJRoomGiftModel *model = self.nowModels[_blindIndex];
|
||
NSArray *finalUids = self.nowSendUids;
|
||
if (finalUids.count == 0) {
|
||
[SVProgressHUD showInfoWithStatus:@"请选择送给谁"];
|
||
return;
|
||
}
|
||
|
||
if ([[self getCurrentVC] isEqual:[SPBlindXunlehuiVC new]]) {
|
||
return;
|
||
}
|
||
|
||
SPBlindXunlehuiVC *vc = [[SPBlindXunlehuiVC alloc] initWithViewModel:_viewModel];
|
||
vc.rid = _viewModel.roomInfo.roomId;
|
||
vc.gid = model.gid;
|
||
vc.to_uid = self.nowSendUids.firstObject;
|
||
[self removeFromSuperview];
|
||
[vc pushSelf];
|
||
}
|
||
}
|
||
|
||
#pragma mark ====================== 懒加载 ======================
|
||
|
||
- (UIButton *)chargeButton{
|
||
if (!_chargeButton) {
|
||
_chargeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
_chargeButton.backgroundColor = HEXCOLORA(0xFFFFFF, 0.1);
|
||
_chargeButton.layer.cornerRadius = 15;
|
||
_chargeButton.layer.masksToBounds = YES;
|
||
[_chargeButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
|
||
_chargeButton.titleLabel.font = YBMediumFont(12);
|
||
[_chargeButton setImage:ImageNamed(@"room_gift_coin") forState:UIControlStateNormal];
|
||
[_chargeButton setTitle:@"999.00 >" forState:UIControlStateNormal];
|
||
_chargeButton.ba_buttonLayoutType = BAKit_ButtonLayoutTypeLeftImageLeft;
|
||
_chargeButton.ba_padding = 5;
|
||
[_chargeButton addTarget:self action:@selector(topUpButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||
}
|
||
return _chargeButton;
|
||
}
|
||
- (UIButton *)selectAllButton{
|
||
if (!_selectAllButton) {
|
||
_selectAllButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
// [_selectAllButton setTitleColor:HEXCOLOR(0x13131F) forState:UIControlStateNormal];
|
||
// _selectAllButton.titleLabel.font = YBMediumFont(12);
|
||
// _selectAllButton.layer.cornerRadius = 19;
|
||
// _selectAllButton.clipsToBounds = YES;
|
||
// _selectAllButton.backgroundColor = [kWhiteColor colorWithAlphaComponent:0.3];
|
||
// [_selectAllButton setTitle:@"全麦" forState:UIControlStateNormal];
|
||
[_selectAllButton setImage:ImageNamed(@"room_user_all_unSelect") forState:UIControlStateNormal];
|
||
[_selectAllButton setImage:ImageNamed(@"room_user_all_select") forState:UIControlStateSelected];
|
||
[_selectAllButton addTarget:self action:@selector(selectAllUserBtnTouched:) forControlEvents:UIControlEventTouchUpInside];
|
||
}
|
||
return _selectAllButton;
|
||
}
|
||
|
||
-(UICollectionView *)collectView
|
||
{
|
||
if (!_collectView) {
|
||
HLHorizontalPageLayout *pagelayout = [[HLHorizontalPageLayout alloc] init];
|
||
CGFloat itemW = ScreenWidth/4;
|
||
pagelayout.itemSize = CGSizeMake(itemW, itemW+20);
|
||
pagelayout.minimumInteritemSpacing = 0;
|
||
pagelayout.minimumLineSpacing = 0;
|
||
// pagelayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||
|
||
_collectView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:pagelayout];
|
||
_collectView.dataSource=self;
|
||
_collectView.delegate=self;
|
||
_collectView.showsHorizontalScrollIndicator = NO;
|
||
_collectView.pagingEnabled = YES;
|
||
_collectView.multipleTouchEnabled = NO;
|
||
// _collectView.backgroundColor = [UIColor colorWithRed:0.110 green:0.102 blue:0.149 alpha:1.000];
|
||
_collectView.backgroundColor = UIColor.clearColor;
|
||
}
|
||
return _collectView;
|
||
}
|
||
|
||
- (UICollectionView *)blindCollectView {
|
||
if (!_blindCollectView) {
|
||
HLHorizontalPageLayout *pagelayout = [[HLHorizontalPageLayout alloc] init];
|
||
CGFloat itemW = (ScreenWidth-15*2-10*3)/4;
|
||
pagelayout.itemSize = CGSizeMake(itemW, itemW+30);
|
||
pagelayout.minimumInteritemSpacing = 0;
|
||
pagelayout.minimumLineSpacing = 10;
|
||
pagelayout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 15);
|
||
// pagelayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||
|
||
_blindCollectView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:pagelayout];
|
||
_blindCollectView.dataSource=self;
|
||
_blindCollectView.delegate=self;
|
||
_blindCollectView.showsHorizontalScrollIndicator = NO;
|
||
_blindCollectView.pagingEnabled = YES;
|
||
_blindCollectView.multipleTouchEnabled = NO;
|
||
// _collectView.backgroundColor = [UIColor colorWithRed:0.110 green:0.102 blue:0.149 alpha:1.000];
|
||
_blindCollectView.backgroundColor = UIColor.clearColor;
|
||
}
|
||
return _blindCollectView;
|
||
}
|
||
|
||
-(UICollectionView *)usersCollectionView
|
||
{
|
||
if (!_usersCollectionView) {
|
||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||
// UserFlowLayout *layout = [[UserFlowLayout alloc] init];
|
||
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||
layout.itemSize = CGSizeMake(50, 65);
|
||
layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
|
||
_usersCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
||
_usersCollectionView.dataSource=self;
|
||
_usersCollectionView.delegate=self;
|
||
_usersCollectionView.showsVerticalScrollIndicator = NO;
|
||
// _usersCollectionView.backgroundColor = [UIColor colorWithRed:0.110 green:0.102 blue:0.149 alpha:1.000];
|
||
_usersCollectionView.backgroundColor = UIColor.clearColor;
|
||
|
||
}
|
||
return _usersCollectionView;
|
||
}
|
||
-(UIPageControl *)pageControl
|
||
{
|
||
if (!_pageControl) {
|
||
_pageControl = [[UIPageControl alloc] init];
|
||
_pageControl.pageIndicatorTintColor = [UIColor grayColor];
|
||
_pageControl.currentPageIndicatorTintColor = [UIColor whiteColor];
|
||
_pageControl.enabled = NO;
|
||
}
|
||
return _pageControl;
|
||
}
|
||
|
||
/// 赠送
|
||
- (UIButton *)handselBUtton{
|
||
if (!_handselBUtton) {
|
||
_handselBUtton = [ControlCreator createButton:nil rect:CGRectZero text:@"" font:YBMediumFont(14) color:HEXCOLOR(0xFFFFFF) backguoundColor:kClearColor imageName:@"gift_zengsong" target:self action:@selector(sendGiftBtntouched)];
|
||
}
|
||
return _handselBUtton;
|
||
}
|
||
- (UIButton *)giftNumButton{
|
||
if (!_giftNumButton) {
|
||
_giftNumButton = [ControlCreator createButton:nil rect:CGRectZero text:@"x1" font:YBMediumFont(14) color:HEXCOLOR(0xFFFFFF) backguoundColor:nil imageName:@"" target:self action:@selector(giftNumButtonClick:)];
|
||
}
|
||
return _giftNumButton;
|
||
}
|
||
|
||
- (UIButton *)bagAllSendBtn {
|
||
if (!_bagAllSendBtn) {
|
||
_bagAllSendBtn = [ControlCreator createButton:nil rect:CGRectZero text:@"" font:YBMediumFont(12) color:nil backguoundColor:nil imageName:nil target:self action:@selector(sendAllBagBtn)];
|
||
[_bagAllSendBtn setImage:ImageNamed(@"room_gift_all_send") forState:UIControlStateNormal];
|
||
// _bagAllSendBtn.layer.cornerRadius = 15;
|
||
// _bagAllSendBtn.layer.borderColor = mainDeepColor.CGColor;
|
||
// _bagAllSendBtn.layer.borderWidth = 0.5;
|
||
_bagAllSendBtn.hidden = YES;
|
||
}
|
||
return _bagAllSendBtn;
|
||
}
|
||
|
||
// 分页菜单视图
|
||
- (JXCategoryTitleView *)categoryView {
|
||
if (!_categoryView) {
|
||
_categoryView = [[JXCategoryTitleView alloc] init];
|
||
_categoryView.delegate = self;
|
||
_categoryView.titleFont = YBMediumFont(14);
|
||
_categoryView.titleSelectedFont = YBBoldFont(15);
|
||
_categoryView.titleColor = HEXCOLORA(0xFFFFFF, 0.5);
|
||
_categoryView.titleSelectedColor = [UIColor whiteColor];
|
||
_categoryView.cellSpacing = 10;
|
||
// _categoryView.averageCellSpacingEnabled = NO;
|
||
_categoryView.contentEdgeInsetLeft = 16;
|
||
_categoryView.contentEdgeInsetRight = 16;
|
||
|
||
_categoryView.titles = self.titles;
|
||
|
||
JXCategoryIndicatorImageView *lineView = [[JXCategoryIndicatorImageView alloc] init];
|
||
lineView.indicatorImageViewSize = CGSizeMake(15, 15);
|
||
lineView.indicatorImageView.image = ImageNamed(@"room_gift_alert_zhishi");
|
||
lineView.verticalMargin = 22;
|
||
lineView.horizontalMargin = 20;
|
||
_categoryView.indicators = @[lineView];
|
||
|
||
// JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
|
||
// lineView.indicatorWidth = 10;
|
||
// lineView.indicatorHeight = 3;
|
||
// lineView.indicatorCornerRadius = 1.5;
|
||
// lineView.indicatorColor = [UIColor whiteColor];
|
||
// lineView.verticalMargin = 6;
|
||
// lineView.lineStyle = JXCategoryIndicatorLineStyle_Lengthen;
|
||
// _categoryView.indicators = @[lineView];
|
||
}
|
||
return _categoryView;
|
||
}
|
||
|
||
#pragma mark 暂不用
|
||
//通过我的钱包接口,获取余额,避免再次调用礼物列表去刷新数据
|
||
- (void)loadWalletData
|
||
{
|
||
// __weak __typeof(self)weakSelf = self;
|
||
// NSDictionary *dic = @{@"user_id":[BJUserManager userInfo].uid};
|
||
// [BJHttpTool BJ_get_user_moneyWithParameters:@{} success:^(id response) {
|
||
//// WalletModel *walletModel = [WalletModel mj_objectWithKeyValues:response[@"data"]];
|
||
//// weakSelf.myQbi = walletModel.mizuan;
|
||
// [weakSelf.chargeButton setTitle:[NSString stringWithFormat:@"%@ >",response[@"data"][@"integral"]] forState:UIControlStateNormal];
|
||
// [weakSelf.chargeButton setImage:ImageNamed(@"room_gift_coin") forState:UIControlStateNormal];
|
||
// } failure:^(NSError *error) {
|
||
//
|
||
// }];
|
||
|
||
}
|
||
|
||
- (UILabel *)giftDescLabel {
|
||
if (!_giftDescLabel) {
|
||
_giftDescLabel = [[UILabel alloc] init];
|
||
_giftDescLabel.font = YBFont(9);
|
||
_giftDescLabel.numberOfLines = 2;
|
||
|
||
NSString *string = @"返现行为违法,请所有用户遵守平台规定,避免讨论返现等话题,违者将做封号处理!";
|
||
NSMutableAttributedString *arrString = [[NSMutableAttributedString alloc] initWithString:string attributes:@{NSFontAttributeName: YBFont(9),NSForegroundColorAttributeName: HEXCOLOR(0xFFFFFF)}];
|
||
|
||
NSRange range = [string rangeOfString:@"违者将做封号处理!"];
|
||
[arrString yy_setColor:kRedColor range:range];
|
||
|
||
_giftDescLabel.attributedText = arrString;
|
||
}
|
||
return _giftDescLabel;
|
||
}
|
||
|
||
@end
|