RQHomePageOneOrFourSmallItemViewModel.m 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //
  2. // RQHomePageOneOrFourSmallItemViewModel.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/6/10.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQHomePageOneOrFourSmallItemViewModel.h"
  9. @interface RQHomePageOneOrFourSmallItemViewModel ()
  10. @property (nonatomic, readwrite, assign) RQHomePageCarType homePageCarType;
  11. @property (nonatomic, readwrite, assign) RQHomePageSubjectType homePageSubjectType;
  12. @end
  13. @implementation RQHomePageOneOrFourSmallItemViewModel
  14. /// init
  15. - (instancetype)initWithRQHomePageCarType:(RQHomePageCarType)homePageCarType homePageSubjectType:(RQHomePageSubjectType)homePageSubjectType homePageOneOrFourItemModel:(RQHomePageOneOrFourItemModel *)homePageOneOrFourItemModel {
  16. if (self = [super init]) {
  17. self.homePageCarType = homePageCarType;
  18. self.homePageSubjectType = homePageSubjectType;
  19. CGFloat width = (RQ_SCREEN_WIDTH - (16 * 2) - 11) / 2.f;
  20. CGFloat height = width * (48.f / 167.f);
  21. self.itemSize = CGSizeMake(width, height);
  22. self.title = homePageOneOrFourItemModel.titleStr;
  23. self.icon = homePageOneOrFourItemModel.iconImgStr;
  24. if ([self.title isEqualToString:@"VIP课程"]) {
  25. self.operation = ^{
  26. [RQ_VIP_Module isVipWithSubject:0 complete:^(BOOL isVip) {
  27. if (RQ_VIP_Module.isVip) {
  28. [RQ_VIP_Module gotoVipCenter];
  29. } else {
  30. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  31. }
  32. }];
  33. };
  34. } else if ([self.title isEqualToString:@"真实考场"]) {
  35. self.operation = ^{
  36. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  37. if (isVip) {
  38. // username subject headimg gs 替换-> model
  39. 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];
  40. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
  41. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  42. webViewModel.prefersNavigationBarHidden = YES;
  43. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  44. } else {
  45. if (RQ_VIP_Module.freeLookSimExamNum == 1) {
  46. 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];
  47. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
  48. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  49. webViewModel.prefersNavigationBarHidden = YES;
  50. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  51. RQ_VIP_Module.freeLookSimExamNum = 0;
  52. } else {
  53. [RQ_ALERTVIEW_MANAGER showAlertWithAlertType:RQAlertType_AD title:@"" message:@"" confirmTitle:@"充值会员无限使用" cancelTitle:@"看广告解锁使用" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  54. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  55. } cancelAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  56. [RQ_AD_Module loadRewardvodAd];
  57. }];
  58. }
  59. }
  60. }];
  61. };
  62. } else if ([self.title isEqualToString:@"新规秘卷"]) {
  63. self.operation = ^{
  64. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  65. if (isVip) {
  66. RQHoursBeforeExamHomeViewModel *hoursBeforeExamHomeViewModel = [[RQHoursBeforeExamHomeViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  67. [RQ_APPDELEGATE.services pushViewModel:hoursBeforeExamHomeViewModel animated:YES];
  68. } else {
  69. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  70. }
  71. }];
  72. };
  73. } else if ([self.title isEqualToString:@"专项练习"]) {
  74. self.operation = ^{
  75. RQSpecialPractiseViewModel *specialPractiseViewModel = [[RQSpecialPractiseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  76. [RQ_APPDELEGATE.services pushViewModel:specialPractiseViewModel animated:YES];
  77. };
  78. } else if ([self.title isEqualToString:@"精选500题"]) {
  79. self.operation = ^{
  80. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  81. if (isVip) {
  82. NSArray *arr = [[RQ_YDTQuestion_Module getQuestionWithSubject:RQ_YDTQuestion_Module.subject exerciseType:RQExerciseType_HandPick ].rac_sequence.signal map:^id _Nullable(RQYDTQuestionModel *ydtQuestionModel) {
  83. return [RQExerciseModel exerciseModelWithRQYDTQuestionModel:ydtQuestionModel];
  84. }].toArray;
  85. RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  86. RQHomePageCarTypeKey : @(RQ_YDTQuestion_Module.carType),
  87. RQHomePageSubjectTypeKey : @(RQ_YDTQuestion_Module.subject),
  88. RQHomeSubPageTypeKey : @(RQHomeSubPageType_SequentialPractice),
  89. RQViewModelIDKey : homePageOneOrFourItemModel.titleStr,
  90. RQExerciseTypeKey : @(RQExerciseType_HandPick),
  91. RQViewModelUtilKey : arr,
  92. }];
  93. [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
  94. } else {
  95. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  96. }
  97. }];
  98. };
  99. } else if ([self.title isEqualToString:@"错题收藏"]) {
  100. self.operation = ^{
  101. RQErrorAndCollectViewModel *errorAndCollectViewModel = [[RQErrorAndCollectViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  102. [RQ_APPDELEGATE.services pushViewModel:errorAndCollectViewModel animated:YES];
  103. };
  104. }
  105. }
  106. return self;
  107. }
  108. @end