// // XMGXianShiMshaView.m // 振飞商城 // // Created by 123 on 2020/5/16. // Copyright © 2020 Vibration Fly. All rights reserved. // #import "XMGXianShiMshaView.h" #import "XMGXianShiMshaCell.h" @interface XMGXianShiMshaView() @property (nonatomic,strong) UICollectionView *collectionView; @end @implementation XMGXianShiMshaView -(instancetype)initWithFrame:(CGRect)frame{ if (self=[super initWithFrame:frame]) { _dataArr=[NSMutableArray array]; self.userInteractionEnabled=YES; UICollectionViewFlowLayout *flowLayout=[[UICollectionViewFlowLayout alloc] init]; //flowLayout.minimumInteritemSpacing = 30; flowLayout.minimumLineSpacing = 35; flowLayout.sectionInset = UIEdgeInsetsMake(10, 35, 10, 35); flowLayout.itemSize = CGSizeMake((JX_SCREEN_WIDTH - 100) /3, 180); flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal; _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0,0,JX_SCREEN_WIDTH, 180 ) collectionViewLayout:flowLayout]; _collectionView.delegate = self; _collectionView.dataSource = self; //_collectionView.backgroundColor = [UIColor clearColor]; [_collectionView registerClass :[XMGXianShiMshaCell class] forCellWithReuseIdentifier:@"XMGXianShiMshaCell"]; _collectionView.showsVerticalScrollIndicator=NO; [self addSubview:_collectionView]; long time = (long)[[NSDate date] timeIntervalSince1970]; time = (time *1000 + g_server.timeDifference); NSString *salt = [NSString stringWithFormat:@"%ld", time]; [SVProgressHUD show]; [g_server getMyPaihangBang:salt andType:@"4" andToView:self]; } return self; } #pragma mark --- 请求成功 -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{ [SVProgressHUD dismiss]; if([aDownload.action isEqualToString:act_usertopPHBall]) { _dataArr=[StatusesModel mj_objectArrayWithKeyValuesArray:array1]; [_collectionView reloadData]; } } -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{ [SVProgressHUD dismiss]; NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]]; if([errorCode isEqualToString:@"权限验证失败"]) { if ([aDownload.action isEqualToString:act_usertopPHBall]) { } } return [errorCode intValue]; } -(void)setDataArr:(NSMutableArray *)dataArr{ //_dataArr=dataArr; // [_collectionView reloadData]; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return _dataArr.count; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { XMGXianShiMshaCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"XMGXianShiMshaCell" forIndexPath:indexPath]; StatusesModel *model=_dataArr[indexPath.row]; cell.shaModel=model; return cell; } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ if (self.delegate && [self.delegate respondsToSelector:@selector(selectItemAtIndexPathTitle:)]) { [self.delegate selectItemAtIndexPathTitle:indexPath]; } } @end