RQVipContentCell.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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 UIImageView *jxbj_imageview;
  26. @property (weak, nonatomic) IBOutlet UIStackView *jingxuan500View;
  27. @property (weak, nonatomic) IBOutlet UIStackView *zhenshimoniView;
  28. @property (weak, nonatomic) IBOutlet UIStackView *chongcijuanView;
  29. @end
  30. @implementation RQVipContentCell
  31. #pragma mark - PublicMethods
  32. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  33. static NSString *ID = @"RQVipContentCell";
  34. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  35. RQVipContentCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  36. if (!cell) cell = [self rq_viewFromXib];
  37. [cell borderColor:RQColorFromHexString(@"#E0B279") width:1 cornorRadius:5];
  38. return cell;
  39. }
  40. - (void)bindViewModel:(RQVipContentItemViewModel *)viewModel {
  41. // @weakify(self)
  42. _viewModel = viewModel;
  43. if (viewModel.isCenter) {
  44. self.leftHeaderIcon.image = RQImageNamed(@"标题左3");
  45. self.rightHederIcon.image = RQImageNamed(@"标题右3");
  46. self.backgroundColor = RQColorFromHexString(@"#FFFAF5");
  47. self.oneTitleLabel.textColor = RQColorFromHexString(@"#0A1A33");
  48. self.oneContent1Label.textColor = RQColorFromHexString(@"#8A9099");
  49. self.oneContent2Label.textColor = RQColorFromHexString(@"#8A9099");
  50. self.twoTitleLabel.textColor = RQColorFromHexString(@"#0A1A33");
  51. self.twoContent1Label.textColor = RQColorFromHexString(@"#8A9099");
  52. self.twoContent2Label.textColor = RQColorFromHexString(@"#8A9099");
  53. self.threeTitleLabel.textColor = RQColorFromHexString(@"#0A1A33");
  54. self.threeContentLabel.textColor = RQColorFromHexString(@"#8A9099");
  55. self.threeContent2Label.textColor = RQColorFromHexString(@"#8A9099");
  56. if (viewModel.homePageSubjectType == RQHomePageSubjectType_SubjectOne) {
  57. self.myTitleLabel.text = @"科一怎么学";
  58. self.mySubTitleLabel.text = @"只需三步,轻松学科一";
  59. self.oneTitleLabel.text = @"精简500题";
  60. self.jxbj_imageview.image = [UIImage imageNamed:@"精选500题背景"];
  61. } else if (viewModel.homePageSubjectType == RQHomePageSubjectType_SubjectFour) {
  62. self.myTitleLabel.text = @"科四怎么学";
  63. self.mySubTitleLabel.text = @"只需三步,轻松学科四";
  64. self.oneTitleLabel.text = @"精简300题";
  65. self.jxbj_imageview.image = [UIImage imageNamed:@"精选300题背景"];
  66. }
  67. } else {
  68. self.leftHeaderIcon.image = RQImageNamed(@"标题左2");
  69. self.rightHederIcon.image = RQImageNamed(@"标题右2");
  70. self.backgroundColor = RQColorFromHexString(@"#252531");
  71. self.oneTitleLabel.textColor = RQColorFromHexString(@"#DEA461");
  72. self.oneContent1Label.textColor = RQColorFromHexString(@"#F8DEB8");
  73. self.oneContent2Label.textColor = RQColorFromHexString(@"#F8DEB8");
  74. self.twoTitleLabel.textColor = RQColorFromHexString(@"#DEA461");
  75. self.twoContent1Label.textColor = RQColorFromHexString(@"#F8DEB8");
  76. self.twoContent2Label.textColor = RQColorFromHexString(@"#F8DEB8");
  77. self.threeTitleLabel.textColor = RQColorFromHexString(@"#DEA461");
  78. self.threeContentLabel.textColor = RQColorFromHexString(@"#F8DEB8");
  79. self.threeContent2Label.textColor = RQColorFromHexString(@"#F8DEB8");
  80. if ([viewModel.typeModel.dictLabel containsString:@"一"]) {
  81. self.myTitleLabel.text = @"科一怎么学";
  82. self.mySubTitleLabel.text = @"只需三步,轻松学科一";
  83. self.oneTitleLabel.text = @"精简500题";
  84. self.jxbj_imageview.image = [UIImage imageNamed:@"精选500题背景"];
  85. } else if ([viewModel.typeModel.dictLabel containsString:@"四"]) {
  86. self.myTitleLabel.text = @"科四怎么学";
  87. self.mySubTitleLabel.text = @"只需三步,轻松学科四";
  88. self.oneTitleLabel.text = @"精简300题";
  89. self.jxbj_imageview.image = [UIImage imageNamed:@"精选300题背景"];
  90. }
  91. }
  92. }
  93. - (void)setIndexPath:(NSIndexPath *)indexPath rowsInSection:(NSInteger)rows {
  94. self.backgroundColor = self.viewModel.isCenter? RQColorFromHexString(@"#FFFAF5") : RQColorFromHexString(@"#252531");
  95. }
  96. #pragma mark - SystemMethods
  97. - (void)awakeFromNib {
  98. [super awakeFromNib];
  99. CGFloat width = (69.f / 375.f) * (RQ_SCREEN_WIDTH - 32.f);
  100. CGFloat height = (25.f / 375.f) * (RQ_SCREEN_WIDTH - 32.f);
  101. CGFloat corner = height / 2.f;
  102. 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]]]];
  103. 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]]]];
  104. 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]]]];
  105. [self.jingxuan500View setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  106. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  107. if (isVip) {
  108. NSArray *arr = [[RQ_YDTQuestion_Module getQuestionWithSubject:RQ_YDTQuestion_Module.subject exerciseType:RQExerciseType_HandPick ].rac_sequence.signal map:^id _Nullable(RQYDTQuestionModel *ydtQuestionModel) {
  109. return [RQExerciseModel exerciseModelWithRQYDTQuestionModel:ydtQuestionModel];
  110. }].toArray;
  111. RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  112. RQHomePageCarTypeKey : @(RQ_YDTQuestion_Module.carType),
  113. RQHomePageSubjectTypeKey : @(RQ_YDTQuestion_Module.subject),
  114. RQHomeSubPageTypeKey : @(RQHomeSubPageType_SequentialPractice),
  115. RQViewModelIDKey : @"精选500题",
  116. RQExerciseTypeKey : @(RQExerciseType_HandPick),
  117. RQViewModelUtilKey : arr,
  118. }];
  119. [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
  120. } else {
  121. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  122. }
  123. }];
  124. }];
  125. [self.zhenshimoniView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  126. if(myDelegate.isTrain&&RQ_USER_MANAGER.currentUser.isNotGcbd){//在计时-同时需要过程照片-提示
  127. ShowMsg(@"请先结束理论计时在进行真实考场!");
  128. return;
  129. }
  130. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  131. if (isVip) {
  132. if(RQ_COMMON_MANAGER.APP_SWITCH){//审核状态走web 页
  133. 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];
  134. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
  135. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  136. webViewModel.prefersNavigationBarHidden = YES;
  137. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  138. }else{
  139. //显示真实考场
  140. NYExaminationViewModel *examinationViewModel = [[NYExaminationViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{}];
  141. examinationViewModel.km = RQ_YDTQuestion_Module.subjectStr.intValue;
  142. [RQ_APPDELEGATE.services pushViewModel:examinationViewModel animated:YES];
  143. }
  144. } else {
  145. if (RQ_VIP_Module.freeLookSimExamNum == 1||
  146. RQ_COMMON_MANAGER.APP_SWITCH) {//审核状态不用看广告
  147. if(RQ_COMMON_MANAGER.APP_SWITCH){//审核状态走web 页
  148. 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];
  149. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
  150. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  151. webViewModel.prefersNavigationBarHidden = YES;
  152. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  153. }else{
  154. //显示真实考场
  155. NYExaminationViewModel *examinationViewModel = [[NYExaminationViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{}];
  156. examinationViewModel.km = RQ_YDTQuestion_Module.subjectStr.intValue;
  157. [RQ_APPDELEGATE.services pushViewModel:examinationViewModel animated:YES];
  158. }
  159. RQ_VIP_Module.freeLookSimExamNum = 0;
  160. } else {
  161. if(!RQ_COMMON_MANAGER.APP_SWITCH){
  162. // 修改后的弹窗调用逻辑
  163. NSString *ukey = [NSString stringWithFormat:@"%@%d",RQ_USER_MANAGER.currentUser.loginCode,RQ_YDTQuestion_Module.subjectStr.intValue];
  164. if (![NYTools hasUserWatchedAdToday:ukey]) {
  165. [RQ_ALERTVIEW_MANAGER showAlertWithAlertType:RQAlertType_AD title:@"" message:@"车管所实题,为防恶意刷屏,每日须观看一次广告,即可正常使用。点击观看无反应。请稍等5到10秒。" confirmTitle:@"充值使用" cancelTitle:@"看广告解锁" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  166. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  167. } cancelAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  168. [RQ_AD_Module loadRewardvodAd];
  169. [NYTools saveUWatchedAdToday:ukey];
  170. }];
  171. }else{
  172. //显示真实考场
  173. NYExaminationViewModel *examinationViewModel = [[NYExaminationViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{}];
  174. examinationViewModel.km = RQ_YDTQuestion_Module.subjectStr.intValue;
  175. [RQ_APPDELEGATE.services pushViewModel:examinationViewModel animated:YES];
  176. }
  177. }
  178. }
  179. }
  180. }];
  181. }];
  182. [self.chongcijuanView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  183. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  184. if (isVip) {
  185. RQHoursBeforeExamHomeViewModel *hoursBeforeExamHomeViewModel = [[RQHoursBeforeExamHomeViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  186. [RQ_APPDELEGATE.services pushViewModel:hoursBeforeExamHomeViewModel animated:YES];
  187. } else {
  188. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  189. }
  190. }];
  191. }];
  192. }
  193. #pragma mark - PrivateMethods
  194. @end