YOUPAILCReceiveGiftVC.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. //
  2. // YOUPAILCReceiveGiftVC.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/9/28.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCReceiveGiftVC.h"
  9. #import "YOUPAILCReceiveItemCell.h"
  10. #import "YOUPAILCGiftSendView.h"
  11. @interface YOUPAILCReceiveGiftVC ()<UICollectionViewDelegate,UICollectionViewDataSource>
  12. @property (nonatomic,strong)NSMutableArray* youpaipreceiveGiftArray;
  13. @property (nonatomic,weak)UICollectionView *youpaipcollectionView;
  14. @property (nonatomic,assign)NSInteger youpaipreceiveUserId;
  15. @property(nonatomic,strong)UIImageView *navView;
  16. @property(nonatomic,strong)UIImageView *iconImageView;//头像
  17. @property(nonatomic,strong)UILabel *nickLabel;//昵称
  18. @property(nonatomic,strong)UILabel *titleLabel;//点亮和总数
  19. @end
  20. @implementation YOUPAILCReceiveGiftVC
  21. -(void)viewWillAppear:(BOOL)animated{
  22. [super viewWillAppear:animated];
  23. self.navigationController.navigationBarHidden = YES;
  24. }
  25. - (void)viewWillDisappear:(BOOL)animated{
  26. [super viewWillDisappear:animated];
  27. self.navigationController.navigationBarHidden = NO;
  28. }
  29. - (void)dealloc{
  30. }
  31. - (void)viewDidLoad {
  32. [super viewDidLoad];
  33. self.youpaipreceiveGiftArray = [NSMutableArray array];
  34. [self youpaifloadNavView];
  35. [self youpaifsetupView];
  36. [self youpaifinitData];
  37. }
  38. -(void)youpaifloadNavView{
  39. UIImageView *navView = [UIImageView new];
  40. self.navView = navView;
  41. [self.view addSubview:navView];
  42. [navView mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.mas_equalTo(0);
  44. make.right.mas_equalTo(0);
  45. make.top.mas_equalTo(0);
  46. make.height.mas_equalTo(250);
  47. }];
  48. navView.contentMode = UIViewContentModeScaleAspectFill;
  49. navView.userInteractionEnabled = YES;
  50. navView.image = [UIImage imageNamed:@"vqu_images_gift_headerViewBg"];
  51. //头像
  52. UIImageView *iconImageView = [UIImageView new];
  53. self.iconImageView = iconImageView;
  54. [navView addSubview:iconImageView];
  55. [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.centerX.mas_equalTo(0);
  57. make.top.mas_equalTo(104);
  58. make.size.mas_equalTo(CGSizeMake(73, 73));
  59. }];
  60. iconImageView.contentMode = UIViewContentModeScaleAspectFill;
  61. iconImageView.layer.cornerRadius = 73/2;
  62. iconImageView.clipsToBounds = YES;
  63. // iconImageView.image = [UIImage imageNamed:@"vqu_images_tab_live_s"];
  64. //昵称
  65. UILabel *nickLabel = [UILabel new];
  66. self.nickLabel = nickLabel;
  67. [navView addSubview:nickLabel];
  68. [nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.top.mas_equalTo(iconImageView.mas_bottom).offset(7);
  70. make.centerX.mas_equalTo(0);
  71. }];
  72. nickLabel.textColor = LCWhiteColor;
  73. nickLabel.font = LCBoldFont(14);
  74. nickLabel.textAlignment = NSTextAlignmentCenter;
  75. //
  76. //返回
  77. UIButton *cancelBtn = [UIButton new];
  78. [navView addSubview:cancelBtn ];
  79. [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.left.mas_equalTo(10);
  81. make.top.mas_equalTo(StatusBarHeight);
  82. make.size.mas_equalTo(CGSizeMake(40, 40));
  83. }];
  84. [cancelBtn setImage:[UIImage imageNamed:@"vqu_images_D_cancel"] forState:UIControlStateNormal];
  85. //title
  86. UILabel *titleLabel = [UILabel new];
  87. [navView addSubview:titleLabel];
  88. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.centerY.mas_equalTo(cancelBtn);
  90. make.centerX.mas_equalTo(0);
  91. }];
  92. titleLabel.font = LCBoldFont(17);
  93. titleLabel.textColor = [UIColor whiteColor];
  94. titleLabel.text = @"礼物墙";
  95. //事件
  96. [cancelBtn addTarget: self action:@selector(youpaifcancelButtonClick) forControlEvents:UIControlEventTouchUpInside];
  97. }
  98. -(void)youpaifcancelButtonClick{
  99. [self.navigationController popViewControllerAnimated:YES];
  100. }
  101. - (void)youpaifsetupView{
  102. UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 221, KScreenWidth, KScreenHeight-221)];
  103. [self.view addSubview:bgView];
  104. bgView.backgroundColor = LZFAFAFCColor;
  105. [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgView size:CGSizeMake(16, 16)];
  106. //点亮
  107. UIImageView *leftImageview = [UIImageView new];
  108. [bgView addSubview:leftImageview];
  109. [leftImageview mas_makeConstraints:^(MASConstraintMaker *make) {
  110. make.left.mas_equalTo(45);
  111. make.top.mas_equalTo(12);
  112. make.size.mas_equalTo(CGSizeMake(107, 39));
  113. }];
  114. leftImageview.image = [UIImage imageNamed:@"vqu_images_leftImage_Gift"];
  115. //
  116. UIImageView *rightImageview = [UIImageView new];
  117. [bgView addSubview:rightImageview];
  118. [rightImageview mas_makeConstraints:^(MASConstraintMaker *make) {
  119. make.right.mas_equalTo(-45);
  120. make.top.mas_equalTo(12);
  121. make.size.mas_equalTo(CGSizeMake(107, 39));
  122. }];
  123. rightImageview.image = [UIImage imageNamed:@"vqu_images_rightImage_Gift"];
  124. //title
  125. UILabel *titleLabel = [UILabel new];
  126. self.titleLabel = titleLabel;
  127. [bgView addSubview:titleLabel];
  128. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  129. make.centerX.mas_equalTo(0);
  130. make.centerY.mas_equalTo(rightImageview);
  131. }];
  132. titleLabel.font = [UIFont systemFontOfSize:12];
  133. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  134. layout.sectionInset = UIEdgeInsetsMake(14.0f, 14.0f, 14.0f, 14.0f);
  135. CGFloat margin = 5;
  136. CGFloat itemWH = (KScreenWidth-28.0f-15.0f)/4;
  137. layout.itemSize = CGSizeMake(itemWH, itemWH * (89.0f/83.0f));
  138. layout.minimumInteritemSpacing = margin;
  139. layout.minimumLineSpacing = margin;
  140. UICollectionView *youpaipcollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  141. [bgView addSubview:youpaipcollectionView];
  142. self.youpaipcollectionView = youpaipcollectionView;
  143. [youpaipcollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  144. make.top.mas_equalTo(rightImageview.mas_bottom).offset(3.5);
  145. make.left.mas_equalTo(0);
  146. make.right.mas_equalTo(0);
  147. make.bottom.mas_equalTo(0.0f);
  148. }];
  149. youpaipcollectionView.bounces = NO;
  150. youpaipcollectionView.backgroundColor = LZFAFAFCColor;
  151. youpaipcollectionView.dataSource = self;
  152. youpaipcollectionView.delegate = self;
  153. youpaipcollectionView.scrollEnabled = YES;
  154. youpaipcollectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  155. [youpaipcollectionView registerClass:[YOUPAILCReceiveItemCell class] forCellWithReuseIdentifier:@"YOUPAILCReceiveItemCell"];
  156. [youpaipcollectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"receiveGiftheader"];
  157. }
  158. - (void)youpaifinitData{
  159. @weakify(self);
  160. [LCHttpHelper requestWithURLString:UserRecGiftList parameters:@{@"user_id":self.youpaipuserId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  161. @strongify(self);
  162. NSDictionary* dict = (NSDictionary*)responseObject;
  163. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  164. if (code==0) {//成功
  165. self.youpaipreceiveUserId = [[[dict objectForKey:@"data"]objectForKey:@"userid"]integerValue];
  166. // avatar,nickname,gift_total,user_gift_total
  167. [self.iconImageView sd_setImageWithURL:[LCTools getImageUrlWithAddress:[[dict objectForKey:@"data"]objectForKey:@"avatar"]] placeholderImage:nil];
  168. self.nickLabel.text = [[dict objectForKey:@"data"]objectForKey:@"nickname"];
  169. [self.titleLabel setAttributedText:[LCTools setRichTextWithTitle:[NSString stringWithFormat:@"已点亮%@/",[[dict objectForKey:@"data"]objectForKey:@"user_gift_total"]] subTitle:[NSString stringWithFormat:@"%@",[[dict objectForKey:@"data"]objectForKey:@"gift_total"]] titleColor:LZ7C69FEColor subTitleColor:LZA3AABEColor titleFontSize:12 subTitleFontSize:12]];
  170. self.youpaipreceiveGiftArray = [YOUPAILCGiftModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"]objectForKey:@"all_list"]];
  171. [self.youpaipcollectionView reloadData];
  172. if (self.youpaipreceiveGiftArray.count != 0) {
  173. [self.youpaipcollectionView lz_hideEmptyView];
  174. }else{
  175. [self.youpaipcollectionView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_gift_data"] content:@"还没有人给你送礼哦"];
  176. }
  177. }
  178. } failure:^(NSError *error) {
  179. }];
  180. }
  181. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  182. return self.youpaipreceiveGiftArray.count;
  183. }
  184. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  185. YOUPAILCReceiveItemCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"YOUPAILCReceiveItemCell" forIndexPath:indexPath];
  186. YOUPAILCGiftModel *model = self.youpaipreceiveGiftArray[indexPath.row];
  187. cell.youpaipreceiveGiftModel = model;
  188. return cell;
  189. }
  190. //- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath{
  191. // YOUPAILCReceiveItemCell *serviceCell = (YOUPAILCReceiveItemCell*)cell;
  192. //
  193. //
  194. //}
  195. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  196. // YOUPAILCGiftModel *model = self.receiveGiftArray[indexPath.row];
  197. // if ([[LCSaveModel getUserModel].userinfo.user_id isEqualToString:self.userId]) {
  198. // [ZCHUDHelper showTitle:@"不能赠送自己"];
  199. // }else{
  200. // YOUPAILCGiftSendView* sendView = [[YOUPAILCGiftSendView alloc]initWithModel:model type:2];
  201. // //modify by leo fix bug 20191009
  202. // sendView.alertWindow.hidden =NO;
  203. // //sendView.alertWindow.rootViewController = self;
  204. // sendView.sendMultiGift = ^(NSString *giftId, NSInteger count) {
  205. // [LCHttpHelper requestWithURLString:SendGift_New parameters:@{@"type":@(4),@"to_uid":self.userId,@"gift_id":giftId,@"num":@(count)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  206. // NSDictionary* dict = (NSDictionary*)responseObject;
  207. // NSInteger code = [[dict objectForKey:@"code"] integerValue];
  208. // if (code==0) {//成功
  209. // [ZCHUDHelper showTitle:@"礼物赠送成功"];
  210. // }
  211. // } failure:^(NSError *error) {
  212. //
  213. // }];
  214. // };
  215. // [sendView show];
  216. // }
  217. }
  218. @end