YOUPAIBBReceiveGiftVC.m 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // YOUPAIBBReceiveGiftVC.m
  3. // VQU
  4. //
  5. // Created by Elaine on 2021/11/15.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIBBReceiveGiftVC.h"
  9. #import "YOUPAILCReceiveItemCell.h"
  10. #import "YOUPAILCGiftSendView.h"
  11. @interface YOUPAIBBReceiveGiftVC ()<UICollectionViewDelegate,UICollectionViewDataSource>
  12. @property (nonatomic,strong)NSMutableArray* youpaipreceiveGiftArray;
  13. @property (nonatomic,strong)UICollectionView *youpaipcollectionView;
  14. @property (nonatomic,assign)NSInteger youpaipreceiveUserId;
  15. @end
  16. @implementation YOUPAIBBReceiveGiftVC
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. self.title = @"我的礼物";
  20. self.youpaipreceiveGiftArray = [NSMutableArray array];
  21. [self youpaifsetupView];
  22. [self youpaifinitData];
  23. }
  24. - (void)youpaifsetupView{
  25. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  26. layout.sectionInset = UIEdgeInsetsMake(14.0f, 14.0f, 14.0f, 14.0f);
  27. CGFloat margin = 5;
  28. CGFloat itemWH = (KScreenWidth-28.0f-15.0f)/4;
  29. layout.itemSize = CGSizeMake(itemWH, itemWH * (89.0f/83.0f));
  30. layout.minimumInteritemSpacing = margin;
  31. layout.minimumLineSpacing = margin;
  32. _youpaipcollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, NavBarHeight, KScreenWidth, KScreenHeight-NavBarHeight) collectionViewLayout:layout];
  33. _youpaipcollectionView.bounces = NO;
  34. _youpaipcollectionView.dataSource = self;
  35. _youpaipcollectionView.delegate = self;
  36. _youpaipcollectionView.scrollEnabled = YES;
  37. _youpaipcollectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  38. [_youpaipcollectionView registerClass:[YOUPAILCReceiveItemCell class] forCellWithReuseIdentifier:@"YOUPAILCReceiveItemCell"];
  39. [_youpaipcollectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"receiveGiftheader"];
  40. _youpaipcollectionView.backgroundColor = LCBkgColor;
  41. [self.view addSubview:_youpaipcollectionView];
  42. }
  43. - (void)youpaifinitData{
  44. [LCHttpHelper requestWithURLString:UserRecGiftList parameters:@{@"user_id":[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  45. NSDictionary* dict = (NSDictionary*)responseObject;
  46. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  47. if (code==0) {//成功
  48. self.youpaipreceiveUserId = [[[dict objectForKey:@"data"]objectForKey:@"userid"]integerValue];
  49. self.youpaipreceiveGiftArray = [YOUPAILCGiftModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"]objectForKey:@"list"]];
  50. [self.youpaipcollectionView reloadData];
  51. if (self.youpaipreceiveGiftArray.count != 0) {
  52. [self.youpaipcollectionView lz_hideEmptyView];
  53. }else{
  54. [self.youpaipcollectionView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_gift_data"] content:@"还没有人给你送礼哦"];
  55. }
  56. }
  57. } failure:^(NSError *error) {
  58. }];
  59. }
  60. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  61. return self.youpaipreceiveGiftArray.count;
  62. }
  63. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  64. YOUPAILCReceiveItemCell *cell = (YOUPAILCReceiveItemCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"YOUPAILCReceiveItemCell" forIndexPath:indexPath];
  65. return cell;
  66. }
  67. - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath{
  68. YOUPAILCReceiveItemCell *serviceCell = (YOUPAILCReceiveItemCell*)cell;
  69. YOUPAILCGiftModel *model = self.youpaipreceiveGiftArray[indexPath.row];
  70. serviceCell.youpaipreceiveGiftModel = model;
  71. }
  72. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  73. // YOUPAILCGiftModel *model = self.youpaipreceiveGiftArray[indexPath.row];
  74. // if ([[LCSaveModel getUserModel].userinfo.user_id isEqualToString:self.userId]) {
  75. // [ZCHUDHelper showTitle:@"不能赠送自己"];
  76. // }else{
  77. // YOUPAILCGiftSendView* sendView = [[YOUPAILCGiftSendView alloc]initWithModel:model type:2];
  78. // //modify by leo fix bug 20191009
  79. // sendView.alertWindow.hidden =NO;
  80. // //sendView.alertWindow.rootViewController = self;
  81. // sendView.sendMultiGift = ^(NSString *giftId, NSInteger count) {
  82. // [LCHttpHelper requestWithURLString:SendGift_New parameters:@{@"type":@(4),@"to_uid":self.userId,@"gift_id":giftId,@"num":@(count)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  83. // NSDictionary* dict = (NSDictionary*)responseObject;
  84. // NSInteger code = [[dict objectForKey:@"code"] integerValue];
  85. // if (code==0) {//成功
  86. // [ZCHUDHelper showTitle:@"礼物赠送成功"];
  87. // }
  88. // } failure:^(NSError *error) {
  89. //
  90. // }];
  91. // };
  92. // [sendView show];
  93. // }
  94. }
  95. @end