MSYOUPAIViewModel.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // MSYOUPAIViewModel.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/3/2.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "MSYOUPAIViewModel.h"
  9. @interface MSYOUPAIViewModel ()
  10. /// 前往个人主页
  11. @property (nonatomic, strong, readwrite) RACSubject *gotoPersonalPageSubject;
  12. @end
  13. @implementation MSYOUPAIViewModel
  14. - (void)ym_initialize{
  15. [super ym_initialize];
  16. @weakify(self)
  17. [[self.gotoPersonalPageSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable value) {
  18. @strongify(self)
  19. if ([value intValue] != 0) {
  20. YMPersonalPageViewModel *personalPageVM = [[YMPersonalPageViewModel alloc]initWithParams:@{
  21. ParamsId:@([value intValue])
  22. }];
  23. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_PERSONAL_PAGE) withUserInfo:@{
  24. RouterViewModel:personalPageVM
  25. } completion:nil];
  26. }
  27. }];
  28. }
  29. /// 当前用户Id
  30. - (NSInteger)currentUserId{
  31. NSInteger userId = [[OCUserDefaults objectForKey:kUSER_ID] intValue];
  32. return userId;
  33. }
  34. - (BOOL)isFemaleGender{
  35. BOOL isFemaleGender = [OCUserDefaults boolForKey:kIS_FEMALE_GENDER];
  36. if (isFemaleGender) {
  37. return YES;
  38. } else {
  39. return NO;
  40. }
  41. }
  42. - (BOOL)isNeedGoddessCertified{
  43. BOOL isGoddessCertified = [OCUserDefaults boolForKey:kIS_GODDESS_CERTIFIED];
  44. if ([self isFemaleGender] && !isGoddessCertified) {
  45. YMTipsPopupView *customView = [[YMTipsPopupView alloc]init];
  46. customView.titleText = @"真人认证";
  47. customView.cancelTitle = @"暂不认证";
  48. customView.confirmTitle = @"去认证";
  49. [customView configutationWithTips:stringFormat(@"%@提倡真实交友,通过【真人认证】后才可以心动交友哦~",[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]) TipsAlignment:NSTextAlignmentLeft IsHideTitle:NO IsHideSingleButton:YES];
  50. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleFade dismissStyle:YMDismissStyleFade];
  51. popupView.priority = 999;
  52. popupView.cornerRadius = adapt(10);
  53. popupView.rectCorners = UIRectCornerAllCorners;
  54. popupView.positionStyle = YMPositionStyleCenter;
  55. popupView.isHideBg = NO;
  56. popupView.bgAlpha = 0.3;
  57. @weakify(popupView)
  58. customView.buttonBlock = ^(BOOL isConfirm) {
  59. @strongify(popupView)
  60. if (isConfirm) {
  61. YMGoddessCertifiedProtocolViewModel *goddessCertifiedProtocolVM = [[YMGoddessCertifiedProtocolViewModel alloc]initWithParams:@{}];
  62. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_GODDESS_CERTIFIED_PROTOCOL) withUserInfo:@{
  63. RouterViewModel:goddessCertifiedProtocolVM
  64. } completion:nil];
  65. }
  66. [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
  67. };
  68. [popupView pop];
  69. return YES;
  70. }else{
  71. return NO;
  72. }
  73. }
  74. - (BOOL)isNeedPurchaseMember{
  75. BOOL isVIP = [OCUserDefaults boolForKey:kIS_VIP];
  76. if (!isVIP) {
  77. YMMemberCenterViewModel *memberCenterVM = [[YMMemberCenterViewModel alloc]initWithParams:@{}];
  78. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_MEMBER_CENTER) withUserInfo:@{
  79. RouterViewModel:memberCenterVM
  80. } completion:nil];
  81. return YES;
  82. }else{
  83. return NO;
  84. }
  85. }
  86. - (RACSubject *)gotoPersonalPageSubject{
  87. if (!_gotoPersonalPageSubject) {
  88. _gotoPersonalPageSubject = [RACSubject subject];
  89. }
  90. return _gotoPersonalPageSubject;
  91. }
  92. @end