123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- //
- // YOUPAILCReceiveGiftVC.m
- // LiveChat
- //
- // Created by 张灿 on 2018/9/28.
- // Copyright © 2018年 caicai. All rights reserved.
- //
- #import "YOUPAILCReceiveGiftVC.h"
- #import "YOUPAILCReceiveItemCell.h"
- #import "YOUPAILCGiftSendView.h"
- @interface YOUPAILCReceiveGiftVC ()<UICollectionViewDelegate,UICollectionViewDataSource>
- @property (nonatomic,strong)NSMutableArray* youpaipreceiveGiftArray;
- @property (nonatomic,weak)UICollectionView *youpaipcollectionView;
- @property (nonatomic,assign)NSInteger youpaipreceiveUserId;
- @property(nonatomic,strong)UIImageView *navView;
- @property(nonatomic,strong)UIImageView *iconImageView;//头像
- @property(nonatomic,strong)UILabel *nickLabel;//昵称
- @property(nonatomic,strong)UILabel *titleLabel;//点亮和总数
- @end
- @implementation YOUPAILCReceiveGiftVC
- -(void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- self.navigationController.navigationBarHidden = YES;
-
- }
- - (void)viewWillDisappear:(BOOL)animated{
- [super viewWillDisappear:animated];
- self.navigationController.navigationBarHidden = NO;
-
- }
- - (void)dealloc{
-
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.youpaipreceiveGiftArray = [NSMutableArray array];
- [self youpaifloadNavView];
- [self youpaifsetupView];
- [self youpaifinitData];
- }
- -(void)youpaifloadNavView{
- UIImageView *navView = [UIImageView new];
- self.navView = navView;
- [self.view addSubview:navView];
- [navView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(0);
- make.height.mas_equalTo(250);
- }];
- navView.contentMode = UIViewContentModeScaleAspectFill;
- navView.userInteractionEnabled = YES;
- navView.image = [UIImage imageNamed:@"vqu_images_gift_headerViewBg"];
- //头像
- UIImageView *iconImageView = [UIImageView new];
- self.iconImageView = iconImageView;
- [navView addSubview:iconImageView];
- [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_equalTo(0);
- make.top.mas_equalTo(104);
- make.size.mas_equalTo(CGSizeMake(73, 73));
- }];
- iconImageView.contentMode = UIViewContentModeScaleAspectFill;
- iconImageView.layer.cornerRadius = 73/2;
- iconImageView.clipsToBounds = YES;
- // iconImageView.image = [UIImage imageNamed:@"vqu_images_tab_live_s"];
- //昵称
- UILabel *nickLabel = [UILabel new];
- self.nickLabel = nickLabel;
- [navView addSubview:nickLabel];
- [nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(iconImageView.mas_bottom).offset(7);
- make.centerX.mas_equalTo(0);
- }];
- nickLabel.textColor = LCWhiteColor;
- nickLabel.font = LCBoldFont(14);
-
- nickLabel.textAlignment = NSTextAlignmentCenter;
- //
- //返回
- UIButton *cancelBtn = [UIButton new];
- [navView addSubview:cancelBtn ];
- [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.top.mas_equalTo(StatusBarHeight);
- make.size.mas_equalTo(CGSizeMake(40, 40));
- }];
- [cancelBtn setImage:[UIImage imageNamed:@"vqu_images_D_cancel"] forState:UIControlStateNormal];
-
- //title
- UILabel *titleLabel = [UILabel new];
- [navView addSubview:titleLabel];
- [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(cancelBtn);
- make.centerX.mas_equalTo(0);
- }];
-
- titleLabel.font = LCBoldFont(17);
- titleLabel.textColor = [UIColor whiteColor];
- titleLabel.text = @"礼物墙";
-
-
- //事件
- [cancelBtn addTarget: self action:@selector(youpaifcancelButtonClick) forControlEvents:UIControlEventTouchUpInside];
-
- }
- -(void)youpaifcancelButtonClick{
- [self.navigationController popViewControllerAnimated:YES];
-
- }
- - (void)youpaifsetupView{
-
- UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 221, KScreenWidth, KScreenHeight-221)];
- [self.view addSubview:bgView];
- bgView.backgroundColor = LZFAFAFCColor;
- [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgView size:CGSizeMake(16, 16)];
- //点亮
- UIImageView *leftImageview = [UIImageView new];
- [bgView addSubview:leftImageview];
- [leftImageview mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(45);
- make.top.mas_equalTo(12);
- make.size.mas_equalTo(CGSizeMake(107, 39));
- }];
- leftImageview.image = [UIImage imageNamed:@"vqu_images_leftImage_Gift"];
- //
- UIImageView *rightImageview = [UIImageView new];
- [bgView addSubview:rightImageview];
- [rightImageview mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-45);
- make.top.mas_equalTo(12);
- make.size.mas_equalTo(CGSizeMake(107, 39));
- }];
- rightImageview.image = [UIImage imageNamed:@"vqu_images_rightImage_Gift"];
- //title
- UILabel *titleLabel = [UILabel new];
- self.titleLabel = titleLabel;
- [bgView addSubview:titleLabel];
- [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_equalTo(0);
- make.centerY.mas_equalTo(rightImageview);
- }];
-
- titleLabel.font = [UIFont systemFontOfSize:12];
-
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
- layout.sectionInset = UIEdgeInsetsMake(14.0f, 14.0f, 14.0f, 14.0f);
- CGFloat margin = 5;
- CGFloat itemWH = (KScreenWidth-28.0f-15.0f)/4;
- layout.itemSize = CGSizeMake(itemWH, itemWH * (89.0f/83.0f));
- layout.minimumInteritemSpacing = margin;
- layout.minimumLineSpacing = margin;
- UICollectionView *youpaipcollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
- [bgView addSubview:youpaipcollectionView];
- self.youpaipcollectionView = youpaipcollectionView;
- [youpaipcollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(rightImageview.mas_bottom).offset(3.5);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0.0f);
- }];
- youpaipcollectionView.bounces = NO;
- youpaipcollectionView.backgroundColor = LZFAFAFCColor;
- youpaipcollectionView.dataSource = self;
- youpaipcollectionView.delegate = self;
- youpaipcollectionView.scrollEnabled = YES;
- youpaipcollectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- [youpaipcollectionView registerClass:[YOUPAILCReceiveItemCell class] forCellWithReuseIdentifier:@"YOUPAILCReceiveItemCell"];
- [youpaipcollectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"receiveGiftheader"];
-
-
- }
- - (void)youpaifinitData{
- @weakify(self);
- [LCHttpHelper requestWithURLString:UserRecGiftList parameters:@{@"user_id":self.youpaipuserId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- self.youpaipreceiveUserId = [[[dict objectForKey:@"data"]objectForKey:@"userid"]integerValue];
- // avatar,nickname,gift_total,user_gift_total
- [self.iconImageView sd_setImageWithURL:[LCTools getImageUrlWithAddress:[[dict objectForKey:@"data"]objectForKey:@"avatar"]] placeholderImage:nil];
- self.nickLabel.text = [[dict objectForKey:@"data"]objectForKey:@"nickname"];
- [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]];
-
- self.youpaipreceiveGiftArray = [YOUPAILCGiftModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"]objectForKey:@"all_list"]];
- [self.youpaipcollectionView reloadData];
- if (self.youpaipreceiveGiftArray.count != 0) {
- [self.youpaipcollectionView lz_hideEmptyView];
- }else{
- [self.youpaipcollectionView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_gift_data"] content:@"还没有人给你送礼哦"];
- }
- }
- } failure:^(NSError *error) {
-
- }];
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
- return self.youpaipreceiveGiftArray.count;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
- YOUPAILCReceiveItemCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"YOUPAILCReceiveItemCell" forIndexPath:indexPath];
- YOUPAILCGiftModel *model = self.youpaipreceiveGiftArray[indexPath.row];
- cell.youpaipreceiveGiftModel = model;
- return cell;
- }
- //- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath{
- // YOUPAILCReceiveItemCell *serviceCell = (YOUPAILCReceiveItemCell*)cell;
- //
- //
- //}
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
- // YOUPAILCGiftModel *model = self.receiveGiftArray[indexPath.row];
- // if ([[LCSaveModel getUserModel].userinfo.user_id isEqualToString:self.userId]) {
- // [ZCHUDHelper showTitle:@"不能赠送自己"];
- // }else{
- // YOUPAILCGiftSendView* sendView = [[YOUPAILCGiftSendView alloc]initWithModel:model type:2];
- // //modify by leo fix bug 20191009
- // sendView.alertWindow.hidden =NO;
- // //sendView.alertWindow.rootViewController = self;
- // sendView.sendMultiGift = ^(NSString *giftId, NSInteger count) {
- // [LCHttpHelper requestWithURLString:SendGift_New parameters:@{@"type":@(4),@"to_uid":self.userId,@"gift_id":giftId,@"num":@(count)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- // NSDictionary* dict = (NSDictionary*)responseObject;
- // NSInteger code = [[dict objectForKey:@"code"] integerValue];
- // if (code==0) {//成功
- // [ZCHUDHelper showTitle:@"礼物赠送成功"];
- // }
- // } failure:^(NSError *error) {
- //
- // }];
- // };
- // [sendView show];
- // }
- }
- @end
|