123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- //
- // JLMyBonusViewController.m
- // shiku_im
- //
- // Created by JayLuo on 2020/4/10.
- // Copyright © 2020 Reese. All rights reserved.
- //
- #import "JLMyBonusViewController.h"
- #import "JLMyBonusHeaderView.h"
- #import "JLMyBonusViewCell.h"
- #import "CYWebCustomerServiceVC.h"
- #import "JLMyBonusModel.h"
- #import "JXChatViewController.h"
- #define cellID @"JLMyBonusViewCell"
- @interface JLMyBonusViewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
- @property (nonatomic, strong) UICollectionView *collectionView;
- @property (nonatomic, strong) NSMutableArray *giftArray;
- @end
- @implementation JLMyBonusViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.isGotoBack = YES;
- self.title = @"我的彩金";
- self.heightFooter = JX_SCREEN_BOTTOM_SAFE_AREA;
- self.heightHeader = JX_SCREEN_TOP;
-
- [self createHeadAndFoot];
- _giftArray = [NSMutableArray array];
- [g_server getRoomActivityRecordToView:self];
- [self setupUI];
- }
- - (void)setupUI {
- [self collectionView];
- UIButton *btn = [UIButton buttonWithType:(UIButtonTypeSystem)];
- [btn setTitle:@"联系客服领取彩金奖励" forState:(UIControlStateNormal)];
- btn.frame = CGRectMake(0, self_height - 30 - JX_SCREEN_BOTTOM_SAFE_AREA - 10, self_width, 50);
- [btn addTarget:self action:@selector(customerClick:) forControlEvents:(UIControlEventTouchUpInside)];
- [self.view addSubview:btn];
- }
- -(void)customerClick:(UIButton *)sender{
- // if ( g_App.customerLinkListArray[0][@"link"]) {
- // CYWebCustomerServiceVC *vc = [[CYWebCustomerServiceVC alloc] init];
- // vc.titleName = g_App.customerLinkListArray[0][@"name"];
- // vc.link = g_App.customerLinkListArray[0][@"link"];
- // [self presentViewController:vc animated:YES completion:^{
- //
- // }];
- // }else {
- // NSLog(@"链接不存在!!!!!!!!");
- // }
- JXChatViewController *vc = [[JXChatViewController alloc] init];
-
- JXUserObject *user = [[JXUserObject sharedInstance] getUserById:@"10000"];
- vc.chatPerson = user;
- [g_navigation pushViewController:vc animated:YES];
- }
- - (void)didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
- if([aDownload.action isEqualToString:act_roomActivityRecord]){
- [_giftArray removeAllObjects];
- for (NSDictionary *tempDict in array1) {
- JLMyBonusModel *model = [JLMyBonusModel mj_objectWithKeyValues:tempDict];
- [_giftArray addObject:model];
- }
- [self.collectionView reloadData];
- }
-
- }
- - (UICollectionView *)collectionView {
- if (_collectionView == nil) {
- UICollectionViewFlowLayout *layout = ({
-
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
-
- // 设置尺寸
- CGFloat width = self_width;
- layout.itemSize = CGSizeMake(width,50);
- //尾部的参考尺寸
- layout.footerReferenceSize = CGSizeMake(100, 100);
- layout.sectionFootersPinToVisibleBounds = YES;
- layout.sectionHeadersPinToVisibleBounds = YES;
- layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
- layout.scrollDirection = UICollectionViewScrollDirectionVertical;
- layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
- layout.minimumInteritemSpacing = 10;
- layout.minimumLineSpacing = 10;
-
- layout;
-
- });
-
- _collectionView = ({
- UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
-
- collectionView.bounds = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
-
- collectionView.backgroundColor = [UIColor clearColor];
-
- 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);
-
- collectionView.dataSource = self;
-
- collectionView.delegate = self;
- [collectionView registerNib:[UINib nibWithNibName:@"JLMyBonusViewCell" bundle:nil] forCellWithReuseIdentifier:cellID];
- [collectionView registerNib:[UINib nibWithNibName:@"JLMyBonusHeaderView" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"JLMyBonusHeaderView"];
-
- //设置滚动条
- collectionView.showsHorizontalScrollIndicator = NO;
- collectionView.showsVerticalScrollIndicator = YES;
-
- //设置是否需要弹簧效果
- collectionView.bounces = NO;
-
- collectionView;
-
- });
-
- [self.view addSubview:_collectionView];
-
- }
- return _collectionView;
- }
- #pragma mark - UICollectionViewDataSource
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
- return 1;
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
- return _giftArray.count;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
- JLMyBonusViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
- JLMyBonusModel *model = _giftArray[indexPath.row];
- cell.nameLabel.text = model.giftName;
- cell.numberLabel.text = [NSString stringWithFormat:@"%.2f", model.amount];
- NSString *statusString;
- switch (model.status) {
- case 0:
- statusString = @"等待派送";
- break;
- case 1:
- statusString = @"已派送";
- break;
- case 2:
- statusString = @"取消派送";
- break;
- default:
- break;
- }
- cell.statusLabel.text = [NSString stringWithFormat:@"%@", statusString];
-
- return cell;
- }
- - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
- return UIEdgeInsetsMake(5, 10, 5, 10);
- }
- - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
-
- UICollectionReusableView *headerView = nil;
- if ([kind isEqualToString:UICollectionElementKindSectionHeader]){
- JLMyBonusHeaderView *view = (JLMyBonusHeaderView *) [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"JLMyBonusHeaderView" forIndexPath:indexPath];
- headerView = view;
- }
- return headerView;
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
- return CGSizeMake(self_width, 40);
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
- return CGSizeZero;
- }
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
- }
- @end
|