UIViewController+VQ_PageControl.m 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. NSLog(@"点击了此处====:%@",str);
  45. if ([str isEqualToString:@"inviteDetail"]) {
  46. }
  47. else if([str containsString:@"wexinPublic"])
  48. {
  49. YOUPAILCWeixinVC* invite = [[YOUPAILCWeixinVC alloc]init];
  50. [self.navigationController pushViewController:invite animated:YES];
  51. }
  52. else if([str isEqualToString:@"member"])
  53. {
  54. // if([LCSaveModel getUserModel].userinfo.gender==2)
  55. // {
  56. // YOUPAILZVipVC* invite = [[YOUPAILZVipVC alloc]init];
  57. // [self.navigationController pushViewController:invite animated:YES];
  58. YMMemberCenterViewModel *memberCenterVM = [[YMMemberCenterViewModel alloc]initWithParams:@{}];
  59. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_MEMBER_CENTER) withUserInfo:@{
  60. RouterViewModel:memberCenterVM
  61. } completion:nil];
  62. // }
  63. }else if ([str isEqualToString:@"rank"]){
  64. YMRankingViewModel *rankingVM = [[YMRankingViewModel alloc]initWithParams:@{}];
  65. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_RANKING) withUserInfo:@{
  66. RouterViewModel:rankingVM
  67. } completion:nil];
  68. }
  69. else if ([str isEqualToString:@"help"]){
  70. NSString *urlStr;
  71. if ([LCSaveModel getUserModel].youpaipuserinfo.youpaipgender==1) {
  72. urlStr = [NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,HelpBigCastH5];
  73. }else{
  74. urlStr = [NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,HelpNormalH5];
  75. }
  76. if([LCSaveData getIsspecial]){
  77. urlStr = [NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,HelpSpecialH5];
  78. }
  79. ZCBaseWebVC * vc = [[ZCBaseWebVC alloc]init];
  80. vc.contentUrl = urlStr;
  81. [self.navigationController pushViewController:vc animated:YES];
  82. }else if ([str isEqualToString:@"rechargeMoney"]){
  83. // YOUPAIXRWalletVC* moneyRecharge = [[YOUPAIXRWalletVC alloc]init];
  84. // [self.navigationController pushViewController:moneyRecharge animated:YES];
  85. YMAccountBalanceViewModel *accountBalanceVM = [[YMAccountBalanceViewModel alloc]initWithParams:@{
  86. ParamsId:@([[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id intValue])
  87. }];
  88. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_ACCOUNT_BALANCE) withUserInfo:@{
  89. RouterViewModel:accountBalanceVM
  90. } completion:nil];
  91. }else if([str isEqualToString:@"rechargeCoin"]){
  92. // YOUPAIXRWalletVC* coinRecharge = [[YOUPAIXRWalletVC alloc]init];
  93. // [self.navigationController pushViewController:coinRecharge animated:YES];
  94. YMAccountBalanceViewModel *accountBalanceVM = [[YMAccountBalanceViewModel alloc]initWithParams:@{
  95. ParamsId:@([[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id intValue])
  96. }];
  97. YMAccountBalanceRechargePopupView *customView = [[YMAccountBalanceRechargePopupView alloc]init];
  98. [customView ym_bindViewModel:accountBalanceVM];
  99. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
  100. popupView.priority = 999;
  101. popupView.cornerRadius = adapt(10);
  102. popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
  103. popupView.positionStyle = YMPositionStyleBottom;
  104. popupView.isClickBgDismiss = YES;
  105. popupView.isHideBg = NO;
  106. popupView.bgAlpha = 0.5;
  107. [popupView pop];
  108. @weakify(popupView)
  109. customView.dismissBlock = ^{
  110. @strongify(popupView)
  111. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  112. };
  113. // YMAccountBalanceViewModel *accountBalanceVM = [[YMAccountBalanceViewModel alloc]initWithParams:@{
  114. // ParamsId:@([[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id intValue])
  115. // }];
  116. // [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_ACCOUNT_BALANCE) withUserInfo:@{
  117. // RouterViewModel:accountBalanceVM
  118. // } completion:nil];
  119. }else if ([str isEqualToString:@"applyBigCast"]){
  120. if ([LCSaveModel getUserModel].youpaipuserinfo.youpaipis_anchor ==0) {
  121. YOUPAILCVerifyBigCastVC* verBigCast = [[YOUPAILCVerifyBigCastVC alloc]init];
  122. [self.navigationController pushViewController:verBigCast animated:YES];
  123. }
  124. }else if ([str isEqualToString:@"auditCamera"]){
  125. YOUPAILCCameraAuditVC* audit = [[YOUPAILCCameraAuditVC alloc]init];
  126. [self.navigationController pushViewController:audit animated:YES];
  127. }else if([str isEqualToString:@"gameOrderList"]){
  128. YOUPAILZGameAccompanyListVC *vc = [[YOUPAILZGameAccompanyListVC alloc] init];
  129. [self.navigationController pushViewController:vc animated:YES];
  130. }else if([str isEqualToString:@"infoEdit"]){
  131. MSYMineinfoEditVC * editvc = [MSYMineinfoEditVC new];
  132. [self.navigationController pushViewController:editvc animated:true];
  133. }else if([str isEqualToString:@"bindPhone"]){
  134. YOUPAILCBindPhoneAccountVC* bindAccount = [[YOUPAILCBindPhoneAccountVC alloc]init];
  135. [self.navigationController pushViewController:bindAccount animated:YES];
  136. }else if([str isEqualToString:@"auth"]){
  137. [LCTools goRealNamePage];
  138. }else if([str isEqualToString:@"main"]){
  139. [[NSNotificationCenter defaultCenter] postNotificationName:@"LeaveLive" object:nil userInfo:nil];
  140. [self.tabBarController setSelectedIndex:0];
  141. [self.tabBarController.navigationController popToRootViewControllerAnimated:YES];
  142. [self.navigationController popToRootViewControllerAnimated:YES];
  143. }else if([str isEqualToString:@"dynamic"]){
  144. [self.tabBarController setSelectedIndex:1];
  145. [self.tabBarController.navigationController popToRootViewControllerAnimated:YES];
  146. [self.navigationController popToRootViewControllerAnimated:YES];
  147. }else if([str isEqualToString:@"msg"]){
  148. [self.tabBarController setSelectedIndex:2];
  149. [self.tabBarController.navigationController popToRootViewControllerAnimated:YES];
  150. [self.navigationController popToRootViewControllerAnimated:YES];
  151. }else if([str isEqualToString:@"my"]){
  152. [self.tabBarController setSelectedIndex:3];
  153. [self.tabBarController.navigationController popToRootViewControllerAnimated:YES];
  154. [self.navigationController popToRootViewControllerAnimated:YES];
  155. }
  156. // if (self.navigationController != nil) {
  157. // self.presentedVCs = [NSMutableArray array];
  158. // UIViewController *vc = self;
  159. // while (0 == 0) {
  160. // if (vc.presentedViewController != nil) {
  161. // [self.presentedVCs addObject:vc.presentedViewController];
  162. // vc = vc.presentedViewController;
  163. // }else{
  164. // break;
  165. // }
  166. // }
  167. // [self dismissViewControllerAnimated:NO completion:^{}];
  168. // }
  169. }
  170. - (NSMutableArray<UIViewController *> *)presentedVCs{
  171. return objc_getAssociatedObject(self, PresentedVCsKey);
  172. }
  173. - (void)setPresentedVCs:(NSMutableArray<UIViewController *> *)presentedVCs{
  174. objc_setAssociatedObject(self, PresentedVCsKey, presentedVCs, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
  175. }
  176. @end