RQVipTimeCell.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // RQVipTimeCell.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/11/17.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQVipTimeCell.h"
  9. @interface RQVipTimeCell ()
  10. @property (nonatomic, readwrite, strong) RQVipTimeItemViewModel *viewModel;
  11. @property (weak, nonatomic) IBOutlet UILabel *timeLabel;
  12. @property (weak, nonatomic) IBOutlet QMUIButton *openBtn;
  13. @property (weak, nonatomic) IBOutlet UILabel *myVipTitleLabel;
  14. @end
  15. @implementation RQVipTimeCell
  16. #pragma mark - PublicMethods
  17. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  18. static NSString *ID = @"RQVipTimeCell";
  19. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  20. RQVipTimeCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  21. if (!cell) cell = [self rq_viewFromXib];
  22. [cell borderColor:RQColorFromHexString(@"#E0B279") width:1 cornorRadius:5];
  23. return cell;
  24. }
  25. - (void)bindViewModel:(RQVipTimeItemViewModel *)viewModel {
  26. // @weakify(self)
  27. _viewModel = viewModel;
  28. switch (viewModel.homePageSubjectType) {
  29. case RQHomePageSubjectType_SubjectOne: {
  30. if (RQStringIsNotEmpty(viewModel.videoVipModel.subject1) && viewModel.videoVipModel.subject1Int == 1) {
  31. self.myVipTitleLabel.text = @"科一极享VIP";
  32. self.openBtn.hidden = YES;
  33. self.timeLabel.hidden = NO;
  34. self.timeLabel.text = [NSString stringWithFormat:@"%@到期",viewModel.videoVipModel.subject1];
  35. } else {
  36. self.myVipTitleLabel.text = @"开通科一VIP,尊享4大权益";
  37. self.openBtn.hidden = NO;
  38. self.timeLabel.hidden = YES;
  39. }
  40. break;
  41. }
  42. case RQHomePageSubjectType_SubjectTwo: {
  43. if (RQStringIsNotEmpty(viewModel.videoVipModel.subject2) && viewModel.videoVipModel.subject2Int == 1) {
  44. self.myVipTitleLabel.text = @"科二极享VIP";
  45. self.openBtn.hidden = YES;
  46. self.timeLabel.hidden = NO;
  47. self.timeLabel.text = [NSString stringWithFormat:@"%@到期",viewModel.videoVipModel.subject2];
  48. } else {
  49. self.myVipTitleLabel.text = @"开通科二VIP,尊享4大权益";
  50. self.openBtn.hidden = NO;
  51. self.timeLabel.hidden = YES;
  52. }
  53. break;
  54. }
  55. case RQHomePageSubjectType_SubjectThree: {
  56. if (RQStringIsNotEmpty(viewModel.videoVipModel.subject3) && viewModel.videoVipModel.subject3Int == 1) {
  57. self.myVipTitleLabel.text = @"科三极享VIP";
  58. self.openBtn.hidden = YES;
  59. self.timeLabel.hidden = NO;
  60. self.timeLabel.text = [NSString stringWithFormat:@"%@到期",viewModel.videoVipModel.subject3];
  61. } else {
  62. self.myVipTitleLabel.text = @"开通科三VIP,尊享4大权益";
  63. self.openBtn.hidden = NO;
  64. self.timeLabel.hidden = YES;
  65. }
  66. break;
  67. }
  68. case RQHomePageSubjectType_SubjectFour: {
  69. if (RQStringIsNotEmpty(viewModel.videoVipModel.subject4) && viewModel.videoVipModel.subject4Int == 1) {
  70. self.myVipTitleLabel.text = @"科四极享VIP";
  71. self.openBtn.hidden = YES;
  72. self.timeLabel.hidden = NO;
  73. self.timeLabel.text = [NSString stringWithFormat:@"%@到期",viewModel.videoVipModel.subject4];
  74. } else {
  75. self.myVipTitleLabel.text = @"开通科四VIP,尊享4大权益";
  76. self.openBtn.hidden = NO;
  77. self.timeLabel.hidden = YES;
  78. }
  79. break;
  80. }
  81. default:
  82. break;
  83. }
  84. }
  85. - (IBAction)openBtnAction:(id)sender {
  86. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full subject:self.viewModel.homePageSubjectType];
  87. }
  88. #pragma mark - SystemMethods
  89. - (void)awakeFromNib {
  90. [super awakeFromNib];
  91. [self.openBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  92. graColor.fromColor = [UIColor qmui_colorWithHexString:@"#DBA05C"];
  93. graColor.toColor = [UIColor qmui_colorWithHexString:@"#F3C085"];
  94. graColor.type = QQGradualChangeTypeLeftToRight;
  95. } size:CGSizeMake(RQ_FIT_HORIZONTAL(75.f), RQ_FIT_HORIZONTAL(25.f)) cornerRadius:QQRadiusMakeSame(RQ_FIT_HORIZONTAL(25.f) / 2.f)] forState:UIControlStateNormal];
  96. }
  97. @end