123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- //
- // AS_LoginC.m
- // Asteria
- //
- // Created by 王猛 on 2023/5/15.
- //
- #import "AS_LoginC.h"
- #import "EamilTFmatchV.h"
- #import "PassWordSecureBtnV.h"
- #import "LoginThirdAuthV.h"
- #import <AFNetworking/AFNetworking.h>
- #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;
- [MBProgressHUD showHUDAddedTo:self.view animated:YES];
- [ASNetTools xxx_loginWithParam:params success:^(id _Nonnull result) {
- [MBProgressHUD hideHUDForView :self.view animated:YES];
- @weakify(self)
- [self.view makeToast:@"Login Suecess" duration:2 position:CSToastPositionCenter title:nil image:nil style:nil completion:^(BOOL didTap) {
- @strongify(self)
- [self handle_closeEvent:nil];
- }];
- } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
- [MBProgressHUD hideHUDForView :self.view animated:YES];
- [self.view makeToast:msg duration:2 position:CSToastPositionCenter];
- }];
- /*
- [PPNetworkHelper POST:urlStr parameters:params success:^(id responseObject) {
- [MBProgressHUD hideHUDForView :self.view animated:YES];
- NSDictionary *tmpDic= responseObject;
- if([tmpDic[@"status"] intValue] ==1){
- NSString *token = MM_str(tmpDic[@"data"]);
- //保存 token
- [DataUtil setLoginToken:token];
- @weakify(self)
- [self.view makeToast:@"Login Suecess" duration:2 position:CSToastPositionCenter title:nil image:nil style:nil completion:^(BOOL didTap) {
- @strongify(self)
- [self handle_closeEvent:nil];
- }];
- }else{
-
- [self.view makeToast:MM_str(tmpDic[@"msg"]) duration:2 position:CSToastPositionCenter];
- }
- } failure:^(NSError *error) {
-
- [MBProgressHUD hideHUDForView :self.view animated:YES];
- if(error == nil){
- [self.view makeToast:@"Network request failed" duration:2 position:CSToastPositionCenter];
- }else{
- NSData *strData = [error userInfo][@"com.alamofire.serialization.response.error.data"];
- NSMutableDictionary *temDic =[NSMutableDictionary dictionaryWithDictionary:[PPNetworkHelper too_DataToDic:strData]];
- temDic = [UC_CommonmoduleNetWorkTool tt_changeType:temDic];
- NSString *errorMsg = @"Network request failed";
- if(![Current_normalTool isBlankString:temDic[@"msg"]]){
- errorMsg = MM_str(temDic[@"msg"]);
- }
- [self.view makeToast:errorMsg duration:2 position:CSToastPositionCenter];
- }
- }];
- */
- }
- //注册页面
- -(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
|