JLMyBonusViewController.m 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. //
  2. // JLMyBonusViewController.m
  3. // shiku_im
  4. //
  5. // Created by JayLuo on 2020/4/10.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JLMyBonusViewController.h"
  9. #import "JLMyBonusHeaderView.h"
  10. #import "JLMyBonusViewCell.h"
  11. #import "CYWebCustomerServiceVC.h"
  12. #import "JLMyBonusModel.h"
  13. #import "JXChatViewController.h"
  14. #define cellID @"JLMyBonusViewCell"
  15. @interface JLMyBonusViewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
  16. @property (nonatomic, strong) UICollectionView *collectionView;
  17. @property (nonatomic, strong) NSMutableArray *giftArray;
  18. @end
  19. @implementation JLMyBonusViewController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. // Do any additional setup after loading the view.
  23. self.isGotoBack = YES;
  24. self.title = @"我的彩金";
  25. self.heightFooter = JX_SCREEN_BOTTOM_SAFE_AREA;
  26. self.heightHeader = JX_SCREEN_TOP;
  27. [self createHeadAndFoot];
  28. _giftArray = [NSMutableArray array];
  29. [g_server getRoomActivityRecordToView:self];
  30. [self setupUI];
  31. }
  32. - (void)setupUI {
  33. [self collectionView];
  34. UIButton *btn = [UIButton buttonWithType:(UIButtonTypeSystem)];
  35. [btn setTitle:@"联系客服领取彩金奖励" forState:(UIControlStateNormal)];
  36. btn.frame = CGRectMake(0, self_height - 30 - JX_SCREEN_BOTTOM_SAFE_AREA - 10, self_width, 50);
  37. [btn addTarget:self action:@selector(customerClick:) forControlEvents:(UIControlEventTouchUpInside)];
  38. [self.view addSubview:btn];
  39. }
  40. -(void)customerClick:(UIButton *)sender{
  41. // if ( g_App.customerLinkListArray[0][@"link"]) {
  42. // CYWebCustomerServiceVC *vc = [[CYWebCustomerServiceVC alloc] init];
  43. // vc.titleName = g_App.customerLinkListArray[0][@"name"];
  44. // vc.link = g_App.customerLinkListArray[0][@"link"];
  45. // [self presentViewController:vc animated:YES completion:^{
  46. //
  47. // }];
  48. // }else {
  49. // NSLog(@"链接不存在!!!!!!!!");
  50. // }
  51. JXChatViewController *vc = [[JXChatViewController alloc] init];
  52. JXUserObject *user = [[JXUserObject sharedInstance] getUserById:@"10000"];
  53. vc.chatPerson = user;
  54. [g_navigation pushViewController:vc animated:YES];
  55. }
  56. - (void)didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  57. if([aDownload.action isEqualToString:act_roomActivityRecord]){
  58. [_giftArray removeAllObjects];
  59. for (NSDictionary *tempDict in array1) {
  60. JLMyBonusModel *model = [JLMyBonusModel mj_objectWithKeyValues:tempDict];
  61. [_giftArray addObject:model];
  62. }
  63. [self.collectionView reloadData];
  64. }
  65. }
  66. - (UICollectionView *)collectionView {
  67. if (_collectionView == nil) {
  68. UICollectionViewFlowLayout *layout = ({
  69. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  70. // 设置尺寸
  71. CGFloat width = self_width;
  72. layout.itemSize = CGSizeMake(width,50);
  73. //尾部的参考尺寸
  74. layout.footerReferenceSize = CGSizeMake(100, 100);
  75. layout.sectionFootersPinToVisibleBounds = YES;
  76. layout.sectionHeadersPinToVisibleBounds = YES;
  77. layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  78. layout.scrollDirection = UICollectionViewScrollDirectionVertical;
  79. layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
  80. layout.minimumInteritemSpacing = 10;
  81. layout.minimumLineSpacing = 10;
  82. layout;
  83. });
  84. _collectionView = ({
  85. UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  86. collectionView.bounds = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
  87. collectionView.backgroundColor = [UIColor clearColor];
  88. collectionView.frame = CGRectMake(0, JX_SCREEN_TOP, self.view.bounds.size.width, self.view.bounds.size.height-JX_SCREEN_TOP-JX_SCREEN_BOTTOM_SAFE_AREA);
  89. collectionView.dataSource = self;
  90. collectionView.delegate = self;
  91. [collectionView registerNib:[UINib nibWithNibName:@"JLMyBonusViewCell" bundle:nil] forCellWithReuseIdentifier:cellID];
  92. [collectionView registerNib:[UINib nibWithNibName:@"JLMyBonusHeaderView" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"JLMyBonusHeaderView"];
  93. //设置滚动条
  94. collectionView.showsHorizontalScrollIndicator = NO;
  95. collectionView.showsVerticalScrollIndicator = YES;
  96. //设置是否需要弹簧效果
  97. collectionView.bounces = NO;
  98. collectionView;
  99. });
  100. [self.view addSubview:_collectionView];
  101. }
  102. return _collectionView;
  103. }
  104. #pragma mark - UICollectionViewDataSource
  105. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  106. return 1;
  107. }
  108. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  109. return _giftArray.count;
  110. }
  111. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  112. JLMyBonusViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
  113. JLMyBonusModel *model = _giftArray[indexPath.row];
  114. cell.nameLabel.text = model.giftName;
  115. cell.numberLabel.text = [NSString stringWithFormat:@"%.2f", model.amount];
  116. NSString *statusString;
  117. switch (model.status) {
  118. case 0:
  119. statusString = @"等待派送";
  120. break;
  121. case 1:
  122. statusString = @"已派送";
  123. break;
  124. case 2:
  125. statusString = @"取消派送";
  126. break;
  127. default:
  128. break;
  129. }
  130. cell.statusLabel.text = [NSString stringWithFormat:@"%@", statusString];
  131. return cell;
  132. }
  133. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
  134. return UIEdgeInsetsMake(5, 10, 5, 10);
  135. }
  136. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
  137. UICollectionReusableView *headerView = nil;
  138. if ([kind isEqualToString:UICollectionElementKindSectionHeader]){
  139. JLMyBonusHeaderView *view = (JLMyBonusHeaderView *) [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"JLMyBonusHeaderView" forIndexPath:indexPath];
  140. headerView = view;
  141. }
  142. return headerView;
  143. }
  144. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
  145. return CGSizeMake(self_width, 40);
  146. }
  147. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
  148. return CGSizeZero;
  149. }
  150. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  151. }
  152. @end