NYHomePageOneBigCell.m 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. //
  2. // NYHomePageOneBigCell.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2024/11/22.
  6. // Copyright © 2024 JCZ. All rights reserved.
  7. //
  8. #import "NYHomePageOneBigCell.h"
  9. @interface NYHomePageOneBigCell ()
  10. @property (nonatomic, readwrite, strong) NYHomePageOneBigItemViewModel *viewModel;
  11. @property (weak, nonatomic) IBOutlet QMUIButton *btn_left_0;
  12. @property (weak, nonatomic) IBOutlet QMUIButton *btn_left_1;
  13. @property (weak, nonatomic) IBOutlet QMUIButton *btn_left_2;
  14. @property (weak, nonatomic) IBOutlet QMUIButton *btn_left_3;
  15. @property (weak, nonatomic) IBOutlet QMUIButton *btn_right_0;
  16. @property (weak, nonatomic) IBOutlet QMUIButton *btn_right_1;
  17. @property (weak, nonatomic) IBOutlet QMUIButton *btn_right_2;
  18. @property (weak, nonatomic) IBOutlet QMUIButton *btn_right_3;
  19. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *lay_blue_w;
  20. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *lay_blue_h;
  21. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *lay_green_w;
  22. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *lay_green_h;
  23. @property (weak, nonatomic) IBOutlet UILabel *blue_title_sx;
  24. @property (weak, nonatomic) IBOutlet UILabel *green_title_mnks;
  25. @end
  26. @implementation NYHomePageOneBigCell
  27. - (void)awakeFromNib {
  28. [super awakeFromNib];
  29. // Initialization code
  30. }
  31. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  32. static NSString *ID = @"NYHomePageOneBigCell";
  33. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  34. NYHomePageOneBigCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  35. if (!cell) cell = [self rq_viewFromXib];
  36. [cell setupUI];
  37. return cell;
  38. }
  39. - (void)setupUI {
  40. self.btn_left_0.imagePosition = QMUIButtonImagePositionTop;
  41. self.btn_left_1.imagePosition = QMUIButtonImagePositionTop;
  42. self.btn_left_2.imagePosition = QMUIButtonImagePositionTop;
  43. self.btn_left_3.imagePosition = QMUIButtonImagePositionTop;
  44. self.btn_right_0.imagePosition = QMUIButtonImagePositionTop;
  45. self.btn_right_1.imagePosition = QMUIButtonImagePositionTop;
  46. self.btn_right_2.imagePosition = QMUIButtonImagePositionTop;
  47. self.btn_right_3.imagePosition = QMUIButtonImagePositionTop;
  48. self.btn_left_0.titleEdgeInsets = UIEdgeInsetsMake(8, 0, 0, 0);
  49. self.btn_left_1.titleEdgeInsets = UIEdgeInsetsMake(8, 0, 0, 0);
  50. self.btn_left_2.titleEdgeInsets = UIEdgeInsetsMake(8, 0, 0, 0);
  51. self.btn_left_3.titleEdgeInsets = UIEdgeInsetsMake(8, 0, 0, 0);
  52. self.btn_right_0.titleEdgeInsets = UIEdgeInsetsMake(8, 0, 0, 0);
  53. self.btn_right_1.titleEdgeInsets = UIEdgeInsetsMake(8, 0, 0, 0);
  54. self.btn_right_2.titleEdgeInsets = UIEdgeInsetsMake(8, 0, 0, 0);
  55. self.btn_right_3.titleEdgeInsets = UIEdgeInsetsMake(8, 0, 0, 0);
  56. self.lay_blue_w.constant = RQ_FIT_HORIZONTAL(121);
  57. self.lay_blue_h.constant = RQ_FIT_HORIZONTAL(121);
  58. self.lay_green_w.constant = RQ_FIT_HORIZONTAL(121);
  59. self.lay_green_h.constant = RQ_FIT_HORIZONTAL(121);
  60. }
  61. - (void)bindViewModel:(NYHomePageOneBigItemViewModel *)viewModel {
  62. _viewModel = viewModel;
  63. RAC(self.blue_title_sx, attributedText) = [[RACObserve(viewModel, sxlxtStr) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  64. RAC(self.green_title_mnks, attributedText) = [[RACObserve(viewModel, mnksStr) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  65. }
  66. #pragma mark - action
  67. //顺序练习
  68. - (IBAction)btnSxlxActiondo:(UIButton *)sender {
  69. if (RQ_USER_MANAGER.isShouldLogin) {
  70. NSArray *arr = [[RQ_YDTQuestion_Module getQuestionWithSubject:RQ_YDTQuestion_Module.subject exerciseType:RQExerciseType_Sequential ].rac_sequence.signal map:^id _Nullable(RQYDTQuestionModel *ydtQuestionModel) {
  71. return [RQExerciseModel exerciseModelWithRQYDTQuestionModel:ydtQuestionModel];
  72. }].toArray;
  73. // NSArray *arr = (self.homePageSubjectType == RQHomePageSubjectType_SubjectFour)? fourArr.copy : oneArr.copy;
  74. // arr = [arr.rac_sequence.signal map:^id _Nullable(RQYDTQuestionModel *ydtQuestionModel) {
  75. // return [RQExerciseModel exerciseModelWithRQYDTQuestionModel:ydtQuestionModel];
  76. // }].toArray;
  77. RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  78. RQHomePageCarTypeKey : @(self.viewModel.homePageCarType),
  79. RQHomePageSubjectTypeKey : @(self.viewModel.homePageSubjectType),
  80. RQHomeSubPageTypeKey : @(RQHomeSubPageType_SequentialPractice),
  81. RQViewModelIDKey : self.viewModel.sxlxtStr,
  82. RQExerciseTypeKey : @(RQExerciseType_Sequential),
  83. RQViewModelUtilKey : arr,
  84. }];
  85. [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
  86. }
  87. }
  88. //模拟考试
  89. - (IBAction)btnMnksActiondo:(UIButton *)sender {
  90. if (RQ_USER_MANAGER.isShouldLogin) {
  91. RQSimulateExamViewModel *viewModel = [[RQSimulateExamViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{}];
  92. [RQ_APPDELEGATE.services pushViewModel:viewModel animated:YES];
  93. }
  94. }
  95. //VIP课程
  96. - (IBAction)btnVipAction:(UIButton *)sender {
  97. // NSString *dictType = @"vip_coach_package";
  98. // [MBProgressHUD rq_showProgressHUD:@"获取VIP套餐..."];
  99. // [[RQ_HTTP_Service getTypeWithDictType:dictType] subscribeNext:^(NSArray *typeModels) {
  100. // [MBProgressHUD rq_hideHUD];
  101. // NYLIVipCoachViewModel *livipCoachViewModel = [[NYLIVipCoachViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  102. // RQViewModelIDKey : @(RQVIPPageType_Full),
  103. // RQViewModelUtilKey : typeModels,
  104. // RQViewCommonValueKey : @(RQHomePageSubjectType_SubjectOne),
  105. // }];
  106. // [RQ_APPDELEGATE.services pushViewModel:livipCoachViewModel animated:YES];
  107. // } error:^(NSError * _Nullable error) {
  108. // [MBProgressHUD rq_hideHUD];
  109. // [MBProgressHUD rq_showErrorTips:error];
  110. // }];
  111. // return;
  112. [MBProgressHUD rq_showProgressHUD:@""];
  113. [[RQ_HTTP_Service getFiveTeachingList:@"1"] subscribeNext:^(NSArray *fiveModels) {
  114. [MBProgressHUD rq_hideHUD];
  115. RQPlaceVideoListModel *placeVideoListModel = [[RQPlaceVideoListModel alloc] init];
  116. placeVideoListModel.examName = @"科一专项精品课";
  117. placeVideoListModel.items = fiveModels;
  118. NSIndexPath *indexPath = [NSIndexPath indexPathWithIndex:0];
  119. NYLIVideoDetailViewModel *videoDetailViewModel = [[NYLIVideoDetailViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  120. RQViewModelUtilKey : placeVideoListModel,
  121. RQVideoItemIndexKey : @(0),
  122. RQVideoItemIndexPathKey : indexPath,
  123. RQHomePageSubjectTypeKey : @(self.viewModel.homePageSubjectType),
  124. }];
  125. [RQ_APPDELEGATE.services pushViewModel:videoDetailViewModel animated:YES];
  126. } error:^(NSError * _Nullable error) {
  127. [MBProgressHUD rq_hideHUD];
  128. [MBProgressHUD rq_showErrorTips:error];
  129. }];
  130. return;
  131. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  132. if (isVip) {
  133. [RQ_VIP_Module gotoVipCenter];
  134. } else {
  135. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  136. }
  137. }];
  138. }
  139. //真实考场
  140. - (IBAction)btnExaminationAction:(UIButton *)sender {
  141. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  142. if (isVip) {
  143. // username subject headimg gs 替换-> model
  144. if(RQ_COMMON_MANAGER.APP_SWITCH){//审核状态走web 页
  145. 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];
  146. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
  147. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  148. webViewModel.prefersNavigationBarHidden = YES;
  149. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  150. }else{
  151. //显示真实考场
  152. NYExaminationViewModel *examinationViewModel = [[NYExaminationViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{}];
  153. examinationViewModel.km = RQ_YDTQuestion_Module.subjectStr.intValue;
  154. [RQ_APPDELEGATE.services pushViewModel:examinationViewModel animated:YES];
  155. }
  156. } else {
  157. if (RQ_VIP_Module.freeLookSimExamNum == 1||
  158. RQ_COMMON_MANAGER.APP_SWITCH) {//审核状态不用看广告
  159. if(RQ_COMMON_MANAGER.APP_SWITCH){//审核状态走web 页
  160. 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];
  161. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
  162. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  163. webViewModel.prefersNavigationBarHidden = YES;
  164. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  165. }else{
  166. //显示真实考场
  167. NYExaminationViewModel *examinationViewModel = [[NYExaminationViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{}];
  168. examinationViewModel.km = RQ_YDTQuestion_Module.subjectStr.intValue;
  169. [RQ_APPDELEGATE.services pushViewModel:examinationViewModel animated:YES];
  170. }
  171. RQ_VIP_Module.freeLookSimExamNum = 0;
  172. } else {
  173. if(!RQ_COMMON_MANAGER.APP_SWITCH){
  174. [RQ_ALERTVIEW_MANAGER showAlertWithAlertType:RQAlertType_AD title:@"" message:@"" confirmTitle:@"充值会员无限使用" cancelTitle:@"看广告解锁使用" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  175. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  176. } cancelAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  177. [RQ_AD_Module loadRewardvodAd];
  178. }];
  179. }
  180. }
  181. }
  182. }];
  183. }
  184. //分阶段练习
  185. - (IBAction)btnCateLxAction:(UIButton *)sender {
  186. if (RQ_USER_MANAGER.isShouldLogin) {
  187. NYBlockExerciseViewModel *blockExerciseViewModel = [[NYBlockExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  188. RQHomePageSubjectTypeKey : @(self.viewModel.homePageSubjectType),
  189. }];
  190. [RQ_APPDELEGATE.services pushViewModel:blockExerciseViewModel animated:YES];
  191. }
  192. }
  193. //易错专项
  194. - (IBAction)btnFallibilityAction:(UIButton *)sender {
  195. if (RQ_USER_MANAGER.isShouldLogin) {
  196. // if(RQ_YDTQuestion_Module.carType != RQHomePageCarType_Car){
  197. // ShowMsg(@"只支持小车");
  198. // return;
  199. // }
  200. NYFailSpecialExerciseViewModel *failSpecialExerciseViewModel = [[NYFailSpecialExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  201. RQHomePageSubjectTypeKey : @(self.viewModel.homePageSubjectType),
  202. }];
  203. [RQ_APPDELEGATE.services pushViewModel:failSpecialExerciseViewModel animated:YES];
  204. }
  205. }
  206. //500精选
  207. - (IBAction)btnWBAction:(UIButton *)sender {
  208. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  209. if (isVip) {
  210. NSArray *arr = [[RQ_YDTQuestion_Module getQuestionWithSubject:RQ_YDTQuestion_Module.subject exerciseType:RQExerciseType_HandPick ].rac_sequence.signal map:^id _Nullable(RQYDTQuestionModel *ydtQuestionModel) {
  211. return [RQExerciseModel exerciseModelWithRQYDTQuestionModel:ydtQuestionModel];
  212. }].toArray;
  213. RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  214. RQHomePageCarTypeKey : @(RQ_YDTQuestion_Module.carType),
  215. RQHomePageSubjectTypeKey : @(RQ_YDTQuestion_Module.subject),
  216. RQHomeSubPageTypeKey : @(RQHomeSubPageType_SequentialPractice),
  217. RQViewModelIDKey : @"精选500题",
  218. RQExerciseTypeKey : @(RQExerciseType_HandPick),
  219. RQViewModelUtilKey : arr,
  220. }];
  221. [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
  222. } else {
  223. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  224. }
  225. }];
  226. }
  227. //专项练习
  228. - (IBAction)btnZxPracticeAction:(UIButton *)sender {
  229. if (RQ_USER_MANAGER.isShouldLogin) {
  230. RQSpecialPractiseViewModel *specialPractiseViewModel = [[RQSpecialPractiseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  231. [RQ_APPDELEGATE.services pushViewModel:specialPractiseViewModel animated:YES];
  232. }
  233. }
  234. //电子资料
  235. - (IBAction)btnCorpuscleresAction:(UIButton *)sender {
  236. NSLog(@"点击了-电子资料-%@",RQ_COMMON_MANAGER.JSJP_XCX_PAGE);
  237. if (RQ_USER_MANAGER.isShouldLogin) {
  238. [RQ_SHARE_FUNCTION miniwithUserName:RQ_COMMON_MANAGER.JSJP_XCX_NAME path:RQ_COMMON_MANAGER.JSJP_XCX_PAGE];
  239. }
  240. }
  241. //错题收藏
  242. - (IBAction)btnErrorCollectAction:(UIButton *)sender {
  243. if (RQ_USER_MANAGER.isShouldLogin) {
  244. RQErrorAndCollectViewModel *errorAndCollectViewModel = [[RQErrorAndCollectViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  245. [RQ_APPDELEGATE.services pushViewModel:errorAndCollectViewModel animated:YES];
  246. }
  247. }
  248. @end