123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- //
- // YOUPAIBBCommonGiftView.m
- // VQU
- //
- // Created by Elaine on 2021/11/5.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAIBBCommonGiftView.h"
- #import "JXCategoryView.h"
- #import "JXPagerView.h"
- #import "YOUPAILZCommonGiftVC.h"
- #import "YOUPAILZCommonGiftListModel.h"
- #import "UIViewController+TFPresent.h"
- #import "SDCycleScrollView.h"
- #define LZCategoryViewHeight 54.0f
- #define LZCategoryViewItemWidth 65.0f
- @interface YOUPAIBBCommonGiftView ()<JXCategoryViewDelegate,JXPagerViewDelegate,JXCategoryListContainerViewDelegate,DidGiftSenderDelegate,SDCycleScrollViewDelegate>
- @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)SDCycleScrollView* youpaipSDCscrollView;
- @end
- @implementation YOUPAIBBCommonGiftView
- - (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 vqf_youpaifrequestCategoryListData];
- });
-
- }
- -(void)youpaifsetupUI{
-
- UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 333.0f+SafeHeight)];
- bgV.backgroundColor = HexColorFromRGB(0x2A2935);
- [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);
- }];
-
- NSMutableArray <NSString *>*titles = [NSMutableArray array];
- // for (YOUPAILZCommonGiftListModel *model in self.youpaiptitlesArr) {
- // [titles addObject:model.name];
- // }
- [titles addObject:@"礼物"];
- JXCategoryTitleView *youpaipcategoryView = [[JXCategoryTitleView alloc] init];
- youpaipcategoryView.backgroundColor = LCSubBkgColor;
- 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);
- }];
-
- JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
- lineView.indicatorHeight = 0.5f;
- lineView.indicatorWidth = LZCategoryViewItemWidth;
- [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:0];
- 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(youpaipcategoryView.mas_bottom);
- make.bottom.offset(0.0f);
- }];
- self.youpaipcategoryView.listContainer = self.youpaippagerView;
- //首冲按钮
- // SDCycleScrollView *bannerView1 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:[UIImage imageNamed:@""]];
- // [self.view addSubview:bannerView1];
- // self.youpaipSDCscrollView = bannerView1;
- // [bannerView1 mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.right.mas_equalTo(0);
- // make.bottom.mas_equalTo(bgV.mas_top);
- // make.size.mas_equalTo(CGSizeMake(50, 50));
- // }];
- // bannerView1.autoScrollTimeInterval = 3.0;//2s轮播
- // bannerView1.pageControlStyle = SDCycleScrollViewPageContolStyleNone;
- // bannerView1.backgroundColor = [UIColor clearColor];
-
- NSMutableArray *imgUrlArray = [NSMutableArray new];
- for (YOUPAILCBannerModel* model in self.youpaipfirstRechargeModel.youpaiplist) {
- [imgUrlArray addObject:[LCTools getImageUrlWithAddress:model.youpaipimage]];
- }
-
- // self.youpaipSDCscrollView.imageURLStringsGroup = imgUrlArray;
- // if (self.youpaipfirstRechargeModel.is_open == 1) {
- // self.youpaipSDCscrollView.hidden = NO;
- //
- // }else{
- // self.youpaipSDCscrollView.hidden = YES;
- //
- // }
- //
-
-
- }
- //#pragma mark - SDCycleScrollViewDelegate
- //- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
- //{
- // [self dismissViewControllerAnimated:NO completion:^{
- // YOUPAILCBannerModel* model = self.youpaipfirstRechargeModel.list[index];
- // if (self.youpaiptouchAdvertBlock) {
- // self.youpaiptouchAdvertBlock(model);
- // }else{
- // if (model.link_type==1) {
- // ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init];
- // baseWeb.contentUrl = model.link_url;
- // [[LCTools getContainNavigationControllerCurrentVC].navigationController pushViewController:baseWeb animated:YES];
- // }else if (model.link_type==2||model.link_type==3){
- // [self youpaifpageToStr:model.link_url];
- // }
- //
- // }
- //
- //
- // }];
- //
- //}
- - (void)youpaifrequestBannerData:(void(^)(void))complete{
- [LCHttpHelper requestWithURLString:GetAdvert parameters:@{@"position":@"5"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* youpaipdict = (NSDictionary*)responseObject;
- NSInteger code = [[youpaipdict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- self.youpaipfirstRechargeModel = [YOUPAILCFirstRechargeModel mj_objectWithKeyValues:youpaipdict[@"data"]];
- if (complete) {
- complete();
- }
- }
- } failure:^(NSError *error) {}];
-
- }
- // 返回列表的数量
- - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
- return 1;
- return self.youpaiptitlesArr.count;
- }
- // 根据下标 index 返回对应遵守并实现 `JXCategoryListContentViewDelegate` 协议的列表实例
- - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
-
- // YOUPAILZCommonGiftListModel *model = self.youpaiptitlesArr[index];
- YOUPAILZCommonGiftVC *vc = [YOUPAILZCommonGiftVC new];
- vc.delegate = self;
- // vc.youpaipisAnchor = self.youpaipisAnchor;
- // vc.send_gift_hide = model.send_gift_hide;
- // vc.youpaipcountDown = self.youpaipcountDown;
- vc.ID = @"1";
- return vc;
- }
- //- (void)youpaipcategoryView:(JXCategoryBaseView *)youpaipcategoryView didSelectedItemAtIndex:(NSInteger)index{
- //
- // [self.youpaipcategoryView.listContainer reloadData];
- //
- //
- //}
- -(void)DidSenderGiftWith:(YOUPAILCGiftModel *)model Count:(NSInteger)count CategoryID:(NSString *)categoryid{
- if (self.youpaiplzgiftblock) {
- self.youpaiplzgiftblock(model, count,categoryid);
- }
- }
- - (void)vqf_youpaifrequestCategoryListData{
- WeakSelf;
- [LCHttpHelper requestWithURLString:LiveGiftList parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- NSDictionary* youpaipdict = (NSDictionary*)responseObject;
- NSInteger code = [[youpaipdict objectForKey:@"code"] integerValue];
- if (code == 0) {
- weakSelf.youpaiptitlesArr = [YOUPAILZCommonGiftListModel mj_objectArrayWithKeyValuesArray:[youpaipdict objectForKey:@"data"]];
- [weakSelf youpaifsetupUI];
-
- }else{
- [ZCHUDHelper showTitle:[youpaipdict objectForKey:@"message"]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
-
- }];
- }
- @end
|