UIViewController+VQ_PageControl.m 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. //
  2. // pageControl.m
  3. // XLChat
  4. //
  5. // Created by 张灿 on 2017/11/13.
  6. // Copyright © 2017年 张灿. All rights reserved.
  7. //
  8. #import "UIViewController+VQ_PageControl.h"
  9. #import "YOUPAILCVerifyBigCastVC.h"
  10. #import "YOUPAILCCameraAuditVC.h"
  11. #import "YOUPAILCWeixinVC.h"
  12. #import "YOUPAILZVipVC.h"
  13. #import "YOUPAILZGameAccompanyListVC.h"
  14. #import "YOUPAILCBoardVC.h"
  15. #import "YOUPAIXRWalletVC.h"
  16. #import "MSYMineinfoEditVC.h"
  17. #import "YOUPAILCBindPhoneAccountVC.h"
  18. #import "UIViewController+TFPresent.h"
  19. static const char *PresentedVCsKey = "PresentedVCsKey";
  20. @implementation UIViewController (PageControl)
  21. + (void)exchangeInstanceMethod1:(SEL)method1 method2:(SEL)method2{
  22. method_exchangeImplementations(class_getInstanceMethod(self, method1), class_getInstanceMethod(self, method2));
  23. }
  24. + (void)load{
  25. [self exchangeInstanceMethod1:@selector(viewDidAppear:) method2:@selector(lz_viewDidAppear:)];
  26. }
  27. -(void)lz_viewDidAppear:(BOOL)animated{
  28. [self lz_viewDidAppear:animated];
  29. if (self.presentedVCs.count != 0) {
  30. [self showWindowWithFormController:self toController:self.presentedVCs[0]];
  31. }
  32. }
  33. - (void)showWindowWithFormController:(UIViewController *)formvc toController:(UIViewController *)tovc{
  34. [formvc TFPresentVC:tovc completion:^{
  35. NSInteger index = [self.presentedVCs indexOfObject:tovc];
  36. if (index != self.presentedVCs.count - 1) {
  37. [self showWindowWithFormController:tovc toController:self.presentedVCs[index + 1]];
  38. }else{
  39. [self.presentedVCs removeAllObjects];
  40. }
  41. }];
  42. }
  43. - (void)youpaifpageToStr:(NSString*)str{
  44. if ([str isEqualToString:@"inviteDetail"]) {
  45. }
  46. else if([str containsString:@"wexinPublic"])
  47. {
  48. YOUPAILCWeixinVC* invite = [[YOUPAILCWeixinVC alloc]init];
  49. [self.navigationController pushViewController:invite animated:YES];
  50. }
  51. else if([str isEqualToString:@"member"])
  52. {
  53. // if([LCSaveModel getUserModel].userinfo.gender==2)
  54. // {
  55. // YOUPAILZVipVC* invite = [[YOUPAILZVipVC alloc]init];
  56. // [self.navigationController pushViewController:invite animated:YES];
  57. YMMemberCenterViewModel *memberCenterVM = [[YMMemberCenterViewModel alloc]initWithParams:@{}];
  58. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_MEMBER_CENTER) withUserInfo:@{
  59. RouterViewModel:memberCenterVM
  60. } completion:nil];
  61. // }
  62. }else if ([str isEqualToString:@"rank"]){
  63. YMRankingViewModel *rankingVM = [[YMRankingViewModel alloc]initWithParams:@{}];
  64. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_RANKING) withUserInfo:@{
  65. RouterViewModel:rankingVM
  66. } completion:nil];
  67. }
  68. else if ([str isEqualToString:@"help"]){
  69. NSString *urlStr;
  70. if ([LCSaveModel getUserModel].youpaipuserinfo.youpaipgender==1) {
  71. urlStr = [NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,HelpBigCastH5];
  72. }else{
  73. urlStr = [NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,HelpNormalH5];
  74. }
  75. if([LCSaveData getIsspecial]){
  76. urlStr = [NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,HelpSpecialH5];
  77. }
  78. ZCBaseWebVC * vc = [[ZCBaseWebVC alloc]init];
  79. vc.contentUrl = urlStr;
  80. [self.navigationController pushViewController:vc animated:YES];
  81. }else if ([str isEqualToString:@"rechargeMoney"]){
  82. // YOUPAIXRWalletVC* moneyRecharge = [[YOUPAIXRWalletVC alloc]init];
  83. // [self.navigationController pushViewController:moneyRecharge animated:YES];
  84. YMAccountBalanceViewModel *accountBalanceVM = [[YMAccountBalanceViewModel alloc]initWithParams:@{
  85. ParamsId:@([[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id intValue])
  86. }];
  87. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_ACCOUNT_BALANCE) withUserInfo:@{
  88. RouterViewModel:accountBalanceVM
  89. } completion:nil];
  90. }else if([str isEqualToString:@"rechargeCoin"]){
  91. // YOUPAIXRWalletVC* coinRecharge = [[YOUPAIXRWalletVC alloc]init];
  92. // [self.navigationController pushViewController:coinRecharge animated:YES];
  93. YMAccountBalanceViewModel *accountBalanceVM = [[YMAccountBalanceViewModel alloc]initWithParams:@{
  94. ParamsId:@([[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id intValue])
  95. }];
  96. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_ACCOUNT_BALANCE) withUserInfo:@{
  97. RouterViewModel:accountBalanceVM
  98. } completion:nil];
  99. }else if ([str isEqualToString:@"applyBigCast"]){
  100. if ([LCSaveModel getUserModel].youpaipuserinfo.youpaipis_anchor ==0) {
  101. YOUPAILCVerifyBigCastVC* verBigCast = [[YOUPAILCVerifyBigCastVC alloc]init];
  102. [self.navigationController pushViewController:verBigCast animated:YES];
  103. }
  104. }else if ([str isEqualToString:@"auditCamera"]){
  105. YOUPAILCCameraAuditVC* audit = [[YOUPAILCCameraAuditVC alloc]init];
  106. [self.navigationController pushViewController:audit animated:YES];
  107. }else if([str isEqualToString:@"gameOrderList"]){
  108. YOUPAILZGameAccompanyListVC *vc = [[YOUPAILZGameAccompanyListVC alloc] init];
  109. [self.navigationController pushViewController:vc animated:YES];
  110. }else if([str isEqualToString:@"infoEdit"]){
  111. MSYMineinfoEditVC * editvc = [MSYMineinfoEditVC new];
  112. [self.navigationController pushViewController:editvc animated:true];
  113. }else if([str isEqualToString:@"bindPhone"]){
  114. YOUPAILCBindPhoneAccountVC* bindAccount = [[YOUPAILCBindPhoneAccountVC alloc]init];
  115. [self.navigationController pushViewController:bindAccount animated:YES];
  116. }else if([str isEqualToString:@"auth"]){
  117. [LCTools goRealNamePage];
  118. }else if([str isEqualToString:@"main"]){
  119. [[NSNotificationCenter defaultCenter] postNotificationName:@"LeaveLive" object:nil userInfo:nil];
  120. [self.tabBarController setSelectedIndex:0];
  121. [self.tabBarController.navigationController popToRootViewControllerAnimated:YES];
  122. [self.navigationController popToRootViewControllerAnimated:YES];
  123. }else if([str isEqualToString:@"dynamic"]){
  124. [self.tabBarController setSelectedIndex:1];
  125. [self.tabBarController.navigationController popToRootViewControllerAnimated:YES];
  126. [self.navigationController popToRootViewControllerAnimated:YES];
  127. }else if([str isEqualToString:@"msg"]){
  128. [self.tabBarController setSelectedIndex:2];
  129. [self.tabBarController.navigationController popToRootViewControllerAnimated:YES];
  130. [self.navigationController popToRootViewControllerAnimated:YES];
  131. }else if([str isEqualToString:@"my"]){
  132. [self.tabBarController setSelectedIndex:3];
  133. [self.tabBarController.navigationController popToRootViewControllerAnimated:YES];
  134. [self.navigationController popToRootViewControllerAnimated:YES];
  135. }
  136. if (self.navigationController != nil) {
  137. self.presentedVCs = [NSMutableArray array];
  138. UIViewController *vc = self;
  139. while (0 == 0) {
  140. if (vc.presentedViewController != nil) {
  141. [self.presentedVCs addObject:vc.presentedViewController];
  142. vc = vc.presentedViewController;
  143. }else{
  144. break;
  145. }
  146. }
  147. [self dismissViewControllerAnimated:NO completion:^{}];
  148. }
  149. }
  150. - (NSMutableArray<UIViewController *> *)presentedVCs{
  151. return objc_getAssociatedObject(self, PresentedVCsKey);
  152. }
  153. - (void)setPresentedVCs:(NSMutableArray<UIViewController *> *)presentedVCs{
  154. objc_setAssociatedObject(self, PresentedVCsKey, presentedVCs, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
  155. }
  156. @end