PCLoginViewController.m 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. //
  2. // PCLoginViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/8/27.
  6. //
  7. #import "PCLoginViewController.h"
  8. @interface PCLoginViewController ()
  9. @end
  10. @implementation PCLoginViewController
  11. - (void)viewDidLoad {
  12. [super viewDidLoad];
  13. // Do any additional setup after loading the view.
  14. [self.view setBackgroundColor:HWF5F7FAColor];
  15. [self.titleLabel setText:NSLocalizedString(@"pc_login_title",nil)];
  16. [self.toolBar setHidden:YES];
  17. [self.navigationBar setHidden:YES];
  18. [self.navBarBGView setHidden:NO];
  19. [self drawAnyView];
  20. }
  21. - (void)drawAnyView{
  22. //顶底底部图片
  23. UIImageView *topImageV = [UIImageView new];
  24. topImageV.image = [UIImage imageNamed:@"pc_login_img"];
  25. [self.view addSubview:topImageV];
  26. [topImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.top.mas_equalTo(150);
  28. make.centerX.mas_equalTo(0);
  29. make.width.mas_equalTo(160);
  30. make.height.mas_equalTo(160);
  31. }];
  32. //提示文件
  33. UILabel*tiplabel = [[UILabel alloc] init];
  34. tiplabel.font = [UIFont boldSystemFontOfSize:14.0];
  35. tiplabel.textColor = [UIColor hwColor:@"#0A132B"];
  36. tiplabel.textAlignment = NSTextAlignmentCenter;
  37. tiplabel.numberOfLines = 2;
  38. [self.view addSubview:tiplabel];
  39. [tiplabel setText:NSLocalizedString(@"pc_login_tip",nil)];
  40. [tiplabel mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.left.mas_equalTo(20);
  42. make.right.mas_equalTo(-20);
  43. make.top.mas_equalTo(topImageV.mas_bottom).offset(5);
  44. make.height.mas_equalTo(40);
  45. }];
  46. UIButton *loginOkBut = [[UIButton alloc] init];
  47. CAGradientLayer *gradientLayer = [CAGradientLayer layer];
  48. gradientLayer.frame = CGRectMake(0, 0, (SCREEN_W - 55*2), 48);
  49. gradientLayer.colors = @[(__bridge NSString *)[UIColor hwColor:@"#0CDEFD" alpha:1.0].CGColor, (__bridge NSString *)[UIColor hwColor:@"#058DFB" alpha:1.0].CGColor];
  50. gradientLayer.locations = @[@(0), @(1.0f)];
  51. gradientLayer.startPoint = CGPointMake(0, 0.5);
  52. gradientLayer.endPoint = CGPointMake(0.97, 0.5);
  53. [loginOkBut.layer addSublayer:gradientLayer];
  54. [loginOkBut setTitle:NSLocalizedString(@"pc_login_sure_tip",nil) forState:UIControlStateNormal];
  55. loginOkBut.titleLabel.font = [UIFont systemFontOfSize:14.0];
  56. loginOkBut.layer.cornerRadius = 8;
  57. loginOkBut.layer.masksToBounds = YES;
  58. loginOkBut.tag = 1;
  59. [loginOkBut addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  60. [self.view addSubview:loginOkBut];
  61. [loginOkBut mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.height.mas_equalTo(48);
  63. make.left.mas_equalTo(55);
  64. make.right.mas_equalTo(-55);
  65. make.top.mas_equalTo(tiplabel.mas_bottom).offset(70);
  66. }];
  67. UIButton *cancelLoginButton = [[UIButton alloc] init];
  68. [cancelLoginButton setTitle:NSLocalizedString(@"pc_login_cancel_tip",nil) forState:UIControlStateNormal];
  69. [cancelLoginButton setTitleColor:[UIColor hwColor:@"#999999"] forState:UIControlStateNormal];
  70. cancelLoginButton.titleLabel.font = [UIFont systemFontOfSize:14.0];
  71. cancelLoginButton.tag = 2;
  72. [cancelLoginButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  73. [self.view addSubview:cancelLoginButton];
  74. [cancelLoginButton mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.height.mas_equalTo(40);
  76. make.left.mas_equalTo(55);
  77. make.right.mas_equalTo(-55);
  78. make.top.mas_equalTo(loginOkBut.mas_bottom).offset(10);
  79. }];
  80. }
  81. #pragma mark 扫码登录
  82. - (void)didClickButtonFun:(UIButton*)but
  83. {
  84. NSInteger tag = but.tag;
  85. NSInteger status = 2;
  86. if(tag == 2){
  87. status = 3;
  88. }
  89. [self scanToPCloginFunWith:status];
  90. }
  91. #pragma mark PC 扫码登录
  92. -(void)scanToPCloginFunWith:(NSInteger)status
  93. {
  94. NSString *changSN = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
  95. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  96. [paraDict setValue:[NSNumber numberWithInteger:status] forKey:@"status"];
  97. if(_loginIdString){
  98. [paraDict setValue:_loginIdString forKey:@"boxLoginId"];
  99. }
  100. if(changSN){
  101. [paraDict setValue:changSN forKey:@"sn"];
  102. }
  103. KWeakSelf
  104. [[netWorkManager shareInstance] CommonPostCallBackCode:updatePCLoginStateFun Parameters:paraDict success:^(id _Nonnull responseObject){
  105. SuperModel *curModel = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  106. if(curModel && curModel.status == 0){
  107. if(status == 2){
  108. [[iToast makeText:NSLocalizedString(@"pc_login_ok_tip",nil)] show];
  109. }
  110. }
  111. else
  112. {
  113. if(curModel.msg){
  114. [[iToast makeText:curModel.msg] show];
  115. }
  116. else{
  117. if(status == 2){
  118. [[iToast makeText:NSLocalizedString(@"pc_login_fail_tip",nil)] show];
  119. }
  120. }
  121. }
  122. [weakSelf showTabbarFunInVC];
  123. [weakSelf.navigationController popToRootViewControllerAnimated:YES];
  124. } failure:^(NSError * _Nonnull error) {
  125. if(status == 2){
  126. [[iToast makeText:NSLocalizedString(@"pc_login_fail_tip",nil)] show];
  127. }
  128. [weakSelf showTabbarFunInVC];
  129. [weakSelf.navigationController popToRootViewControllerAnimated:YES];
  130. }];
  131. }
  132. #pragma mark 修复PC登录后没有tabbar问题
  133. - (void)showTabbarFunInVC
  134. {
  135. //[self showTabbarFun];
  136. [[NSNotificationCenter defaultCenter] postNotificationName:PCDidLoginNotification object:nil];/*发送通知*/
  137. }
  138. //"pc_login_ing_tip" = "正在登录中…";
  139. @end