// // QXMeetActivityRecordView.m // QXLive // // Created by 启星 on 2025/8/26. // #import "QXMeetActivityRecordView.h" @interface QXMeetActivityRecordView() @property(nonatomic,strong)UIView* bgView; @property(nonatomic,strong)UIImageView* ruleImageView; @property(nonatomic,strong)UIImageView* bgImageView; @property(nonatomic,strong)UIView* bgCoverView; @property(nonatomic,strong)UICollectionView* collectionView; @property(nonatomic,strong)NSMutableArray* myRecordArray; @property(nonatomic,strong)NSMutableArray* allRecordArray; @property(nonatomic,assign)NSInteger page; @end @implementation QXMeetActivityRecordView - (instancetype)init { self = [super init]; if (self) { self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); [self initSubviews]; } return self; } -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{ return touch.view == self; } -(void)initSubviews{ UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)]; tap.delegate = self; [self addGestureRecognizer:tap]; self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3]; self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(663))]; [self.bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)]; [self addSubview:self.bgView]; self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"meet_rule_bg"]]; self.bgImageView.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(663)); self.bgImageView.contentMode = UIViewContentModeScaleToFill; [self.bgView addSubview:self.bgImageView]; self.ruleImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"meet_record_icon"]]; self.ruleImageView.contentMode = UIViewContentModeScaleToFill; self.ruleImageView.frame = CGRectMake((SCREEN_WIDTH-ScaleWidth(164))/2, 0, ScaleWidth(164), ScaleWidth(90)); [self.bgView addSubview:self.ruleImageView]; self.bgCoverView = [[UIView alloc] initWithFrame:CGRectMake(16, self.ruleImageView.bottom+12, self.bgView.width-32, self.bgView.height-self.ruleImageView.bottom-24)]; self.bgCoverView.backgroundColor = RGB16A(0x000000, 0.5); [self.bgView addSubview:self.bgCoverView]; [self.bgCoverView addSubview:self.collectionView]; } -(void)setRoomId:(NSString *)roomId{ _roomId = roomId; self.page = 1; [self getRecordList]; } -(void)getRecordList{ if (![self.roomId isExist]) { return; } MJWeakSelf NSDictionary *parameters = @{ @"room_id":self.roomId?self.roomId:@"", @"page":[NSNumber numberWithInteger:self.page] }; NSString *url = [NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/get_xlh_my_record"]; [[QXRequset shareInstance] postWithUrl:url parameters:parameters needCache:NO success:^(id responseObject) { if (weakSelf.page == 1) { [weakSelf.myRecordArray removeAllObjects]; } NSArray *arr = [NSArray yy_modelArrayWithClass:[QXActivityRecordModel class] json:responseObject[@"data"]]; [weakSelf.myRecordArray addObjectsFromArray:arr]; [weakSelf.collectionView reloadData]; if (arr.count == 0) { weakSelf.collectionView.mj_footer.state = MJRefreshStateNoMoreData; }else{ [weakSelf.collectionView.mj_footer endRefreshing]; } [weakSelf.collectionView.mj_header endRefreshing]; } fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) { [weakSelf.collectionView.mj_footer endRefreshing]; [weakSelf.collectionView.mj_header endRefreshing]; }]; } -(void)showInView:(UIView *)view{ self.bgView.y = SCREEN_HEIGHT; [view addSubview:self]; [UIView animateWithDuration:0.3 animations:^{ self.bgView.y = SCREEN_HEIGHT-ScaleWidth(663); }]; } -(void)hide{ // [self stopSlowAnimate]; [UIView animateWithDuration:0.3 animations:^{ self.bgView.y = SCREEN_HEIGHT; } completion:^(BOOL finished) { [self removeFromSuperview]; }]; } -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ // if (self.myRecordBtn.selected) { return self.myRecordArray.count; // }else{ // return self.allRecordArray.count; // } } - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ QXMeetRecordCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXMeetRecordCell" forIndexPath:indexPath]; // if (self.myRecordBtn.selected) { cell.model = self.myRecordArray[indexPath.row]; // }else{ // cell.model = self.allRecordArray[indexPath.row]; // } return cell; } -(UICollectionView *)collectionView{ if (!_collectionView) { UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; layout.minimumLineSpacing = 16; layout.minimumInteritemSpacing = 16; layout.sectionInset = UIEdgeInsetsMake(0, 12, 0, 12); layout.itemSize = CGSizeMake((self.bgCoverView.width-12*2-16*2)/3, ScaleWidth(123)); _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 10, self.bgCoverView.width, self.bgCoverView.height-10) collectionViewLayout:layout]; _collectionView.delegate = self; _collectionView.dataSource = self; _collectionView.showsHorizontalScrollIndicator = NO; _collectionView.showsVerticalScrollIndicator = NO; _collectionView.backgroundColor = [UIColor clearColor]; [_collectionView registerClass:[QXMeetRecordCell class] forCellWithReuseIdentifier:@"QXMeetRecordCell"]; MJWeakSelf _collectionView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{ weakSelf.page++; [weakSelf getRecordList]; }]; _collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ weakSelf.page = 1; [weakSelf getRecordList]; }]; } return _collectionView; } -(NSMutableArray *)myRecordArray{ if (!_myRecordArray) { _myRecordArray =[NSMutableArray array]; } return _myRecordArray; } - (NSMutableArray *)allRecordArray{ if (!_allRecordArray) { _allRecordArray = [NSMutableArray array]; } return _allRecordArray; } @end @implementation QXMeetRecordCell - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initSubviews]; } return self; } -(void)setModel:(QXActivityRecordModel *)model{ _model = model; // self.giftInfoLabel.text = [NSString stringWithFormat:@"%@x%@",model.gift_name,model.count]; self.recieveInfoLabel.text = [NSString stringWithFormat:@"%@X%@",model.gift_name,model.count]; [self.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.base_image]]; self.timeLabel.text = model.createtime; } -(void)initSubviews{ self.giftImageView = [[UIImageView alloc] init]; self.giftImageView.contentMode = UIViewContentModeScaleAspectFit; [self.contentView addSubview:self.giftImageView]; [self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.contentView); make.left.equalTo(self.contentView).offset(8); make.right.equalTo(self.contentView).offset(-8); make.height.equalTo(self.giftImageView.mas_width); }]; self.giftInfoLabel = [[UILabel alloc] init]; self.giftInfoLabel.textColor = RGB16(0xffffff); self.giftInfoLabel.font = [UIFont systemFontOfSize:12]; [self.contentView addSubview:self.giftInfoLabel]; [self.giftInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.right.equalTo(self.contentView); }]; self.recieveInfoLabel = [[UILabel alloc] init]; self.recieveInfoLabel.textColor = RGB16(0xffffff); self.recieveInfoLabel.font = [UIFont systemFontOfSize:14]; self.recieveInfoLabel.textAlignment = NSTextAlignmentCenter; [self.contentView addSubview:self.recieveInfoLabel]; [self.recieveInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.giftImageView.mas_bottom).offset(4); make.left.right.equalTo(self.contentView); make.height.mas_equalTo(21); }]; self.giftInfoLabel.hidden = YES; self.timeLabel = [[UILabel alloc] init]; self.timeLabel.textColor = RGB16(0x5B5B5B); self.timeLabel.font = [UIFont systemFontOfSize:10]; [self.contentView addSubview:self.timeLabel]; [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.contentView); make.left.right.equalTo(self.contentView); }]; } @end