123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- //
- // XMGXianShiMshaView.m
- // 振飞商城
- //
- // Created by 123 on 2020/5/16.
- // Copyright © 2020 Vibration Fly. All rights reserved.
- //
- #import "XMGXianShiMshaView.h"
- #import "XMGXianShiMshaCell.h"
- @interface XMGXianShiMshaView()<UICollectionViewDelegate,UICollectionViewDataSource>
- @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
|