RQHoursBeforeExamHomeViewModel.m 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // RQHoursBeforeExamHomeViewModel.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/6/21.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQHoursBeforeExamHomeViewModel.h"
  9. @interface RQHoursBeforeExamHomeViewModel ()
  10. /// 秘卷一
  11. @property (nonatomic, readwrite, copy) NSArray *itemsOne;
  12. /// 秘卷二
  13. @property (nonatomic, readwrite, copy) NSArray *itemsTwo;
  14. @property (nonatomic, readwrite, assign) NSInteger hudDisMissCount;
  15. @end
  16. @implementation RQHoursBeforeExamHomeViewModel
  17. #pragma mark - Public Method
  18. - (instancetype)initWithServices:(id<RQViewModelServices>)services params:(NSDictionary *)params {
  19. if (self = [super initWithServices:services params:params]) {
  20. }
  21. return self;
  22. }
  23. - (void)initialize {
  24. [super initialize];
  25. self.title = @"考前秘卷";
  26. /// 隐藏导航栏的细线
  27. self.prefersNavigationBarBottomLineHidden = YES;
  28. self.prefersNavigationBarHidden = YES;
  29. self.hudDisMissCount = 0;
  30. ///配置数据
  31. // [self rq_configureData];
  32. }
  33. #pragma mark - PrivateMethod
  34. - (void)rq_configureData {
  35. @weakify(self);
  36. NSString *gs = [RQ_COMMON_MANAGER getCarTypeSimpleCNStrWithCarType:RQ_COMMON_MANAGER.carType];
  37. NSString *km = [RQ_COMMON_MANAGER getSubjectTypeNumStrWithSubjectType:RQ_COMMON_MANAGER.subject];
  38. [MBProgressHUD rq_showProgressHUD:@"获取秘卷..."];
  39. [[[RQ_HTTP_Service getSelectMiQuestionInfoListWithCategory:RQMiQuestionType_One gs:gs kemu:km] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSArray *itemArr) {
  40. @strongify(self)
  41. self.itemsOne = itemArr;
  42. self.hudDisMissCount ++;
  43. } error:^(NSError * _Nullable error) {
  44. @strongify(self)
  45. self.hudDisMissCount ++;
  46. }];
  47. [[[RQ_HTTP_Service getSelectMiQuestionInfoListWithCategory:RQMiQuestionType_Two gs:gs kemu:km] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSArray *itemArr) {
  48. @strongify(self)
  49. self.itemsTwo = itemArr;
  50. self.hudDisMissCount ++;
  51. } error:^(NSError * _Nullable error) {
  52. @strongify(self)
  53. self.hudDisMissCount ++;
  54. }];
  55. [RACObserve(self, hudDisMissCount) subscribeNext:^(id _Nullable x) {
  56. if (self.hudDisMissCount >= 2) {
  57. [MBProgressHUD rq_hideHUD];
  58. }
  59. }];
  60. }
  61. @end