RQVipCenterViewModel.m 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // RQVipCenterViewModel.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/8/5.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQVipCenterViewModel.h"
  9. @interface RQVipCenterViewModel ()
  10. @property (nonatomic, readwrite, copy) NSArray *typeModels;
  11. @property (nonatomic, readwrite, assign) RQHomePageSubjectType homePageSubjectType;
  12. @end
  13. @implementation RQVipCenterViewModel
  14. #pragma mark - Public Method
  15. - (instancetype)initWithServices:(id<RQViewModelServices>)services params:(NSDictionary *)params {
  16. if (self = [super initWithServices:services params:params]) {
  17. self.typeModels = params[RQViewModelUtilKey];
  18. self.homePageSubjectType = [params[RQViewCommonValueKey] integerValue];
  19. }
  20. return self;
  21. }
  22. - (void)initialize {
  23. [super initialize];
  24. self.title = @"会员中心";
  25. ///配置数据
  26. [self rq_configureData];
  27. }
  28. // 请求数据
  29. - (RACSignal *)requestRemoteDataSignalWithPage:(NSUInteger)page {
  30. [MBProgressHUD rq_showProgressHUD:@"获取会员套餐..."];
  31. NSArray * (^typeModelsBlock)(NSArray *) = ^(NSArray *products) {
  32. [MBProgressHUD rq_hideHUD];
  33. if (page == 1) {
  34. /// 下拉刷新
  35. } else {
  36. /// 上拉加载
  37. products = @[(self.typeModels ?: @[]).rac_sequence, products.rac_sequence].rac_sequence.flatten.array;
  38. }
  39. return products;
  40. };
  41. return [[[self.services.client getTypeWithDictType:(!RQObjectIsNil(RQ_VIP_Module.activationModel) && RQ_VIP_Module.activationModel.isShare && !(RQ_VIP_Module.activationModel.isActive == 1))? RQ_USER_MANAGER.currentUser.city : @"vip_package"] map:typeModelsBlock] doError:^(NSError * _Nonnull error) {
  42. [MBProgressHUD rq_hideHUD];
  43. [MBProgressHUD rq_showErrorTips:error];
  44. }];
  45. }
  46. #pragma mark - PrivateMethod
  47. - (void)rq_configureData {
  48. }
  49. @end