From 3e8437ae559487362fae3525beb79c534c213a51 Mon Sep 17 00:00:00 2001 From: 单军华 Date: Thu, 12 Jul 2018 13:44:34 +0800 Subject: [PATCH] bug修复和功能优化 --- screendisplay/screendisplay/Classes/登录/Controller/LoginViewController.m | 283 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 283 insertions(+), 0 deletions(-) diff --git "a/screendisplay/screendisplay/Classes/\347\231\273\345\275\225/Controller/LoginViewController.m" "b/screendisplay/screendisplay/Classes/\347\231\273\345\275\225/Controller/LoginViewController.m" new file mode 100644 index 0000000..533a557 --- /dev/null +++ "b/screendisplay/screendisplay/Classes/\347\231\273\345\275\225/Controller/LoginViewController.m" @@ -0,0 +1,283 @@ +// +// LoginViewController.m +// screendisplay +// +// Created by ��������� on 2018/7/3. +// Copyright �� 2018��� ���������. All rights reserved. +// + +#import "LoginViewController.h" +#import "LoginSevice.h" +#import "CommonReqModel.h" +#import "LMJTabBarController.h" +#import "MonitoringMapViewController.h" + +@interface LoginViewController () +{ + UIButton * nomalLoginBtn; + + UITextField * userPhoneTextField; + UITextField * userPwdTextFeild; + + //UIButton * forgetBtn; +} + +/** digest */ +@property (nonatomic, strong) LoginSevice *loginSevice; + + +@end + +@implementation LoginViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. + [self setUIView]; +} + +-(void)setUIView +{ + UIImageView * loginBk = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)]; + loginBk.image = [UIImage imageNamed:@"login_background"]; + [self.view addSubview:loginBk]; + + + UIImageView * logoPic = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-AdaptedWidth(335))/2, NavBar_Height+AdaptedHeight(27), AdaptedWidth(335), AdaptedHeight(149))]; + logoPic.image = [UIImage imageNamed:@"login_app_logo"]; + [self.view addSubview:logoPic]; + + UIImageView * edit_bkimg = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-AdaptedWidth(304))/2, NavBar_Height+AdaptedHeight(27+149+33), AdaptedWidth(304), AdaptedHeight(50))]; + edit_bkimg.image = [UIImage imageNamed:@"login_account_pwd_bk"]; + [self.view addSubview:edit_bkimg]; + + userPhoneTextField = [[UITextField alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-AdaptedWidth(304))/2+AdaptedWidth(40), NavBar_Height+AdaptedHeight(27+149+33), AdaptedWidth(304-40), AdaptedHeight(50))]; + userPhoneTextField.font = [UIFont fontWithName:@"Arial" size:16]; + userPhoneTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"������������������"attributes:@{ NSForegroundColorAttributeName:kUIColorFromRGB(0x00b744)}]; + userPhoneTextField.delegate = self; + [userPhoneTextField setValue:RgbColor(255, 255, 255) forKeyPath:@"_placeholderLabel.textColor"]; + //userPhoneTextField.layer.borderColor = [RgbColor(213, 213, 213) CGColor]; + userPhoneTextField.textColor = RgbColor(255, 255, 255); + userPhoneTextField.keyboardType = UIKeyboardTypeDefault; + userPhoneTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; + // ������������������blankView���15.0������������View���������width��������������������������������������������������������������� + UIView *blankView = [[UIView alloc] initWithFrame:CGRectMake(userPhoneTextField.frame.origin.x,userPhoneTextField.frame.origin.y,10.0, userPhoneTextField.frame.size.height)]; + + userPhoneTextField.leftView = blankView; + userPhoneTextField.leftViewMode =UITextFieldViewModeAlways; + [self.view addSubview:userPhoneTextField]; + + UIImageView * edit_bkimg2 = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-AdaptedWidth(304))/2, NavBar_Height+AdaptedHeight(27+149+33+50+33), AdaptedWidth(304), AdaptedHeight(50))]; + edit_bkimg2.image = [UIImage imageNamed:@"login_account_pwd_bk"]; + [self.view addSubview:edit_bkimg2]; + + + userPwdTextFeild = [[UITextField alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-AdaptedWidth(304))/2+AdaptedWidth(40), NavBar_Height+AdaptedHeight(27+149+33+50+33), AdaptedWidth(304-40), AdaptedHeight(50))]; + userPwdTextFeild.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"���������������"attributes:@{ NSForegroundColorAttributeName:kUIColorFromRGB(0x00b744)}]; + userPwdTextFeild.secureTextEntry = YES; + userPwdTextFeild.font = [UIFont fontWithName:@"Arial" size:16]; + userPwdTextFeild.delegate = self; + [userPwdTextFeild setValue:RgbColor(255, 255, 255) forKeyPath:@"_placeholderLabel.textColor"]; + //userPhoneTextField.layer.borderColor = [RgbColor(213, 213, 213) CGColor]; + userPwdTextFeild.textColor = RgbColor(255, 255, 255); + userPwdTextFeild.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; + // ������������������blankView���15.0������������View���������width��������������������������������������������������������������� + UIView *blankView2 = [[UIView alloc] initWithFrame:CGRectMake(userPwdTextFeild.frame.origin.x,userPwdTextFeild.frame.origin.y,10.0, userPwdTextFeild.frame.size.height)]; + userPwdTextFeild.leftView = blankView2; + userPwdTextFeild.leftViewMode =UITextFieldViewModeAlways; + [self.view addSubview:userPwdTextFeild]; + + nomalLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom]; + nomalLoginBtn.frame = CGRectMake((SCREEN_WIDTH-AdaptedWidth(304))/2, NavBar_Height+AdaptedHeight(27+149+33+50+33+50+33), AdaptedWidth(304), AdaptedHeight(50)); + [nomalLoginBtn setBackgroundImage:[UIImage imageNamed:@"login_user_login_btnbk" ] forState:UIControlStateNormal]; + [nomalLoginBtn setTitle:@"��� ���" forState:UIControlStateNormal]; + nomalLoginBtn.titleLabel.font = [UIFont systemFontOfSize: 18.0]; + [nomalLoginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + nomalLoginBtn.layer.masksToBounds=YES; + nomalLoginBtn.layer.cornerRadius=8.0f; + [nomalLoginBtn addTarget:self action:@selector(userLogin) forControlEvents:UIControlEventTouchUpInside]; + [self.view addSubview:nomalLoginBtn]; + +// forgetBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; +// forgetBtn.frame = CGRectMake((SCREEN_WIDTH-120)/2, SCREEN_HEIGHT/2+225, 120, 40); +// [forgetBtn setTitle:@"������������" forState:UIControlStateNormal]; +// forgetBtn.titleLabel.font = [UIFont systemFontOfSize: 16.0]; +// [forgetBtn setTitleColor:kUIColorFromRGB(0x009dff) forState:UIControlStateNormal]; +// [forgetBtn addTarget:self action:@selector(registAction) forControlEvents:UIControlEventTouchUpInside]; +// [self.view addSubview:forgetBtn]; +} + +-(void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:YES]; + + self.navigationController.navigationBarHidden = YES; + + if([UserDefault stringForKey:@"isLogin"] != nil && [[UserDefault stringForKey:@"isLogin"] intValue] == 1 ) + { + // ��������������� + [self getUserInfo]; + } + +} +-(void)viewDidDisappear:(BOOL)animated +{ + [super viewDidDisappear:YES]; + //self.navigationController.navigationBarHidden = NO; +} + + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (LoginSevice *)loginSevice +{ + if(_loginSevice == nil) { + _loginSevice = [LoginSevice new]; + } + return _loginSevice; +} + +-(void)registAction +{ + +} + +-(void) userLogin +{ + // ������������������ + if(userPhoneTextField.text.length == 0) + { + [Global alertMessageEx:@"���������������." title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self]; + } + else if(userPwdTextFeild.text.length == 0) + { + [Global alertMessageEx:@"���������������������." title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self]; + } + else + { + // ������������������ + MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; + HUD.labelText = @"���������..."; + // ��������������������������������� + HUD.removeFromSuperViewOnHide = YES; + // YES������������������������ + HUD.dimBackground = YES; + + CommonReqModel * model = [[CommonReqModel alloc] init]; + [model setAccount:userPhoneTextField.text]; + [model setPassword:userPwdTextFeild.text]; + + TWWeak(self); + [self.loginSevice getLoginWithParameters:model.toDic completion:^(NSString *desc, int code) { + HUD.hidden = YES; + if(code == 1) + { + MonitoringMapViewController * page = [[MonitoringMapViewController alloc] init]; + [weakself.navigationController pushViewController:page animated:YES]; + } + else + { + [Global alertMessageEx:desc title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self]; + } + }]; + } + +} + +-(void)getUserInfo +{ + CommonReqModel * model = [[CommonReqModel alloc] init]; + [model setAccount:[UserDefault stringForKey:@"accountName"]]; + [model setPassword:[UserDefault stringForKey:@"password"]]; + + TWWeak(self); + [self.loginSevice getLoginWithParameters:model.toDic completion:^(NSString *desc, int code) { + if(code == 1) + { + // ��������������� + MonitoringMapViewController * page = [[MonitoringMapViewController alloc] init]; + [weakself.navigationController pushViewController:page animated:YES]; + } + else + { + [Global alertMessageEx:desc title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self]; + } + }]; +} +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +#pragma mark - LMJNavUIBaseViewControllerDataSource + +- (UIStatusBarStyle)navUIBaseViewControllerPreferStatusBarStyle:(LMJNavUIBaseViewController *)navUIBaseViewController +{ + return UIStatusBarStyleDefault; +} + +/**������������*/ +- (NSMutableAttributedString*)lmjNavigationBarTitle:(LMJNavigationBar *)navigationBar +{ + return nil; +} + + +/** ��������� */ +- (UIColor *)lmjNavigationBackgroundColor:(LMJNavigationBar *)navigationBar +{ + return [UIColor clearColor]; +} + +/** ������������������������ */ +- (BOOL)lmjNavigationIsHideBottomLine:(LMJNavigationBar *)navigationBar +{ + return YES; +} + +/** ������������������������ */ +- (UIImage *)lmjNavigationBarLeftButtonImage:(UIButton *)leftButton navigationBar:(LMJNavigationBar *)navigationBar +{ + + return [UIImage imageNamed:@"login_close_icon"]; +} +/** ������������������������ */ +- (UIImage *)lmjNavigationBarRightButtonImage:(UIButton *)rightButton navigationBar:(LMJNavigationBar *)navigationBar +{ + + [rightButton setEnabled:NO]; +// [rightButton setTitle:@"������������" forState: UIControlStateNormal]; +// [rightButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; +// [rightButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted]; +// rightButton.titleLabel.font = [UIFont systemFontOfSize:15]; +// +// rightButton.lmj_width = 80; + + return nil; +} + + + +#pragma mark - LMJNavUIBaseViewControllerDelegate +/** ������������������������ */ +-(void)leftButtonEvent:(UIButton *)sender navigationBar:(LMJNavigationBar *)navigationBar +{ + [self dismissViewControllerAnimated:YES completion:nil]; +} + + +/** ������������������������ */ +-(void)rightButtonEvent:(UIButton *)sender navigationBar:(LMJNavigationBar *)navigationBar +{ + +} + +@end -- Gitblit v1.8.0