// // RQVipTimeCell.m // jiaPei // // Created by 张嵘 on 2022/11/17. // Copyright © 2022 JCZ. All rights reserved. // #import "RQVipTimeCell.h" @interface RQVipTimeCell () @property (nonatomic, readwrite, strong) RQVipTimeItemViewModel *viewModel; @property (weak, nonatomic) IBOutlet UILabel *timeLabel; @property (weak, nonatomic) IBOutlet QMUIButton *openBtn; @property (weak, nonatomic) IBOutlet UILabel *myVipTitleLabel; @end @implementation RQVipTimeCell #pragma mark - PublicMethods + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath { static NSString *ID = @"RQVipTimeCell"; [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID]; RQVipTimeCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath]; if (!cell) cell = [self rq_viewFromXib]; [cell borderColor:RQColorFromHexString(@"#E0B279") width:1 cornorRadius:5]; return cell; } - (void)bindViewModel:(RQVipTimeItemViewModel *)viewModel { // @weakify(self) _viewModel = viewModel; switch (viewModel.homePageSubjectType) { case RQHomePageSubjectType_SubjectOne: { if (RQStringIsNotEmpty(viewModel.videoVipModel.subject1) && viewModel.videoVipModel.subject1Int == 1) { self.myVipTitleLabel.text = @"科一极享VIP"; self.openBtn.hidden = YES; self.timeLabel.hidden = NO; self.timeLabel.text = [NSString stringWithFormat:@"%@到期",viewModel.videoVipModel.subject1]; } else { self.myVipTitleLabel.text = @"开通科一VIP,尊享4大权益"; self.openBtn.hidden = NO; self.timeLabel.hidden = YES; } break; } case RQHomePageSubjectType_SubjectTwo: { if (RQStringIsNotEmpty(viewModel.videoVipModel.subject2) && viewModel.videoVipModel.subject2Int == 1) { self.myVipTitleLabel.text = @"科二极享VIP"; self.openBtn.hidden = YES; self.timeLabel.hidden = NO; self.timeLabel.text = [NSString stringWithFormat:@"%@到期",viewModel.videoVipModel.subject2]; } else { self.myVipTitleLabel.text = @"开通科二VIP,尊享4大权益"; self.openBtn.hidden = NO; self.timeLabel.hidden = YES; } break; } case RQHomePageSubjectType_SubjectThree: { if (RQStringIsNotEmpty(viewModel.videoVipModel.subject3) && viewModel.videoVipModel.subject3Int == 1) { self.myVipTitleLabel.text = @"科三极享VIP"; self.openBtn.hidden = YES; self.timeLabel.hidden = NO; self.timeLabel.text = [NSString stringWithFormat:@"%@到期",viewModel.videoVipModel.subject3]; } else { self.myVipTitleLabel.text = @"开通科三VIP,尊享4大权益"; self.openBtn.hidden = NO; self.timeLabel.hidden = YES; } break; } case RQHomePageSubjectType_SubjectFour: { if (RQStringIsNotEmpty(viewModel.videoVipModel.subject4) && viewModel.videoVipModel.subject4Int == 1) { self.myVipTitleLabel.text = @"科四极享VIP"; self.openBtn.hidden = YES; self.timeLabel.hidden = NO; self.timeLabel.text = [NSString stringWithFormat:@"%@到期",viewModel.videoVipModel.subject4]; } else { self.myVipTitleLabel.text = @"开通科四VIP,尊享4大权益"; self.openBtn.hidden = NO; self.timeLabel.hidden = YES; } break; } default: break; } } - (IBAction)openBtnAction:(id)sender { [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full subject:self.viewModel.homePageSubjectType]; } #pragma mark - SystemMethods - (void)awakeFromNib { [super awakeFromNib]; [self.openBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) { graColor.fromColor = [UIColor qmui_colorWithHexString:@"#DBA05C"]; graColor.toColor = [UIColor qmui_colorWithHexString:@"#F3C085"]; graColor.type = QQGradualChangeTypeLeftToRight; } size:CGSizeMake(RQ_FIT_HORIZONTAL(75.f), RQ_FIT_HORIZONTAL(25.f)) cornerRadius:QQRadiusMakeSame(RQ_FIT_HORIZONTAL(25.f) / 2.f)] forState:UIControlStateNormal]; } @end