123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- //
- // YOUPAIBBReceiveGiftVC.m
- // VQU
- //
- // Created by Elaine on 2021/11/15.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAIBBReceiveGiftVC.h"
- #import "YOUPAILCReceiveItemCell.h"
- #import "YOUPAILCGiftSendView.h"
- @interface YOUPAIBBReceiveGiftVC ()<UICollectionViewDelegate,UICollectionViewDataSource>
- @property (nonatomic,strong)NSMutableArray* youpaipreceiveGiftArray;
- @property (nonatomic,strong)UICollectionView *youpaipcollectionView;
- @property (nonatomic,assign)NSInteger youpaipreceiveUserId;
- @end
- @implementation YOUPAIBBReceiveGiftVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.title = @"我的礼物";
-
- self.youpaipreceiveGiftArray = [NSMutableArray array];
- [self youpaifsetupView];
- [self youpaifinitData];
- }
- - (void)youpaifsetupView{
- 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;
- _youpaipcollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, NavBarHeight, KScreenWidth, KScreenHeight-NavBarHeight) collectionViewLayout:layout];
- _youpaipcollectionView.bounces = NO;
- _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"];
- _youpaipcollectionView.backgroundColor = LCBkgColor;
- [self.view addSubview:_youpaipcollectionView];
- }
- - (void)youpaifinitData{
- [LCHttpHelper requestWithURLString:UserRecGiftList parameters:@{@"user_id":[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- self.youpaipreceiveUserId = [[[dict objectForKey:@"data"]objectForKey:@"userid"]integerValue];
- self.youpaipreceiveGiftArray = [YOUPAILCGiftModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"]objectForKey:@"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 = (YOUPAILCReceiveItemCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"YOUPAILCReceiveItemCell" forIndexPath:indexPath];
-
- return cell;
- }
- - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath{
- YOUPAILCReceiveItemCell *serviceCell = (YOUPAILCReceiveItemCell*)cell;
- YOUPAILCGiftModel *model = self.youpaipreceiveGiftArray[indexPath.row];
- serviceCell.youpaipreceiveGiftModel = model;
-
- }
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
- // YOUPAILCGiftModel *model = self.youpaipreceiveGiftArray[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
|