XMGXianShiMshaView.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // XMGXianShiMshaView.m
  3. // 振飞商城
  4. //
  5. // Created by 123 on 2020/5/16.
  6. // Copyright © 2020 Vibration Fly. All rights reserved.
  7. //
  8. #import "XMGXianShiMshaView.h"
  9. #import "XMGXianShiMshaCell.h"
  10. @interface XMGXianShiMshaView()<UICollectionViewDelegate,UICollectionViewDataSource>
  11. @property (nonatomic,strong) UICollectionView *collectionView;
  12. @end
  13. @implementation XMGXianShiMshaView
  14. -(instancetype)initWithFrame:(CGRect)frame{
  15. if (self=[super initWithFrame:frame]) {
  16. _dataArr=[NSMutableArray array];
  17. self.userInteractionEnabled=YES;
  18. UICollectionViewFlowLayout *flowLayout=[[UICollectionViewFlowLayout alloc] init];
  19. //flowLayout.minimumInteritemSpacing = 30;
  20. flowLayout.minimumLineSpacing = 35;
  21. flowLayout.sectionInset = UIEdgeInsetsMake(10, 35, 10, 35);
  22. flowLayout.itemSize = CGSizeMake((JX_SCREEN_WIDTH - 100) /3, 180);
  23. flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  24. _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0,0,JX_SCREEN_WIDTH, 180 ) collectionViewLayout:flowLayout];
  25. _collectionView.delegate = self;
  26. _collectionView.dataSource = self;
  27. //_collectionView.backgroundColor = [UIColor clearColor];
  28. [_collectionView registerClass :[XMGXianShiMshaCell class] forCellWithReuseIdentifier:@"XMGXianShiMshaCell"];
  29. _collectionView.showsVerticalScrollIndicator=NO;
  30. [self addSubview:_collectionView];
  31. long time = (long)[[NSDate date] timeIntervalSince1970];
  32. time = (time *1000 + g_server.timeDifference);
  33. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  34. [SVProgressHUD show];
  35. [g_server getMyPaihangBang:salt andType:@"4" andToView:self];
  36. }
  37. return self;
  38. }
  39. #pragma mark --- 请求成功
  40. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  41. [SVProgressHUD dismiss];
  42. if([aDownload.action isEqualToString:act_usertopPHBall])
  43. {
  44. _dataArr=[StatusesModel mj_objectArrayWithKeyValuesArray:array1];
  45. [_collectionView reloadData];
  46. }
  47. }
  48. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  49. [SVProgressHUD dismiss];
  50. NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]];
  51. if([errorCode isEqualToString:@"权限验证失败"])
  52. {
  53. if ([aDownload.action isEqualToString:act_usertopPHBall])
  54. {
  55. }
  56. }
  57. return [errorCode intValue];
  58. }
  59. -(void)setDataArr:(NSMutableArray *)dataArr{
  60. //_dataArr=dataArr;
  61. // [_collectionView reloadData];
  62. }
  63. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  64. return _dataArr.count;
  65. }
  66. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  67. XMGXianShiMshaCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"XMGXianShiMshaCell" forIndexPath:indexPath];
  68. StatusesModel *model=_dataArr[indexPath.row];
  69. cell.shaModel=model;
  70. return cell;
  71. }
  72. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  73. if (self.delegate && [self.delegate respondsToSelector:@selector(selectItemAtIndexPathTitle:)])
  74. {
  75. [self.delegate selectItemAtIndexPathTitle:indexPath];
  76. }
  77. }
  78. @end