NYGetjobTimeViewModel.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // NYGetjobTimeViewModel.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2023/6/9.
  6. // Copyright © 2023 JCZ. All rights reserved.
  7. //
  8. #import "NYGetjobTimeViewModel.h"
  9. #import "NYTimeRuleItemViewModel.h"
  10. #import "NYGetjobStartRuleViewModel.h"
  11. @interface NYGetjobTimeViewModel ()
  12. @end
  13. @implementation NYGetjobTimeViewModel
  14. #pragma mark - Public Method
  15. - (instancetype)initWithServices:(id<RQViewModelServices>)services params:(NSDictionary *)params {
  16. if (self = [super initWithServices:services params:params]) {
  17. }
  18. return self;
  19. }
  20. - (void)initialize {
  21. [super initialize];
  22. self.title = @"从业资格计时";
  23. //ning(无奈) 判断-是否是 辽宁-并且当前是科目一时,台州加的3310 温州3303
  24. NSString *citystr = @"yntms,2101,2108,3310,3303";
  25. if ([citystr rangeOfString:RQ_USER_MANAGER.currentUser.city].location != NSNotFound) {
  26. self.title = @"理论计时(科一)";
  27. }
  28. ///配置数据
  29. [self rq_configureData];
  30. //注册通知
  31. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(runChangeTitle:) name:NYGetJobtimeChangeTitleNotification object:nil];
  32. }
  33. - (void)runChangeTitle:(NSNotification *)notification{
  34. self.title = [notification.object stringValue];
  35. }
  36. - (void)setNavTitle:(NSString*)title{
  37. self.title = title;
  38. }
  39. #pragma mark - ConfigureData
  40. - (void)rq_configureData {
  41. // @weakify(self)
  42. /// 数据源
  43. RAC(self, dataSource) = [RACSignal
  44. combineLatest:@[RACObserve(RQ_USER_MANAGER, isCykh)]
  45. reduce:^(NSNumber *isCykh) {
  46. // @strongify(self)
  47. RQCommonGroupViewModel *group0 = [RQCommonGroupViewModel groupViewModel];
  48. RQTimeADItemViewModel *timeADItemViewModel = [[RQTimeADItemViewModel alloc] init];
  49. group0.itemViewModels = @[timeADItemViewModel];
  50. RQCommonGroupViewModel *group1 = [RQCommonGroupViewModel groupViewModel];
  51. NYGetjobStartRuleViewModel *timeStartRuleViewModel = [[NYGetjobStartRuleViewModel alloc] init];
  52. group1.itemViewModels = @[timeStartRuleViewModel];
  53. RQCommonGroupViewModel *group2 = [RQCommonGroupViewModel groupViewModel];
  54. NYTimeRuleItemViewModel *timeRuleItemViewModel = [[NYTimeRuleItemViewModel alloc] init];
  55. timeRuleItemViewModel.isCykh = isCykh;
  56. group2.itemViewModels = @[timeRuleItemViewModel];
  57. return @[group0, group1, group2];
  58. }];
  59. }
  60. - (void)dealloc{
  61. [[NSNotificationCenter defaultCenter] removeObserver:self];
  62. }
  63. @end