RQVipCenterSubListViewModel.m 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // RQVipCenterSubListViewModel.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/9/22.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQVipCenterSubListViewModel.h"
  9. @interface RQVipCenterSubListViewModel ()
  10. @property (nonatomic, readwrite, assign) RQHomePageSubjectType homePageSubjectType;
  11. @end
  12. @implementation RQVipCenterSubListViewModel
  13. #pragma mark - Public Method
  14. - (instancetype)initWithServices:(id<RQViewModelServices>)services params:(NSDictionary *)params {
  15. if (self = [super initWithServices:services params:params]) {
  16. self.homePageSubjectType = [params[RQHomePageSubjectTypeKey] integerValue];
  17. }
  18. return self;
  19. }
  20. - (void)initialize {
  21. [super initialize];
  22. self.title = @"会员中心";
  23. [[RQ_HTTP_Service getVideoVipWithUserId:RQ_USER_MANAGER.currentUser._id] subscribeNext:^(RQVideoVipModel *videoVipModel) {
  24. // videoVipModel.subject1 = @"1";
  25. // videoVipModel.subject2 = @"";
  26. // videoVipModel.subject3 = @"";
  27. // videoVipModel.subject4 = @"1";
  28. RQ_VIP_Module.videoVipModel = videoVipModel;
  29. }];
  30. [RQ_VIP_Module isVipWithSubject:0 complete:^(BOOL isVip) {
  31. }];
  32. [RQ_VIP_Module isActiveWithCcomplete:^(RQActivationModel * _Nullable activationModel, BOOL isSuccess) {}];
  33. ///配置数据
  34. [self rq_configureData];
  35. }
  36. #pragma mark - PrivateMethod
  37. - (void)rq_configureData {
  38. @weakify(self)
  39. /// 数据源
  40. RAC(self,dataSource) = [RACSignal
  41. combineLatest:@[RACObserve(RQ_VIP_Module, videoVipModel),RACObserve(RQ_VIP_Module, chooseTypeModel)]
  42. reduce:^(RQVideoVipModel *videoVipModel, RQTypeModel *chooseTypeModel) {
  43. @strongify(self)
  44. /// 第零组 会员期限与购买
  45. RQCommonGroupViewModel *group0 = [RQCommonGroupViewModel groupViewModel];
  46. RQVipTimeItemViewModel *vipTimeItemViewModel = [[RQVipTimeItemViewModel alloc] initVideoVipModel:videoVipModel homePageSubjectType:self.homePageSubjectType];
  47. if(self.homePageSubjectType==RQHomePageSubjectType_SubjectOne_LI-1||
  48. self.homePageSubjectType==RQHomePageSubjectType_SubjectFour_LI-1){
  49. NYLIVipTipsItemViewModel *vipTipsItemViewModel = [[NYLIVipTipsItemViewModel alloc] initVideoVipModel:videoVipModel homePageSubjectType:self.homePageSubjectType];
  50. group0.itemViewModels = @[vipTipsItemViewModel,vipTimeItemViewModel];
  51. }else{
  52. group0.itemViewModels = @[vipTimeItemViewModel];
  53. }
  54. /// 第一组 怎么学
  55. RQCommonGroupViewModel *group1 = [RQCommonGroupViewModel groupViewModel];
  56. RQVipContentItemViewModel *vipContentItemViewModel = [[RQVipContentItemViewModel alloc] initWithRQTypeModel:chooseTypeModel];
  57. vipContentItemViewModel.isCenter = YES;
  58. vipContentItemViewModel.homePageSubjectType = self.homePageSubjectType;
  59. if(self.homePageSubjectType==RQHomePageSubjectType_SubjectOne_LI-1||
  60. self.homePageSubjectType==RQHomePageSubjectType_SubjectFour_LI-1){
  61. NYLIVipContentItemViewModel *model01 = [[NYLIVipContentItemViewModel alloc] initWithRQTypeModel:chooseTypeModel type:0];
  62. model01.isCenter = YES;
  63. model01.homePageSubjectType = self.homePageSubjectType;
  64. NYLIVipContentItemViewModel *model02 = [[NYLIVipContentItemViewModel alloc] initWithRQTypeModel:chooseTypeModel type:1];
  65. model02.isCenter = YES;
  66. model02.homePageSubjectType = self.homePageSubjectType;
  67. NYLIVipContentItemViewModel *model03 = [[NYLIVipContentItemViewModel alloc] initWithRQTypeModel:chooseTypeModel type:2];
  68. model03.isCenter = YES;
  69. model03.homePageSubjectType = self.homePageSubjectType;
  70. NYLIVipContentItemViewModel *model04 = [[NYLIVipContentItemViewModel alloc] initWithRQTypeModel:chooseTypeModel type:3];
  71. model04.isCenter = YES;
  72. model04.homePageSubjectType = self.homePageSubjectType;
  73. NYLIVipContentItem03ViewModel *model05 = [[NYLIVipContentItem03ViewModel alloc] initWithRQTypeModel:chooseTypeModel];
  74. model05.homePageSubjectType = self.homePageSubjectType;
  75. group1.itemViewModels = @[model01,model02,model03,model04,model05];
  76. }else{
  77. group1.itemViewModels = @[vipContentItemViewModel];
  78. }
  79. /// 第二组 尊享4大权益
  80. RQCommonGroupViewModel *group2 = [RQCommonGroupViewModel groupViewModel];
  81. RQVipAuthorityItemViewModel *vipAuthorityItemViewModel = [[RQVipAuthorityItemViewModel alloc] initWithRQTypeModel:chooseTypeModel];
  82. vipAuthorityItemViewModel.isCenter = YES;
  83. vipAuthorityItemViewModel.homePageSubjectType = self.homePageSubjectType;
  84. group2.itemViewModels = @[vipAuthorityItemViewModel];
  85. if(self.homePageSubjectType==RQHomePageSubjectType_SubjectOne_LI-1||
  86. self.homePageSubjectType==RQHomePageSubjectType_SubjectFour_LI-1){
  87. return @[group0, group1];
  88. }
  89. return (self.homePageSubjectType == RQHomePageSubjectType_SubjectOne || self.homePageSubjectType == RQHomePageSubjectType_SubjectFour)? @[group0, group1, group2] : @[group0, group2];
  90. }];
  91. }
  92. @end