RQVipContentCell.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. //
  2. // RQVipContentCell.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/3/1.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQVipContentCell.h"
  9. @interface RQVipContentCell ()
  10. @property (nonatomic, readwrite, strong) RQVipContentItemViewModel *viewModel;
  11. @property (weak, nonatomic) IBOutlet UIImageView *leftHeaderIcon;
  12. @property (weak, nonatomic) IBOutlet UIImageView *rightHederIcon;
  13. @property (weak, nonatomic) IBOutlet UILabel *oneStepLabel;
  14. @property (weak, nonatomic) IBOutlet UILabel *twoStepLabel;
  15. @property (weak, nonatomic) IBOutlet UILabel *threeStepLabel;
  16. @property (weak, nonatomic) IBOutlet UILabel *oneTitleLabel;
  17. @property (weak, nonatomic) IBOutlet UILabel *oneContent1Label;
  18. @property (weak, nonatomic) IBOutlet UILabel *oneContent2Label;
  19. @property (weak, nonatomic) IBOutlet UILabel *twoTitleLabel;
  20. @property (weak, nonatomic) IBOutlet UILabel *twoContent1Label;
  21. @property (weak, nonatomic) IBOutlet UILabel *twoContent2Label;
  22. @property (weak, nonatomic) IBOutlet UILabel *threeTitleLabel;
  23. @property (weak, nonatomic) IBOutlet UILabel *threeContentLabel;
  24. @property (weak, nonatomic) IBOutlet UILabel *threeContent2Label;
  25. @property (weak, nonatomic) IBOutlet UIStackView *jingxuan500View;
  26. @property (weak, nonatomic) IBOutlet UIStackView *zhenshimoniView;
  27. @property (weak, nonatomic) IBOutlet UIStackView *chongcijuanView;
  28. @end
  29. @implementation RQVipContentCell
  30. #pragma mark - PublicMethods
  31. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  32. static NSString *ID = @"RQVipContentCell";
  33. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  34. RQVipContentCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  35. if (!cell) cell = [self rq_viewFromXib];
  36. [cell borderColor:RQColorFromHexString(@"#E0B279") width:1 cornorRadius:5];
  37. return cell;
  38. }
  39. - (void)bindViewModel:(RQVipContentItemViewModel *)viewModel {
  40. // @weakify(self)
  41. _viewModel = viewModel;
  42. if (viewModel.isCenter) {
  43. self.leftHeaderIcon.image = RQImageNamed(@"标题左3");
  44. self.rightHederIcon.image = RQImageNamed(@"标题右3");
  45. self.backgroundColor = RQColorFromHexString(@"#FFFAF5");
  46. self.oneTitleLabel.textColor = RQColorFromHexString(@"#0A1A33");
  47. self.oneContent1Label.textColor = RQColorFromHexString(@"#8A9099");
  48. self.oneContent2Label.textColor = RQColorFromHexString(@"#8A9099");
  49. self.twoTitleLabel.textColor = RQColorFromHexString(@"#0A1A33");
  50. self.twoContent1Label.textColor = RQColorFromHexString(@"#8A9099");
  51. self.twoContent2Label.textColor = RQColorFromHexString(@"#8A9099");
  52. self.threeTitleLabel.textColor = RQColorFromHexString(@"#0A1A33");
  53. self.threeContentLabel.textColor = RQColorFromHexString(@"#8A9099");
  54. self.threeContent2Label.textColor = RQColorFromHexString(@"#8A9099");
  55. if (viewModel.homePageSubjectType == RQHomePageSubjectType_SubjectOne) {
  56. self.myTitleLabel.text = @"科一怎么学";
  57. self.mySubTitleLabel.text = @"只需三步,轻松学科一";
  58. } else if (viewModel.homePageSubjectType == RQHomePageSubjectType_SubjectFour) {
  59. self.myTitleLabel.text = @"科四怎么学";
  60. self.mySubTitleLabel.text = @"只需三步,轻松学科四";
  61. }
  62. } else {
  63. self.leftHeaderIcon.image = RQImageNamed(@"标题左2");
  64. self.rightHederIcon.image = RQImageNamed(@"标题右2");
  65. self.backgroundColor = RQColorFromHexString(@"#252531");
  66. self.oneTitleLabel.textColor = RQColorFromHexString(@"#DEA461");
  67. self.oneContent1Label.textColor = RQColorFromHexString(@"#F8DEB8");
  68. self.oneContent2Label.textColor = RQColorFromHexString(@"#F8DEB8");
  69. self.twoTitleLabel.textColor = RQColorFromHexString(@"#DEA461");
  70. self.twoContent1Label.textColor = RQColorFromHexString(@"#F8DEB8");
  71. self.twoContent2Label.textColor = RQColorFromHexString(@"#F8DEB8");
  72. self.threeTitleLabel.textColor = RQColorFromHexString(@"#DEA461");
  73. self.threeContentLabel.textColor = RQColorFromHexString(@"#F8DEB8");
  74. self.threeContent2Label.textColor = RQColorFromHexString(@"#F8DEB8");
  75. if ([viewModel.typeModel.dictLabel containsString:@"一"]) {
  76. self.myTitleLabel.text = @"科一怎么学";
  77. self.mySubTitleLabel.text = @"只需三步,轻松学科一";
  78. } else if ([viewModel.typeModel.dictLabel containsString:@"四"]) {
  79. self.myTitleLabel.text = @"科四怎么学";
  80. self.mySubTitleLabel.text = @"只需三步,轻松学科四";
  81. }
  82. }
  83. }
  84. - (void)setIndexPath:(NSIndexPath *)indexPath rowsInSection:(NSInteger)rows {
  85. self.backgroundColor = self.viewModel.isCenter? RQColorFromHexString(@"#FFFAF5") : RQColorFromHexString(@"#252531");
  86. }
  87. #pragma mark - SystemMethods
  88. - (void)awakeFromNib {
  89. [super awakeFromNib];
  90. CGFloat width = (69.f / 375.f) * (RQ_SCREEN_WIDTH - 32.f);
  91. CGFloat height = (25.f / 375.f) * (RQ_SCREEN_WIDTH - 32.f);
  92. CGFloat corner = height / 2.f;
  93. self.oneStepLabel.backgroundColor = [UIColor colorWithPatternImage:[UIImage qmui_imageWithGradientColors:@[RQColorFromHexString(@"#DBA05C"),RQColorFromHexString(@"#F3C085")] type:QMUIImageGradientTypeTopLeftToBottomRight locations:nil size:CGSizeMake(width, height) cornerRadiusArray:@[@0,@0,[NSNumber numberWithFloat:corner],[NSNumber numberWithFloat:corner]]]];
  94. self.twoStepLabel.backgroundColor = [UIColor colorWithPatternImage:[UIImage qmui_imageWithGradientColors:@[RQColorFromHexString(@"#DBA05C"),RQColorFromHexString(@"#F3C085")] type:QMUIImageGradientTypeTopLeftToBottomRight locations:nil size:CGSizeMake(width, height) cornerRadiusArray:@[@0,@0,[NSNumber numberWithFloat:corner],[NSNumber numberWithFloat:corner]]]];
  95. self.threeStepLabel.backgroundColor = [UIColor colorWithPatternImage:[UIImage qmui_imageWithGradientColors:@[RQColorFromHexString(@"#DBA05C"),RQColorFromHexString(@"#F3C085")] type:QMUIImageGradientTypeTopLeftToBottomRight locations:nil size:CGSizeMake(width, height) cornerRadiusArray:@[@0,@0,[NSNumber numberWithFloat:corner],[NSNumber numberWithFloat:corner]]]];
  96. [self.jingxuan500View setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  97. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  98. if (isVip) {
  99. NSArray *arr = [[RQ_YDTQuestion_Module getQuestionWithSubject:RQ_YDTQuestion_Module.subject exerciseType:RQExerciseType_HandPick ].rac_sequence.signal map:^id _Nullable(RQYDTQuestionModel *ydtQuestionModel) {
  100. return [RQExerciseModel exerciseModelWithRQYDTQuestionModel:ydtQuestionModel];
  101. }].toArray;
  102. RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  103. RQHomePageCarTypeKey : @(RQ_YDTQuestion_Module.carType),
  104. RQHomePageSubjectTypeKey : @(RQ_YDTQuestion_Module.subject),
  105. RQHomeSubPageTypeKey : @(RQHomeSubPageType_SequentialPractice),
  106. RQViewModelIDKey : @"精选500题",
  107. RQExerciseTypeKey : @(RQExerciseType_HandPick),
  108. RQViewModelUtilKey : arr,
  109. }];
  110. [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
  111. } else {
  112. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  113. }
  114. }];
  115. }];
  116. [self.zhenshimoniView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  117. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  118. if (isVip) {
  119. NSString *urlStr = [NSString stringWithFormat:@"https://mn.zzxcx.net/#/exam/begin?username=%@&subject=%@&model=%@&headimg=%@",[RQ_USER_MANAGER.currentUser.userName qmui_stringByEncodingUserInputQuery],RQ_YDTQuestion_Module.subjectStr,RQ_YDTQuestion_Module.carTypeStrNew,RQ_USER_MANAGER.currentUser.photo];
  120. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
  121. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  122. webViewModel.prefersNavigationBarHidden = YES;
  123. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  124. } else {
  125. if (RQ_VIP_Module.freeLookSimExamNum == 1) {
  126. NSString *urlStr = [NSString stringWithFormat:@"https://mn.zzxcx.net/#/exam/begin?username=%@&subject=%@&model=%@&headimg=%@",[RQ_USER_MANAGER.currentUser.userName qmui_stringByEncodingUserInputQuery],RQ_YDTQuestion_Module.subjectStr,RQ_YDTQuestion_Module.carTypeStrNew,RQ_USER_MANAGER.currentUser.photo];
  127. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
  128. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  129. webViewModel.prefersNavigationBarHidden = YES;
  130. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  131. RQ_VIP_Module.freeLookSimExamNum = 0;
  132. } else {
  133. [RQ_ALERTVIEW_MANAGER showAlertWithAlertType:RQAlertType_AD title:@"" message:@"" confirmTitle:@"充值会员无限使用" cancelTitle:@"看广告解锁使用" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  134. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  135. } cancelAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  136. [RQ_AD_Module loadRewardvodAd];
  137. }];
  138. }
  139. }
  140. }];
  141. }];
  142. [self.chongcijuanView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  143. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  144. if (isVip) {
  145. RQHoursBeforeExamHomeViewModel *hoursBeforeExamHomeViewModel = [[RQHoursBeforeExamHomeViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  146. [RQ_APPDELEGATE.services pushViewModel:hoursBeforeExamHomeViewModel animated:YES];
  147. } else {
  148. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  149. }
  150. }];
  151. }];
  152. }
  153. #pragma mark - PrivateMethods
  154. @end