// // RQVipCenterSubListViewModel.m // jiaPei // // Created by 张嵘 on 2022/9/22. // Copyright © 2022 JCZ. All rights reserved. // #import "RQVipCenterSubListViewModel.h" @interface RQVipCenterSubListViewModel () @property (nonatomic, readwrite, assign) RQHomePageSubjectType homePageSubjectType; @end @implementation RQVipCenterSubListViewModel #pragma mark - Public Method - (instancetype)initWithServices:(id)services params:(NSDictionary *)params { if (self = [super initWithServices:services params:params]) { self.homePageSubjectType = [params[RQHomePageSubjectTypeKey] integerValue]; } return self; } - (void)initialize { [super initialize]; self.title = @"会员中心"; [[RQ_HTTP_Service getVideoVipWithUserId:RQ_USER_MANAGER.currentUser._id] subscribeNext:^(RQVideoVipModel *videoVipModel) { // videoVipModel.subject1 = @"1"; // videoVipModel.subject2 = @""; // videoVipModel.subject3 = @""; // videoVipModel.subject4 = @"1"; RQ_VIP_Module.videoVipModel = videoVipModel; }]; [RQ_VIP_Module isVipWithSubject:0 complete:^(BOOL isVip) { }]; [RQ_VIP_Module isActiveWithCcomplete:^(RQActivationModel * _Nullable activationModel, BOOL isSuccess) {}]; ///配置数据 [self rq_configureData]; } #pragma mark - PrivateMethod - (void)rq_configureData { @weakify(self) /// 数据源 RAC(self,dataSource) = [RACSignal combineLatest:@[RACObserve(RQ_VIP_Module, videoVipModel),RACObserve(RQ_VIP_Module, chooseTypeModel)] reduce:^(RQVideoVipModel *videoVipModel, RQTypeModel *chooseTypeModel) { @strongify(self) /// 第零组 会员期限与购买 RQCommonGroupViewModel *group0 = [RQCommonGroupViewModel groupViewModel]; RQVipTimeItemViewModel *vipTimeItemViewModel = [[RQVipTimeItemViewModel alloc] initVideoVipModel:videoVipModel homePageSubjectType:self.homePageSubjectType]; if(self.homePageSubjectType==RQHomePageSubjectType_SubjectOne_LI-1|| self.homePageSubjectType==RQHomePageSubjectType_SubjectFour_LI-1){ NYLIVipTipsItemViewModel *vipTipsItemViewModel = [[NYLIVipTipsItemViewModel alloc] initVideoVipModel:videoVipModel homePageSubjectType:self.homePageSubjectType]; group0.itemViewModels = @[vipTipsItemViewModel,vipTimeItemViewModel]; }else{ group0.itemViewModels = @[vipTimeItemViewModel]; } /// 第一组 怎么学 RQCommonGroupViewModel *group1 = [RQCommonGroupViewModel groupViewModel]; RQVipContentItemViewModel *vipContentItemViewModel = [[RQVipContentItemViewModel alloc] initWithRQTypeModel:chooseTypeModel]; vipContentItemViewModel.isCenter = YES; vipContentItemViewModel.homePageSubjectType = self.homePageSubjectType; if(self.homePageSubjectType==RQHomePageSubjectType_SubjectOne_LI-1|| self.homePageSubjectType==RQHomePageSubjectType_SubjectFour_LI-1){ NYLIVipContentItemViewModel *model01 = [[NYLIVipContentItemViewModel alloc] initWithRQTypeModel:chooseTypeModel type:0]; model01.isCenter = YES; model01.homePageSubjectType = self.homePageSubjectType; NYLIVipContentItemViewModel *model02 = [[NYLIVipContentItemViewModel alloc] initWithRQTypeModel:chooseTypeModel type:1]; model02.isCenter = YES; model02.homePageSubjectType = self.homePageSubjectType; NYLIVipContentItemViewModel *model03 = [[NYLIVipContentItemViewModel alloc] initWithRQTypeModel:chooseTypeModel type:2]; model03.isCenter = YES; model03.homePageSubjectType = self.homePageSubjectType; NYLIVipContentItemViewModel *model04 = [[NYLIVipContentItemViewModel alloc] initWithRQTypeModel:chooseTypeModel type:3]; model04.isCenter = YES; model04.homePageSubjectType = self.homePageSubjectType; NYLIVipContentItem03ViewModel *model05 = [[NYLIVipContentItem03ViewModel alloc] initWithRQTypeModel:chooseTypeModel]; model05.homePageSubjectType = self.homePageSubjectType; group1.itemViewModels = @[model01,model02,model03,model04,model05]; }else{ group1.itemViewModels = @[vipContentItemViewModel]; } /// 第二组 尊享4大权益 RQCommonGroupViewModel *group2 = [RQCommonGroupViewModel groupViewModel]; RQVipAuthorityItemViewModel *vipAuthorityItemViewModel = [[RQVipAuthorityItemViewModel alloc] initWithRQTypeModel:chooseTypeModel]; vipAuthorityItemViewModel.isCenter = YES; vipAuthorityItemViewModel.homePageSubjectType = self.homePageSubjectType; group2.itemViewModels = @[vipAuthorityItemViewModel]; if(self.homePageSubjectType==RQHomePageSubjectType_SubjectOne_LI-1|| self.homePageSubjectType==RQHomePageSubjectType_SubjectFour_LI-1){ return @[group0, group1]; } return (self.homePageSubjectType == RQHomePageSubjectType_SubjectOne || self.homePageSubjectType == RQHomePageSubjectType_SubjectFour)? @[group0, group1, group2] : @[group0, group2]; }]; } @end