// // AS_LoginC.m // Asteria // // Created by 王猛 on 2023/5/15. // #import "AS_LoginC.h" #import "EamilTFmatchV.h" #import "PassWordSecureBtnV.h" #import "LoginThirdAuthV.h" #import #import "AS_SignUpC.h" #import "AS_ForgotC.h" @interface AS_LoginC () @property (nonatomic, strong) UIScrollView *scrollview; @property (nonatomic, strong) EamilTFmatchV *xxx_emailTFV; @property (nonatomic, strong) PassWordSecureBtnV *xxx_passwordV; @property (nonatomic, strong) UIButton *xxx_logInBtn; @property (nonatomic, strong) LoginThirdAuthV *xxx_authV; @end @implementation AS_LoginC - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.customNavBar.hidden = YES; self.navigationController.navigationBar.hidden = YES; } - (void)initSubviews{ [super initSubviews]; [self.view addSubview:self.scrollview]; UIView *logNav = [self logNavView]; [self.scrollview addSubview:logNav]; UIImageView *Hi_imgV = [[UIImageView alloc]init]; UIImage *hiImg = [UIImage imageNamed:@"login_HI"]; Hi_imgV.image = hiImg; Hi_imgV.frame = CGRectMake(20, CGRectGetMaxY(logNav.frame)+30, KScreenWidth-40, hiImg.size.height/hiImg.size.width*(KScreenWidth-40)); [self.scrollview addSubview:Hi_imgV]; [self.scrollview addSubview:self.xxx_emailTFV]; [self.scrollview addSubview:self.xxx_passwordV]; [self.scrollview bringSubviewToFront:self.xxx_emailTFV]; [self.scrollview addSubview:self.xxx_logInBtn]; [self.scrollview addSubview:self.xxx_authV]; UIView *bottomV = [self load_bottom_v]; [self.scrollview addSubview:bottomV]; self.xxx_emailTFV.mj_y = CGRectGetMaxY(Hi_imgV.frame)+35; self.xxx_passwordV.frame = CGRectFlatMake(20, CGRectGetMaxY(self.xxx_emailTFV.frame)+30, KScreenWidth-40, 50+20); self.xxx_logInBtn.frame = CGRectMake(20, CGRectGetMaxY(self.xxx_passwordV.frame)+10, KScreenWidth-40, 45); self.xxx_authV.mj_y = CGRectGetMaxY(self.xxx_logInBtn.frame)+30; bottomV.mj_y = CGRectGetMaxY(self.xxx_authV.frame)+30; } -(void)handle_closeEvent:(UIButton *)btn{ [self.navigationController dismissViewControllerAnimated:YES completion:nil]; } -(void)handle_xxx_logInBtnEvent:(UIButton *)btn{//进行登录操作 ///登录的跳转 if (self.xxx_emailTFV.xxx_emailTF.text.length == 0 || ![Current_normalTool xxx_isValidateEmail:self.xxx_emailTFV.xxx_emailTF.text]) { [self.view makeToast:@"* Please prvide an email address." duration:2 position:CSToastPositionCenter]; return; }else if(self.xxx_passwordV.xxx_passwordTF.text.length == 0){ [self.view makeToast:@"Please input a password" duration:2 position:CSToastPositionCenter]; return; } NSString *urlStr = [NSString stringWithFormat:@"%@V1/integration/customer/token",AS_Server]; NSMutableDictionary *params = [[NSMutableDictionary alloc]init]; params[@"username"] = self.xxx_emailTFV.xxx_emailTF.text; params[@"password"] = self.xxx_passwordV.xxx_passwordTF.text; // NSString *josnStr = [Current_normalTool jsonStringFromDictionary:params]; // [PPNetworkHelper POST:urlStr parameters:params success:^(id responseObject) { // NSDictionary *tmpDic= responseObject; // // } failure:^(NSError *error) { // [self.view makeToast:@"Network request failed" duration:2 position:CSToastPositionCenter]; // }]; AFHTTPSessionManager *manager =[AFHTTPSessionManager manager]; manager.requestSerializer = [AFJSONRequestSerializer serializer]; manager.responseSerializer = [AFHTTPResponseSerializer serializer]; manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/json", @"text/plain", @"text/html", nil]; [manager POST:urlStr parameters:params headers:nil progress:^(NSProgress * _Nonnull uploadProgress) { } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { NSString * jsonStr = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding]; NSDictionary *temDic = [Current_normalTool dicFromjsonStr:jsonStr]; NSLog(@"%@",temDic); } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { }]; } //注册页面 -(void)handle_signUpEvent:(UIButton *)btn{ AS_SignUpC *upVC = [[AS_SignUpC alloc]init]; [self.navigationController pushViewController:upVC animated:YES]; } -(void)handle_forgetBtnEvent:(UIButton *)btn{ AS_ForgotC *forgoC = [[AS_ForgotC alloc]init]; [self.navigationController pushViewController:forgoC animated:YES]; } #pragma mark - **************** 懒加载 **************** -(UIView *)logNavView{ IPhoneXHeigh UIView *topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, securitytop_Y)]; UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [closeBtn setImage:[UIImage imageNamed:@"common_close"] forState:UIControlStateNormal]; [closeBtn addTarget:self action:@selector(handle_closeEvent:) forControlEvents:UIControlEventTouchUpInside]; closeBtn.frame = CGRectMake(20, securitytop_Y-44, 44, 44); [topView addSubview:closeBtn]; UIImageView *headImg = [[UIImageView alloc]init]; UIImage *bannerImg = [UIImage imageNamed:@"common_headLogo"]; headImg.image = bannerImg ; headImg.frame = CGRectMake((KScreenWidth- bannerImg.size.width)/2, (IPHONEX ? 44 : 20)+20 , bannerImg.size.width, bannerImg.size.height); [topView addSubview:headImg]; closeBtn.centerY = topView.centerY; headImg.centerY = topView.centerY; return topView; } - (UIScrollView *)scrollview { if (!_scrollview) { _scrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; } return _scrollview; } -(EamilTFmatchV *)xxx_emailTFV{ if (!_xxx_emailTFV) { _xxx_emailTFV = [[EamilTFmatchV alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 50)]; } return _xxx_emailTFV; } - (PassWordSecureBtnV *)xxx_passwordV { if (!_xxx_passwordV) { _xxx_passwordV = [[PassWordSecureBtnV alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(self.xxx_emailTFV.frame)+30, KScreenWidth-40, 50+20)]; } return _xxx_passwordV; } - (UIButton *)xxx_logInBtn { if (!_xxx_logInBtn) { _xxx_logInBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [_xxx_logInBtn setTitleColor:[UIColor colorWithHexString:@"#000000"] forState:UIControlStateNormal]; _xxx_logInBtn.titleLabel.font = [UIFont fontWithName:Rob_Bold size:16]; [_xxx_logInBtn setTitle:@"LOG IN" forState:UIControlStateNormal]; [_xxx_logInBtn addTarget:self action:@selector(handle_xxx_logInBtnEvent:) forControlEvents:UIControlEventTouchUpInside]; _xxx_logInBtn.backgroundColor = ThemeColor; _xxx_logInBtn.layer.cornerRadius = 4; _xxx_logInBtn.clipsToBounds = YES; } return _xxx_logInBtn; } - (LoginThirdAuthV *)xxx_authV { if (!_xxx_authV) { _xxx_authV = [[LoginThirdAuthV alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 15+20+(36+10)*3)]; } return _xxx_authV; } -(UIView *)load_bottom_v{ UIView *bottomV = [[UIView alloc]initWithFrame:CGRectMake(20, 0, KScreenWidth-40, 32)]; QMUILabel *disLab = [[QMUILabel alloc]init]; disLab.text = @"Don't Have An Account?"; disLab.font = [UIFont fontWithName:Rob_Regular size:12]; [bottomV addSubview:disLab]; UIButton *signUpBtn = [UIButton buttonWithType:UIButtonTypeCustom]; signUpBtn.backgroundColor = [UIColor clearColor]; NSMutableAttributedString *sinAtr = [[NSMutableAttributedString alloc]initWithString:@"Sign Up" attributes:@{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}]; [signUpBtn setAttributedTitle:sinAtr forState:UIControlStateNormal]; [signUpBtn addTarget:self action:@selector(handle_signUpEvent:) forControlEvents:UIControlEventTouchUpInside]; [signUpBtn setTitleColor:ThemeColor forState:UIControlStateNormal]; signUpBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:12]; [bottomV addSubview:signUpBtn]; UIButton *forgetBtn = [UIButton buttonWithType:UIButtonTypeCustom]; forgetBtn.backgroundColor = [UIColor clearColor]; NSMutableAttributedString *forgotAtr = [[NSMutableAttributedString alloc]initWithString:@"Forgot Your Password" attributes:@{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}]; [forgetBtn setAttributedTitle:forgotAtr forState:UIControlStateNormal]; [forgetBtn setTitleColor:ThemeColor forState:UIControlStateNormal]; forgetBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:12]; [forgetBtn addTarget:self action:@selector(handle_forgetBtnEvent:) forControlEvents:UIControlEventTouchUpInside]; [bottomV addSubview:forgetBtn]; [disLab mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.mas_equalTo(0); make.height.mas_equalTo(16); }]; [signUpBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(disLab); make.left.equalTo(disLab.mas_right).offset(3); make.height.mas_equalTo(20); make.width.mas_equalTo(45); }]; [forgetBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.equalTo(disLab.mas_bottom).offset(10); make.height.mas_equalTo(15); make.width.mas_equalTo(120); }]; return bottomV; } @end