123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- //
- // YOUPAILZCommonGiftView.m
- // VQU
- //
- // Created by 肖浩然的mac on 2021/8/20.
- // Copyright © 2021 leo. All rights reserved.
- //
- #import "YOUPAIHRChatRoomGiftView.h"
- #import "JXCategoryView.h"
- #import "JXPagerView.h"
- #import "YOUPAILZCommonGiftVC.h"
- #import "YOUPAILZCommonGiftListModel.h"
- #import "UIViewController+TFPresent.h"
- #import "YOUPAIHRChatRoomSubGiftVC.h"
- #import "YOUPAIHRChatRoomHeaderView.h"
- #import "YOUPAIHRChatRoomGiftModel.h"
- #import "YOUPAILZChatRoomSeatModel.h"
- #define LZCategoryViewHeight 54.0f
- #define LZCategoryViewItemWidth 65.0f
- @interface YOUPAIHRChatRoomGiftView ()<JXCategoryViewDelegate,JXPagerViewDelegate,JXCategoryListContainerViewDelegate,GiftSenderDelegate>
- @property (nonatomic, weak) JXCategoryListContainerView *youpaippagerView;
- @property (nonatomic, strong) JXCategoryTitleView *youpaipcategoryView;
- /* titlearr */
- @property (strong, nonatomic) NSArray *youpaiptitlesArr;
- /* youpaipfirstBtn */
- @property (strong, nonatomic) UIButton *youpaipfirstBtn;
- @property (strong, nonatomic) YOUPAILCFirstRechargeModel *youpaipfirstRechargeModel;
- @property (nonatomic, strong) NSMutableArray <YOUPAILZChatRoomSeatModel *>*youpaipseats;
- @property (nonatomic, strong)YOUPAIHRChatRoomHeaderView *youpaipheadView;
- @end
- @implementation YOUPAIHRChatRoomGiftView
- - (void)dealloc{
- [[NSNotificationCenter defaultCenter] removeObserver:self];
-
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.baseView.hidden = YES;
- // self.youpaiptitlesArr = @[@"1",@"2",@"3"];
-
- dispatch_group_t group = dispatch_group_create();
- dispatch_group_enter(group);
- dispatch_group_async(group, dispatch_get_main_queue(), ^{
- NSLog(@"%@---获取 余额",[NSThread currentThread]);
- // 获取余额
- [self youpaifrequestBannerData:^{
- dispatch_group_leave(group);
- }];
-
- });
-
- dispatch_group_notify(group, dispatch_get_main_queue(), ^{
- NSLog(@"%@---全部结束。。。",[NSThread currentThread]);
- [self youpaifrequestCategoryListData];
- });
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifupdateSeat:) name:@"UpdateChatRoomAllSeat" object:nil];
- }
- -(void)youpaifupdateSeat:(NSNotification *)notify{
- self.youpaipnormalSeatJsons = notify.userInfo[@"seats"];
- [self youpaifhandleSeatInfo];
- }
- -(void)youpaifsetupUI{
-
- UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 333.0f+SafeHeight+50)];
- bgV.backgroundColor = LCBkgColor;
- [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(20.0f, 20.0f)];
- [self.view addSubview:bgV];
- [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.offset(0.0f);
- make.height.offset(333.0f+SafeHeight+50);
- }];
-
- NSMutableArray <NSString *>*titles = [NSMutableArray array];
- for (YOUPAILZCommonGiftListModel *model in self.youpaiptitlesArr) {
- [titles addObject:model.youpaipname];
- }
- JXCategoryTitleView *youpaipcategoryView = [[JXCategoryTitleView alloc] init];
- youpaipcategoryView.backgroundColor = LCBkgColor;
- youpaipcategoryView.titles = titles;
- youpaipcategoryView.delegate = self;
- youpaipcategoryView.titleSelectedColor = HexColorFromRGB(0xffffff);
- youpaipcategoryView.titleColor = HexColorFromRGB(0x9F9DA5);
- youpaipcategoryView.titleColorGradientEnabled = YES;
- youpaipcategoryView.titleFont = LCFont(18.0f);
- youpaipcategoryView.titleSelectedFont = LCBoldFont(18.0f);
- youpaipcategoryView.cellWidth = LZCategoryViewItemWidth;
- youpaipcategoryView.cellSpacing = 0.0f;
- youpaipcategoryView.averageCellSpacingEnabled = NO;
- youpaipcategoryView.defaultSelectedIndex =1;
- [bgV addSubview:youpaipcategoryView];
- self.youpaipcategoryView = youpaipcategoryView;
- [youpaipcategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.right.offset(0.0f);
- make.height.offset(49.0f);
- }];
- YOUPAILZCommonGiftListModel *model = self.youpaiptitlesArr[0];
- //头部View
- YOUPAIHRChatRoomHeaderView *youpaipheadView = [[YOUPAIHRChatRoomHeaderView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(youpaipcategoryView.frame), KScreenWidth, 50) send_gift_hide:model.youpaipsend_gift_hide];
- [bgV addSubview:youpaipheadView];
- self.youpaipheadView = youpaipheadView;
- // youpaipheadView.youpaipisAnchor = self.youpaipisAnchor;
- // youpaipheadView.dataArr = arr;
- [youpaipheadView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(youpaipcategoryView.mas_bottom);
- make.height.mas_equalTo(50);
- }];
-
-
- JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
- lineView.verticalMargin = 4.0f;
- lineView.indicatorHeight = 2.5f;
- lineView.indicatorWidth = 8;
- lineView.layer.cornerRadius = 1.25;
- lineView.layer.masksToBounds = YES;
- [lineView.layer addSublayer:[LCTools getGradientLayerWithSize:CGSizeMake(lineView.indicatorWidth, lineView.indicatorHeight) twoColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] gradientType:GradientLeftToRight]];
- // youpaipcategoryView.indicators = @[lineView];
-
- JXCategoryListContainerView *pagerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_CollectionView delegate:self];
- [pagerView setDefaultSelectedIndex:1];
- pagerView.listCellBackgroundColor = LCSubBkgColor;
- // pagerView.frame = CGRectMake(0.0f,CGRectGetMaxY(categoryBgV.frame), KScreenWidth, KScreenHeight - CGRectGetMaxY(categoryBgV.frame) - SafeHeight);
- [bgV addSubview:pagerView];
- self.youpaippagerView = pagerView;
- [pagerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.offset(0.0f);
- make.top.equalTo(youpaipheadView.mas_bottom).offset(10);
- make.bottom.offset(0.0f);
- }];
- self.youpaipcategoryView.listContainer = self.youpaippagerView;
-
-
-
-
- }
- - (void)youpaifhandleSeatInfo{
- NSMutableArray <YOUPAILZChatRoomSeatModel *> *youpaipseats = [YOUPAILZChatRoomSeatModel mj_objectArrayWithKeyValuesArray:self.youpaipnormalSeatJsons];
- if (youpaipseats.count != 0) {
- youpaipseats.lastObject.youpaipisSelected = NO;
- }
- // BOOL youpaipisFirst = YES;
- NSMutableArray <YOUPAILZChatRoomSeatModel *> *nseats = [NSMutableArray array];
- for (NSInteger i = 0; i < youpaipseats.count; i ++) {
- YOUPAILZChatRoomSeatModel *iseatModel = youpaipseats[i];
- iseatModel.youpaipisTalking = NO;
- if (iseatModel.youpaipseatState == LZChatRoomSeatStateWithBusy) {
- for (YOUPAILZChatRoomSeatModel *seatModel in self.youpaipseats) {
- if ([iseatModel.youpaipuserInfo.youpaipid isEqual:seatModel.youpaipuserInfo.youpaipid]) {
- iseatModel.youpaipisSelected = seatModel.youpaipisSelected;
- break;
- }
- }
- if (self.youpaipseats == nil/* && youpaipisFirst*/) {
- // youpaipisFirst = NO;
- iseatModel.youpaipisSelected = YES;
- }
- [nseats addObject:iseatModel];
- }
- }
- self.youpaipseats = nseats;
- self.youpaipheadView.youpaipseats = self.youpaipseats;
- }
- - (void)youpaifrequestBannerData:(void(^)(void))complete{
- [LCHttpHelper requestWithURLString:GetAdvert parameters:@{@"position":@"5"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- self.youpaipfirstRechargeModel = [YOUPAILCFirstRechargeModel mj_objectWithKeyValues:dict[@"data"]];
-
-
- if (complete) {
- complete();
- }
- }
- } failure:^(NSError *error) {}];
-
- }
- // 返回列表的数量
- - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
- return self.youpaiptitlesArr.count;
- }
- // 根据下标 index 返回对应遵守并实现 `JXCategoryListContentViewDelegate` 协议的列表实例
- - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
-
- YOUPAILZCommonGiftListModel *model = self.youpaiptitlesArr[index];
- YOUPAIHRChatRoomSubGiftVC *vc = [YOUPAIHRChatRoomSubGiftVC new];
- vc.Giftdelegate = self;
- vc.youpaipisAnchor = self.youpaipisAnchor;
- vc.youpaipsend_gift_hide = model.youpaipsend_gift_hide;
- vc.youpaipID = [NSString stringWithFormat:@"%ld",model.youpaipid];
- vc.youpaipjumToWalletBlock = self.youpaipjumToWalletBlock1;
- return vc;
- }
- //- (void)youpaipcategoryView:(JXCategoryBaseView *)youpaipcategoryView didSelectedItemAtIndex:(NSInteger)index{
- //
- // [self.youpaipcategoryView.listContainer reloadData];
- //
- //
- //}
- -(void)youpaifDidSenderGiftWith:(YOUPAILCGiftModel *)model Count:(NSInteger)count CategoryID:(NSString *)categoryid{
-
- if (self.youpaiplzgiftblock != nil && model != nil) {
- NSMutableString *userIds = [NSMutableString string];
- for (YOUPAILZChatRoomSeatModel *seatModel in self.youpaipseats) {
- if (seatModel.youpaipisSelected) {
- [userIds appendFormat:@"%@,",seatModel.youpaipuserInfo.youpaipid];
- }
- }
- if (userIds.length == 0) {
- [ZCHUDHelper showTitle:@"请选择赠送的嘉宾"];
- return;
- }else{
- [userIds deleteCharactersInRange:NSMakeRange(userIds.length - 1, 1)];
- }
- // [self dismissViewControllerAnimated:NO completion:^{
- //
- // }];
- self.youpaiplzgiftblock(model, userIds, count, categoryid);
- }
- }
- - (void)youpaifrequestCategoryListData{
- @weakify(self);
- [LCHttpHelper requestWithURLString:LiveGiftList parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- self.youpaiptitlesArr = [YOUPAILZCommonGiftListModel mj_objectArrayWithKeyValuesArray:[dict objectForKey:@"data"]];
- [self youpaifsetupUI];
- [self youpaifhandleSeatInfo];
- }else{
- [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
-
- }];
- }
- - (void)youpaifreloadBalance{
- [[NSNotificationCenter defaultCenter] postNotificationName:@"VQUChatRoomRefreshBalance" object:nil userInfo:nil];
- }
- @end
|