123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- //
- // PCLoginViewController.m
- // 双子星云手机
- //
- // Created by xd h on 2024/8/27.
- //
- #import "PCLoginViewController.h"
- @interface PCLoginViewController ()
- @end
- @implementation PCLoginViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- [self.view setBackgroundColor:HWF5F7FAColor];
-
- [self.titleLabel setText:NSLocalizedString(@"pc_login_title",nil)];
-
- [self.toolBar setHidden:YES];
- [self.navigationBar setHidden:YES];
- [self.navBarBGView setHidden:NO];
-
- [self drawAnyView];
- }
- - (void)drawAnyView{
- //顶底底部图片
- UIImageView *topImageV = [UIImageView new];
- topImageV.image = [UIImage imageNamed:@"pc_login_img"];
- [self.view addSubview:topImageV];
-
- [topImageV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(150);
- make.centerX.mas_equalTo(0);
- make.width.mas_equalTo(160);
- make.height.mas_equalTo(160);
- }];
-
- //提示文件
- UILabel*tiplabel = [[UILabel alloc] init];
- tiplabel.font = [UIFont boldSystemFontOfSize:14.0];
- tiplabel.textColor = [UIColor hwColor:@"#0A132B"];
- tiplabel.textAlignment = NSTextAlignmentCenter;
- tiplabel.numberOfLines = 2;
- [self.view addSubview:tiplabel];
- [tiplabel setText:NSLocalizedString(@"pc_login_tip",nil)];
-
- [tiplabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(20);
- make.right.mas_equalTo(-20);
- make.top.mas_equalTo(topImageV.mas_bottom).offset(5);
- make.height.mas_equalTo(40);
- }];
-
-
- UIButton *loginOkBut = [[UIButton alloc] init];
-
- CAGradientLayer *gradientLayer = [CAGradientLayer layer];
- gradientLayer.frame = CGRectMake(0, 0, (SCREEN_W - 55*2), 48);
- gradientLayer.colors = @[(__bridge NSString *)[UIColor hwColor:@"#0CDEFD" alpha:1.0].CGColor, (__bridge NSString *)[UIColor hwColor:@"#058DFB" alpha:1.0].CGColor];
- gradientLayer.locations = @[@(0), @(1.0f)];
- gradientLayer.startPoint = CGPointMake(0, 0.5);
- gradientLayer.endPoint = CGPointMake(0.97, 0.5);
- [loginOkBut.layer addSublayer:gradientLayer];
-
- [loginOkBut setTitle:NSLocalizedString(@"pc_login_sure_tip",nil) forState:UIControlStateNormal];
- loginOkBut.titleLabel.font = [UIFont systemFontOfSize:14.0];
- loginOkBut.layer.cornerRadius = 8;
- loginOkBut.layer.masksToBounds = YES;
- loginOkBut.tag = 1;
- [loginOkBut addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:loginOkBut];
-
-
- [loginOkBut mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(48);
- make.left.mas_equalTo(55);
- make.right.mas_equalTo(-55);
- make.top.mas_equalTo(tiplabel.mas_bottom).offset(70);
- }];
-
- UIButton *cancelLoginButton = [[UIButton alloc] init];
- [cancelLoginButton setTitle:NSLocalizedString(@"pc_login_cancel_tip",nil) forState:UIControlStateNormal];
- [cancelLoginButton setTitleColor:[UIColor hwColor:@"#999999"] forState:UIControlStateNormal];
- cancelLoginButton.titleLabel.font = [UIFont systemFontOfSize:14.0];
- cancelLoginButton.tag = 2;
- [cancelLoginButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:cancelLoginButton];
-
- [cancelLoginButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(40);
- make.left.mas_equalTo(55);
- make.right.mas_equalTo(-55);
- make.top.mas_equalTo(loginOkBut.mas_bottom).offset(10);
- }];
-
-
- }
- #pragma mark 扫码登录
- - (void)didClickButtonFun:(UIButton*)but
- {
- NSInteger tag = but.tag;
- NSInteger status = 2;
- if(tag == 2){
- status = 3;
- }
-
- [self scanToPCloginFunWith:status];
- }
- #pragma mark PC 扫码登录
- -(void)scanToPCloginFunWith:(NSInteger)status
- {
- NSString *changSN = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
- [paraDict setValue:[NSNumber numberWithInteger:status] forKey:@"status"];
- if(_loginIdString){
- [paraDict setValue:_loginIdString forKey:@"boxLoginId"];
- }
- if(changSN){
- [paraDict setValue:changSN forKey:@"sn"];
- }
-
-
- KWeakSelf
- [[netWorkManager shareInstance] CommonPostCallBackCode:updatePCLoginStateFun Parameters:paraDict success:^(id _Nonnull responseObject){
- SuperModel *curModel = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
-
- if(curModel && curModel.status == 0){
- if(status == 2){
- [[iToast makeText:NSLocalizedString(@"pc_login_ok_tip",nil)] show];
- }
- }
- else
- {
- if(curModel.msg){
- [[iToast makeText:curModel.msg] show];
- }
- else{
- if(status == 2){
- [[iToast makeText:NSLocalizedString(@"pc_login_fail_tip",nil)] show];
- }
- }
-
- }
-
- [weakSelf showTabbarFunInVC];
- [weakSelf.navigationController popToRootViewControllerAnimated:YES];
-
- } failure:^(NSError * _Nonnull error) {
- if(status == 2){
- [[iToast makeText:NSLocalizedString(@"pc_login_fail_tip",nil)] show];
- }
- [weakSelf showTabbarFunInVC];
- [weakSelf.navigationController popToRootViewControllerAnimated:YES];
- }];
- }
- #pragma mark 修复PC登录后没有tabbar问题
- - (void)showTabbarFunInVC
- {
- //[self showTabbarFun];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:PCDidLoginNotification object:nil];/*发送通知*/
- }
- //"pc_login_ing_tip" = "正在登录中…";
- @end
|