YOUPAIBBCommonGiftView.m 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. //
  2. // YOUPAIBBCommonGiftView.m
  3. // VQU
  4. //
  5. // Created by Elaine on 2021/11/5.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIBBCommonGiftView.h"
  9. #import "JXCategoryView.h"
  10. #import "JXPagerView.h"
  11. #import "YOUPAILZCommonGiftVC.h"
  12. #import "YOUPAILZCommonGiftListModel.h"
  13. #import "UIViewController+TFPresent.h"
  14. #import "SDCycleScrollView.h"
  15. #define LZCategoryViewHeight 54.0f
  16. #define LZCategoryViewItemWidth 65.0f
  17. @interface YOUPAIBBCommonGiftView ()<JXCategoryViewDelegate,JXPagerViewDelegate,JXCategoryListContainerViewDelegate,DidGiftSenderDelegate,SDCycleScrollViewDelegate>
  18. @property (nonatomic, weak) JXCategoryListContainerView *youpaippagerView;
  19. @property (nonatomic, strong) JXCategoryTitleView *youpaipcategoryView;
  20. /* titlearr */
  21. @property (strong, nonatomic) NSArray *youpaiptitlesArr;
  22. /* youpaipfirstBtn */
  23. @property (strong, nonatomic) UIButton *youpaipfirstBtn;
  24. @property (strong, nonatomic) YOUPAILCFirstRechargeModel *youpaipfirstRechargeModel;
  25. //@property(nonatomic,strong)SDCycleScrollView* youpaipSDCscrollView;
  26. @end
  27. @implementation YOUPAIBBCommonGiftView
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. self.baseView.hidden = YES;
  31. // self.youpaiptitlesArr = @[@"1",@"2",@"3"];
  32. dispatch_group_t group = dispatch_group_create();
  33. dispatch_group_enter(group);
  34. dispatch_group_async(group, dispatch_get_main_queue(), ^{
  35. NSLog(@"%@---获取 余额",[NSThread currentThread]);
  36. // 获取余额
  37. [self youpaifrequestBannerData:^{
  38. dispatch_group_leave(group);
  39. }];
  40. });
  41. dispatch_group_notify(group, dispatch_get_main_queue(), ^{
  42. NSLog(@"%@---全部结束。。。",[NSThread currentThread]);
  43. [self vqf_youpaifrequestCategoryListData];
  44. });
  45. }
  46. -(void)youpaifsetupUI{
  47. UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 333.0f+SafeHeight)];
  48. bgV.backgroundColor = HexColorFromRGB(0x2A2935);
  49. [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(20.0f, 20.0f)];
  50. [self.view addSubview:bgV];
  51. [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.left.right.bottom.offset(0.0f);
  53. make.height.offset(333.0f+SafeHeight);
  54. }];
  55. NSMutableArray <NSString *>*titles = [NSMutableArray array];
  56. // for (YOUPAILZCommonGiftListModel *model in self.youpaiptitlesArr) {
  57. // [titles addObject:model.name];
  58. // }
  59. [titles addObject:@"礼物"];
  60. JXCategoryTitleView *youpaipcategoryView = [[JXCategoryTitleView alloc] init];
  61. youpaipcategoryView.backgroundColor = LCSubBkgColor;
  62. youpaipcategoryView.titles = titles;
  63. youpaipcategoryView.delegate = self;
  64. youpaipcategoryView.titleSelectedColor = HexColorFromRGB(0xffffff);
  65. youpaipcategoryView.titleColor = HexColorFromRGB(0x9F9DA5);
  66. youpaipcategoryView.titleColorGradientEnabled = YES;
  67. youpaipcategoryView.titleFont = LCFont(18.0f);
  68. youpaipcategoryView.titleSelectedFont = LCBoldFont(18.0f);
  69. youpaipcategoryView.cellWidth = LZCategoryViewItemWidth;
  70. youpaipcategoryView.cellSpacing = 0.0f;
  71. youpaipcategoryView.averageCellSpacingEnabled = NO;
  72. youpaipcategoryView.defaultSelectedIndex =1;
  73. [bgV addSubview:youpaipcategoryView];
  74. self.youpaipcategoryView = youpaipcategoryView;
  75. [youpaipcategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.left.top.right.offset(0.0f);
  77. make.height.offset(49.0f);
  78. }];
  79. JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
  80. lineView.indicatorHeight = 0.5f;
  81. lineView.indicatorWidth = LZCategoryViewItemWidth;
  82. [lineView.layer addSublayer:[LCTools getGradientLayerWithSize:CGSizeMake(lineView.indicatorWidth, lineView.indicatorHeight) twoColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] gradientType:GradientLeftToRight]];
  83. // youpaipcategoryView.indicators = @[lineView];
  84. JXCategoryListContainerView *pagerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_CollectionView delegate:self];
  85. [pagerView setDefaultSelectedIndex:0];
  86. pagerView.listCellBackgroundColor = LCSubBkgColor;
  87. // pagerView.frame = CGRectMake(0.0f,CGRectGetMaxY(categoryBgV.frame), KScreenWidth, KScreenHeight - CGRectGetMaxY(categoryBgV.frame) - SafeHeight);
  88. [bgV addSubview:pagerView];
  89. self.youpaippagerView = pagerView;
  90. [pagerView mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.left.right.offset(0.0f);
  92. make.top.equalTo(youpaipcategoryView.mas_bottom);
  93. make.bottom.offset(0.0f);
  94. }];
  95. self.youpaipcategoryView.listContainer = self.youpaippagerView;
  96. //首冲按钮
  97. // SDCycleScrollView *bannerView1 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:[UIImage imageNamed:@""]];
  98. // [self.view addSubview:bannerView1];
  99. // self.youpaipSDCscrollView = bannerView1;
  100. // [bannerView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  101. // make.right.mas_equalTo(0);
  102. // make.bottom.mas_equalTo(bgV.mas_top);
  103. // make.size.mas_equalTo(CGSizeMake(50, 50));
  104. // }];
  105. // bannerView1.autoScrollTimeInterval = 3.0;//2s轮播
  106. // bannerView1.pageControlStyle = SDCycleScrollViewPageContolStyleNone;
  107. // bannerView1.backgroundColor = [UIColor clearColor];
  108. NSMutableArray *imgUrlArray = [NSMutableArray new];
  109. for (YOUPAILCBannerModel* model in self.youpaipfirstRechargeModel.youpaiplist) {
  110. [imgUrlArray addObject:[LCTools getImageUrlWithAddress:model.youpaipimage]];
  111. }
  112. // self.youpaipSDCscrollView.imageURLStringsGroup = imgUrlArray;
  113. // if (self.youpaipfirstRechargeModel.is_open == 1) {
  114. // self.youpaipSDCscrollView.hidden = NO;
  115. //
  116. // }else{
  117. // self.youpaipSDCscrollView.hidden = YES;
  118. //
  119. // }
  120. //
  121. }
  122. //#pragma mark - SDCycleScrollViewDelegate
  123. //- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
  124. //{
  125. // [self dismissViewControllerAnimated:NO completion:^{
  126. // YOUPAILCBannerModel* model = self.youpaipfirstRechargeModel.list[index];
  127. // if (self.youpaiptouchAdvertBlock) {
  128. // self.youpaiptouchAdvertBlock(model);
  129. // }else{
  130. // if (model.link_type==1) {
  131. // ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init];
  132. // baseWeb.contentUrl = model.link_url;
  133. // [[LCTools getContainNavigationControllerCurrentVC].navigationController pushViewController:baseWeb animated:YES];
  134. // }else if (model.link_type==2||model.link_type==3){
  135. // [self youpaifpageToStr:model.link_url];
  136. // }
  137. //
  138. // }
  139. //
  140. //
  141. // }];
  142. //
  143. //}
  144. - (void)youpaifrequestBannerData:(void(^)(void))complete{
  145. [LCHttpHelper requestWithURLString:GetAdvert parameters:@{@"position":@"5"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  146. NSDictionary* youpaipdict = (NSDictionary*)responseObject;
  147. NSInteger code = [[youpaipdict objectForKey:@"code"] integerValue];
  148. if (code==0) {//成功
  149. self.youpaipfirstRechargeModel = [YOUPAILCFirstRechargeModel mj_objectWithKeyValues:youpaipdict[@"data"]];
  150. if (complete) {
  151. complete();
  152. }
  153. }
  154. } failure:^(NSError *error) {}];
  155. }
  156. // 返回列表的数量
  157. - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
  158. return 1;
  159. return self.youpaiptitlesArr.count;
  160. }
  161. // 根据下标 index 返回对应遵守并实现 `JXCategoryListContentViewDelegate` 协议的列表实例
  162. - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
  163. // YOUPAILZCommonGiftListModel *model = self.youpaiptitlesArr[index];
  164. YOUPAILZCommonGiftVC *vc = [YOUPAILZCommonGiftVC new];
  165. vc.delegate = self;
  166. // vc.youpaipisAnchor = self.youpaipisAnchor;
  167. // vc.send_gift_hide = model.send_gift_hide;
  168. // vc.youpaipcountDown = self.youpaipcountDown;
  169. vc.ID = @"1";
  170. return vc;
  171. }
  172. //- (void)youpaipcategoryView:(JXCategoryBaseView *)youpaipcategoryView didSelectedItemAtIndex:(NSInteger)index{
  173. //
  174. // [self.youpaipcategoryView.listContainer reloadData];
  175. //
  176. //
  177. //}
  178. -(void)DidSenderGiftWith:(YOUPAILCGiftModel *)model Count:(NSInteger)count CategoryID:(NSString *)categoryid{
  179. if (self.youpaiplzgiftblock) {
  180. self.youpaiplzgiftblock(model, count,categoryid);
  181. }
  182. }
  183. - (void)vqf_youpaifrequestCategoryListData{
  184. WeakSelf;
  185. [LCHttpHelper requestWithURLString:LiveGiftList parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  186. NSDictionary* youpaipdict = (NSDictionary*)responseObject;
  187. NSInteger code = [[youpaipdict objectForKey:@"code"] integerValue];
  188. if (code == 0) {
  189. weakSelf.youpaiptitlesArr = [YOUPAILZCommonGiftListModel mj_objectArrayWithKeyValuesArray:[youpaipdict objectForKey:@"data"]];
  190. [weakSelf youpaifsetupUI];
  191. }else{
  192. [ZCHUDHelper showTitle:[youpaipdict objectForKey:@"message"]];
  193. }
  194. } failure:^(NSError *error) {
  195. [ZCHUDHelper showTitle:error.localizedDescription];
  196. }];
  197. }
  198. @end