GuideViewController.m 7.7 KB

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