GuideViewController.m 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. //
  2. // GuideViewController.m
  3. //
  4. //
  5. // Created by APPLE on 2023/8/11.
  6. //
  7. #import "GuideViewController.h"
  8. #import "Masonry.h"
  9. #import "UIView+View.h"
  10. #import "GuideView.h"
  11. #import "GuideLastView.h"
  12. #import "SetPWDFirstViewController.h"
  13. #import "inputPWDViewController.h"
  14. @interface GuideViewController ()<UIScrollViewDelegate>
  15. {
  16. UIScrollView *bgScrView;
  17. GuideView *guideView0;
  18. GuideView *guideView1;
  19. GuideView *guideView2;
  20. GuideView *guideView3;
  21. GuideLastView *guideLastView;
  22. }
  23. @end
  24. @implementation GuideViewController
  25. @synthesize delegate;
  26. @synthesize sn;
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. // Do any additional setup after loading the view.
  30. self.navigationBar.hidden = YES;
  31. [self drawAnyView];
  32. if(!ksharedAppDelegate.isWebSockLinkOKAginType){
  33. [[webRtcManager shareManager] beginToLinkWebRtcFun];
  34. }
  35. }
  36. - (void)viewDidAppear:(BOOL)animated{
  37. [super viewDidAppear:animated];
  38. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  39. [self startMoveView];
  40. });
  41. }
  42. - (void)startMoveView{
  43. CGFloat x = bgScrView.contentOffset.x;
  44. NSInteger index = (x+1)/self.view.width;
  45. if (index >= 4){
  46. /*记录已经用户引导*/
  47. [HWDataManager setBoolWithKey:Const_Have_Show_Guide value:YES];
  48. if(!ksharedAppDelegate.DeviceThirdIdMod){
  49. HLog(@"没有拿到设备信息");
  50. KWeakSelf
  51. [[netWorkManager shareInstance] getThridMsgBySN:sn success:^(id _Nonnull responseObject) {
  52. DeviceThirdIdModel *model = responseObject;
  53. if([model isKindOfClass:[DeviceThirdIdModel class]]){
  54. if(model.status == 0 && model.data){
  55. }
  56. else{
  57. [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_get_SdnID_fail",nil)] show];
  58. }
  59. }
  60. else{
  61. [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_get_SdnID_fail",nil)] show];
  62. }
  63. [weakSelf startMoveView];
  64. } failure:^(NSError * _Nonnull error) {
  65. [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_get_SdnID_fail",nil)] show];
  66. [weakSelf startMoveView];
  67. }];
  68. return;
  69. }
  70. //是否已经有密码了 有就是输入密码 没有就是设置密码
  71. NSString *curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password;
  72. if(curPwd && curPwd.length > 0){
  73. BOOL haveOpenMask = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
  74. if(!haveOpenMask)
  75. {
  76. ksharedAppDelegate.isFirstInputPwdDone = YES;
  77. [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
  78. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  79. [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
  80. });
  81. return;
  82. }
  83. /*设置密码*/
  84. // inputPWDViewController *nextVC = [[inputPWDViewController alloc] init];
  85. // nextVC.isQRCodeType = YES;
  86. // [self.navigationController pushViewController:nextVC animated:YES];
  87. [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
  88. }
  89. else{
  90. /*设置密码*/
  91. // SetPWDFirstViewController *nextVC = [[SetPWDFirstViewController alloc] init];
  92. // [self.navigationController pushViewController:nextVC animated:YES];
  93. [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
  94. }
  95. }else{
  96. [bgScrView setContentOffset:CGPointMake((index + 1)*self.view.width, 0) animated:YES];
  97. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  98. [self startMoveView];
  99. });
  100. }
  101. }
  102. - (void)drawAnyView{
  103. [self.view setBackgroundColor:HWF5F7FAColor];
  104. bgScrView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
  105. [bgScrView setBackgroundColor:HWF5F7FAColor];
  106. [bgScrView setShowsVerticalScrollIndicator:NO];
  107. [bgScrView setShowsHorizontalScrollIndicator:NO];
  108. [bgScrView setPagingEnabled:YES];
  109. // [bgScrView setUserInteractionEnabled:NO];
  110. bgScrView.delegate = self;
  111. [bgScrView setContentSize:CGSizeMake(5*self.view.width,self.view.height)];
  112. [bgScrView setClipsToBounds:YES];
  113. [self.view addSubview:bgScrView];
  114. guideView0 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_0",nil)
  115. imageName:@"guide_middle_0_icon"
  116. index:0];
  117. guideView1 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_1",nil)
  118. imageName:@"guide_middle_1_icon"
  119. index:1];
  120. guideView2 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_2",nil)
  121. imageName:@"guide_middle_2_icon"
  122. index:2];
  123. guideView3 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_3",nil)
  124. imageName:@"guide_middle_3_icon"
  125. index:3];
  126. guideView0.frame = CGRectMake(0*self.view.width, 0, self.view.width,self.view.height);
  127. guideView1.frame = CGRectMake(1*self.view.width, 0, self.view.width,self.view.height);
  128. guideView2.frame = CGRectMake(2*self.view.width, 0, self.view.width,self.view.height);
  129. guideView3.frame = CGRectMake(3*self.view.width, 0, self.view.width,self.view.height);
  130. [bgScrView addSubview:guideView0];
  131. [bgScrView addSubview:guideView1];
  132. [bgScrView addSubview:guideView2];
  133. [bgScrView addSubview:guideView3];
  134. guideLastView = [[GuideLastView alloc] initWithFrame:CGRectMake(4*self.view.width, 0, self.view.width,self.view.height)];
  135. [bgScrView addSubview:guideLastView];
  136. KWeakSelf
  137. guideView0.didClickButton = ^{
  138. [weakSelf didClickSkipFun];
  139. };
  140. guideView1.didClickButton = ^{
  141. [weakSelf didClickSkipFun];
  142. };
  143. guideView2.didClickButton = ^{
  144. [weakSelf didClickSkipFun];
  145. };
  146. guideView3.didClickButton = ^{
  147. [weakSelf didClickSkipFun];
  148. };
  149. }
  150. #pragma mark 点击了跳过
  151. - (void)didClickSkipFun
  152. {
  153. [bgScrView setContentOffset:CGPointMake(4*self.view.width, 0) animated:NO];
  154. }
  155. #pragma mark 监听滚动
  156. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  157. {
  158. CGFloat x = scrollView.contentOffset.x;
  159. NSInteger index = (x+1)/self.view.width;
  160. if (index == 4){
  161. bgScrView.userInteractionEnabled = NO;
  162. }
  163. }
  164. @end