123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- //
- // JZPhoneLoginViewController.m
- // JIZHANG
- //
- // Created by jikaipeng on 2017/10/26.
- // Copyright © 2017年 kuxuan. All rights reserved.
- //
- #import "JZPhoneLoginViewController.h"
- #import "JZSettingViewController.h"
- #import "AppDelegate.h"
- #import "JZTabBarViewController.h"
- #import "JZForgetPwdViewController.h"
- #import "JZRegisterViewController.h"
- #import <WXApi.h>
- #import <UMSocialCore/UMSocialCore.h>
- #import "JZUtil.h"
- @interface JZPhoneLoginViewController ()
- //手机号
- @property (weak, nonatomic) IBOutlet UITextField *phoneField;
- //密码
- @property (weak, nonatomic) IBOutlet UITextField *pwdField;
- //登录按钮
- @property (weak, nonatomic) IBOutlet UIButton *loginBtn;
- //找回密码
- @property (weak, nonatomic) IBOutlet UIButton *forgetBtn;
- //微信登录
- @property (weak, nonatomic) IBOutlet UIButton *WXLogin;
- //注册按钮
- @property (weak, nonatomic) IBOutlet UIButton *registerBtn;
- //退出登录按钮
- @property (weak, nonatomic) IBOutlet UIButton *backBtn;
- @end
- @implementation JZPhoneLoginViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view from its nib.
- [self setupNavBar];
- [self initUI];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [MobClick beginLogPageView:@"loginPage"];
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- [MobClick endLogPageView:@"loginPage"];
- }
- #pragma mark - event handle
- - (void)setupNavBar {
- [self addLeftBarButtonItemWithImageName:@"mine_back" title:@"返回" target:self selector:@selector(disMissAction)];
- }
- - (void) initUI{
- self.phoneField.clearButtonMode = UITextFieldViewModeWhileEditing;
- self.pwdField.clearButtonMode = UITextFieldViewModeWhileEditing;
- self.phoneField.keyboardType = UIKeyboardTypeNumberPad;
- [self.loginBtn setTitle:@"登录" forState:UIControlStateNormal];
- self.loginBtn.layer.cornerRadius = 12;
- self.loginBtn.layer.masksToBounds = YES;
- self.WXLogin.layer.cornerRadius = 12;
- self.WXLogin.layer.masksToBounds = YES;
- self.loginBtn.backgroundColor = [UIColor baseColor];
- [self.WXLogin setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- self.pwdField.secureTextEntry = YES;
- [self.loginBtn addTarget:self action:@selector(loginAction) forControlEvents:UIControlEventTouchUpInside];
- self.WXLogin.backgroundColor = [UIColor baseColor];
- [self.forgetBtn addTarget:self action:@selector(forgetBtnAction) forControlEvents:UIControlEventTouchUpInside];
- [self.registerBtn addTarget:self action:@selector(registerAction) forControlEvents:UIControlEventTouchUpInside];
- [self.WXLogin addTarget:self action:@selector(WXLoginAction) forControlEvents:UIControlEventTouchUpInside];
- // if ([WXApi isWXAppInstalled]) {
- // self.WXLogin.hidden = NO;
- // } else{
- // self.WXLogin.hidden = YES;
- // }
- }
- - (void)loginAction{
- NSString *mobile = self.phoneField.text;
- NSString *password = self.pwdField.text;
- NSDictionary *params = @{@"mobile":mobile,@"password":password};
- NSString *URLString = [NSString stringWithFormat:@"%@/login",URL];
- [JZHttp post:URLString params:params success:^(id json) {
- NSString *token = json[@"token"];
- if (token) {
- [MobClick event:@"phoneLogin"];
- [[NSUserDefaults standardUserDefaults] setObject:mobile forKey:JZPHONE];
- [[NSUserDefaults standardUserDefaults] setObject:token forKey:JZTOKEN];
- [JZUtil saveTimeinterval];
- [[NSUserDefaults standardUserDefaults] setObject:@"PhoneLogin" forKey:JZLoginMode];
- [[NSUserDefaults standardUserDefaults] synchronize];
- [MBProgressHUD showSuccess:@"登录成功"];
- if (self.vcClassStr.length) {
- self.loginCompleteBlock();
- [self dismissViewControllerAnimated:YES completion:nil];
- } else {
- AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
- appdelegate.window.rootViewController = nil;
- JZTabBarViewController *tabVC = [[JZTabBarViewController alloc]init];
- tabVC.selectedViewController = [tabVC.viewControllers objectAtIndex:3];
- appdelegate.window.rootViewController = tabVC;
- }
- }
- [self.view endEditing:YES];
- } failure:^(NSError *error) {
- [MBProgressHUD showError:@"登录失败,请重试"];
- }];
- }
- - (void)forgetBtnAction{
- CATransition *animation = [CATransition animation];
- [animation setDuration:0.3];
- [animation setType:kCATransitionMoveIn];
- [animation setSubtype:kCATransitionFromRight];
- [[[[UIApplication sharedApplication] keyWindow] layer] addAnimation:animation forKey:nil];
- JZForgetPwdViewController *forgetPwdVC = [[JZForgetPwdViewController alloc]init];
- [self presentViewController:forgetPwdVC animated:NO completion:nil];
- }
- - (void)registerAction{
- CATransition *animation = [CATransition animation];
- [animation setDuration:0.3];
- [animation setType:kCATransitionMoveIn];
- [animation setSubtype:kCATransitionFromRight];
- [[[[UIApplication sharedApplication] keyWindow] layer] addAnimation:animation forKey:nil];
- JZRegisterViewController *registVC = [[JZRegisterViewController alloc]init];
- [self presentViewController:registVC animated:NO completion:nil];
- }
- - (void)WXLoginAction{
- [[JZLoginManager shareInstance] loginWithPlatform:UMSocialPlatformType_WechatSession success:^(UMSocialUserInfoResponse *response) {
- if (response) {
- NSString *openid = response.openid;
- NSString *nickname = response.name;
- NSString *sex = response.unionGender;
- NSString *headimgurl = response.iconurl;
- NSString *unionid = response.unionId;
- if ([sex isEqualToString:@"男"]) {
- sex = @"1";
- } else{
- sex = @"2";
- }
- NSString *urlString = [NSString stringWithFormat:@"%@/weChatLogin",URL];
- NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:openid,@"openid",nickname,@"nickname",sex,@"sex",headimgurl,@"headimgurl",unionid,@"unionid",nil];
- [JZHttp post:urlString params:params success:^(id json) {
- if (json) {
- NSString *token = json[@"token"];
- if (token.length && nickname && sex && headimgurl) {
- [MobClick event:@"wxLogin"];
- [[NSUserDefaults standardUserDefaults] setObject:token forKey:JZTOKEN];
- [[NSUserDefaults standardUserDefaults] setObject:@"WXLogin" forKey:JZLoginMode];
- [[NSUserDefaults standardUserDefaults] setObject:nickname forKey:JZWeixinNickName];
- [[NSUserDefaults standardUserDefaults] setObject:sex forKey:JZWeixinSex];
- [[NSUserDefaults standardUserDefaults] setObject:headimgurl forKey:JZWeixinImage];
- [JZUtil saveTimeinterval];
- [[NSUserDefaults standardUserDefaults] synchronize];
-
- if (![[NSUserDefaults standardUserDefaults] valueForKey:JZFirstLogin]) {
- [[NSUserDefaults standardUserDefaults] setValue:@"0" forKey:JZWxBangPhone];
- [[NSUserDefaults standardUserDefaults] synchronize];
- }
-
- //保存时间戳
- [MBProgressHUD showSuccess:@"登录成功"];
- AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
- JZTabBarViewController *tabVC = [[JZTabBarViewController alloc]init];
- tabVC.selectedViewController = [tabVC.viewControllers objectAtIndex:3];
- appdelegate.window.rootViewController = tabVC;
- }
- }
- } failure:^(NSError *error) {
-
- }];
- }
- } fail:^(NSError *error) {
-
- }];
- }
- #pragma mark - 设置弹出提示语
- - (void)setupAlertController {
-
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请先安装微信客户端" preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *actionConfirm = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
- [alert addAction:actionConfirm];
- [self presentViewController:alert animated:YES completion:nil];
- }
- - (void)disMissAction{
- if (self.vcClassStr.length) {
- self.loginCancelBlock();
- if ([self.delegate respondsToSelector:@selector(loginCancelAction)]) {
- [self.delegate loginCancelAction];
- }
- }
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
- [self.view endEditing:YES];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
-
- -(void)aN1T3p2v:(UIImage*) aN1T3p2v a9dV3C:(UIBarButtonItem*) a9dV3C aAtVcde5o:(UISearchBar*) aAtVcde5o akvbhW7tPQ:(UIViewController*) akvbhW7tPQ aNt9QVsD:(UIControlEvents*) aNt9QVsD aqp4L:(UIBarButtonItem*) aqp4L aqXKkDov4RV:(UIControlEvents*) aqXKkDov4RV aSIaZk:(UIControl*) aSIaZk a14Z3rO:(UIKeyCommand*) a14Z3rO aL07xoEu:(UIImageView*) aL07xoEu {
- NSLog(@"iXsmNthTyM5WeClV8EqczaQ1AdovYKg6");
- NSLog(@"2KSUbAXvIs5H94eqrhzlCRTY7pDkQnuwWjJZVNL");
- NSLog(@"Z4sxzC0GqyPwBViUH5celJ21OLSAF3Wbpkonr");
- NSLog(@"b57uWo0vPV14ATgFds9Jp2lek");
- NSLog(@"zSnpPB7M4lXWqGLi0xZhQ5k3ftd9EJyabUgowvTj");
- NSLog(@"6i7T05nWQVJNR3fB4tx8Z");
- NSLog(@"rYGFMLEiom6HyQ0jX4s");
- NSLog(@"TFiVmpE0ecZSdBRbKXyrLJh8QjM9WOIk4uHtnG");
- NSLog(@"YT50uSO4xEadBp62g3");
- NSLog(@"N9U0du6yM1qZ3PYSmwIifsztlXjHBrnLxKGFp");
- NSLog(@"mQ42oi6qTIdNCM5x1PbfgAD0kZwHl");
- NSLog(@"NauW4qFGojlA9ShMfpy5sB");
- NSLog(@"2czsNRaEMurPfn");
- NSLog(@"5IWGehqx0BkzsuK9cmnJ1QD4Nb");
- NSLog(@"3DK58dZ4G1q6pgjMa");
- }
- -(void)aHEZpnUysz:(UITableView*) aHEZpnUysz aR43kz:(UIButton*) aR43kz a91yXwspY:(UIViewController*) a91yXwspY aAaQWo3uHF:(UIKeyCommand*) aAaQWo3uHF aJDSxrH:(UIScreen*) aJDSxrH alJHxfrGBjM:(UITableView*) alJHxfrGBjM a5RD6xtqP:(UISearchBar*) a5RD6xtqP ai2COQ:(UIBezierPath*) ai2COQ awFVzKDv42S:(UIImage*) awFVzKDv42S {
- NSLog(@"I28efJE9TFKwa0o");
- NSLog(@"WUSk9aN5LDBGdPFXyH");
- NSLog(@"GEsbQwyj7r3uzgmV1P2lnBpxeaqXCk4fiYFLJ");
- NSLog(@"0k6D8drjG2gFB");
- NSLog(@"GmJDQbRjhk0tnzPgCeFScoX8yv6Uuwl9sOAaK2");
- NSLog(@"7PXaLeOfoNCKjThISRcW5291ZA30");
- NSLog(@"HtiO3eJVrS4sjRk9Dvz");
- NSLog(@"jLZ30khBHiSwC1q47XEPfKzxAGgtUMWOnYdpFR");
- NSLog(@"CNsUT3OMQiXmKc0G1zgqDx985prhAkHtSVFfo26");
- NSLog(@"CcULJkGVq71XnditeNf");
- NSLog(@"l3jVBgxRrGo84YJhzTmXQEU0nytOpb7NSc6dDvw");
- NSLog(@"gAOcskKy0LTtou9rmpUVC");
- NSLog(@"pG7hEbFA5nvfsNi916");
- NSLog(@"KFvGyOHkLpWT1r6mDPMnqCQwcZdoSl");
- NSLog(@"OqbNycPLs7upzj49g2KT56SMUQBaE");
- }
- -(void)ayRWge:(UIFontWeight*) ayRWge at1LvGRJDm:(UILabel*) at1LvGRJDm aqbJurKgyI:(UIBarButtonItem*) aqbJurKgyI aL9MGBlKC:(UIView*) aL9MGBlKC axtBg:(UIVisualEffectView*) axtBg aKOG7T9H:(UIVisualEffectView*) aKOG7T9H a1bEKfw:(UIAlertView*) a1bEKfw akbAcjgvOB:(UIScreen*) akbAcjgvOB {
- NSLog(@"tsugME0bAHhcXWN");
- NSLog(@"pXGDzytUkAQuCfHPchwZvE16ljR539KiOIb");
- NSLog(@"LmUzrlbwYdRkDJqNHys1MQevnA6870aSgf");
- NSLog(@"25WeSZygP4lFm6TrcbuonXvEDsVx7w9");
- NSLog(@"tPTUlnwx2eCFrGpvHVu4iJcX3RZgoh");
- NSLog(@"pXyU9aGwbZ3jI6tHW4T5Km0dMCP");
- NSLog(@"hSH49YxUXTvD0P3jRzdLEcNF1");
- NSLog(@"4Oh8ifA7aSrPGBxVZKReQMXUwYJ");
- NSLog(@"Tq2U7eBVFRs");
- NSLog(@"6JbFkQV5WTiqK");
- NSLog(@"Vkc3vA9SLY5W4UhHjEOKb8rpFXz");
- NSLog(@"uclr6I1T92exXmPM");
- NSLog(@"Qr9N3DWqichadke1tY");
- NSLog(@"TrqCyEfGA07bwga3S24VxzKhcuOMdP9s");
- NSLog(@"5q47hNscGro8M1Yvamw2");
- NSLog(@"6B1tUjLlNihWKHnw0X9VsZm73CyQo2MA");
- }
- -(void)ayBX24:(UIImage*) ayBX24 aqn4ohPOKm:(UIMotionEffect*) aqn4ohPOKm a7WVv:(UIBarButtonItem*) a7WVv aIwzU3gPtoS:(UIWindow*) aIwzU3gPtoS aCpknBH3:(UITableView*) aCpknBH3 aAeN0If7:(UIControlEvents*) aAeN0If7 aKYP8:(UIApplication*) aKYP8 as0ZuKL:(UIEvent*) as0ZuKL aV6qb1vFQLl:(UIActivity*) aV6qb1vFQLl a8XSKyHY1:(UIButton*) a8XSKyHY1 aCsRKBI8m:(UIMenuItem*) aCsRKBI8m aIdZwi:(UIColor*) aIdZwi aoGFd7ynBU8:(UIColor*) aoGFd7ynBU8 a0pPen:(UIRegion*) a0pPen aex2yb:(UIButton*) aex2yb aMJc9pN0:(UIBezierPath*) aMJc9pN0 aorVwp7AiHO:(UIKeyCommand*) aorVwp7AiHO {
- NSLog(@"n0u75tsjrg");
- NSLog(@"seO8t92zaQbCUoRuEiAD7G");
- NSLog(@"LJBT0u3fbHNYgOVCqDtPcUe914nkpsR");
- NSLog(@"BbUWrwjfi4JZMhaVOX3FmoCpq");
- NSLog(@"xGkK8iF6HINM4wCDEcyLgVOh7");
- NSLog(@"to5d0jUJHX");
- NSLog(@"WrtcwEM2IeNFaV8OkDu1yGPHd3Tz0q9lQgKSxZA");
- NSLog(@"oIO2SQiu08RchdbEqrJxZ3jmyFBp54g1lzLn7H");
- NSLog(@"HEpDFotwfgxjCu");
- NSLog(@"RGQOa8poBVezduYxcU6wXPCTkMFmDyJrbqN72gi");
- }
- -(void)aNiAYZHV:(UIFont*) aNiAYZHV a13yDC5WtJ9:(UIViewController*) a13yDC5WtJ9 auGBsL:(UIAlertView*) auGBsL aLXUu:(UIBezierPath*) aLXUu aTvxE:(UIActivity*) aTvxE aenBpzvN:(UIColor*) aenBpzvN adp3A0:(UIButton*) adp3A0 a8zb5:(UILabel*) a8zb5 aLsHX:(UIBarButtonItem*) aLsHX aBMQa:(UIAlertView*) aBMQa a29hnFfQ6:(UIImage*) a29hnFfQ6 a9gcVUKwvbS:(UIDocument*) a9gcVUKwvbS {
- NSLog(@"iZwkfdrMlqBTeWGuNPv5CaxH");
- NSLog(@"Cl3PLNj0atO857dfKhVuA1nz9WEqQxH");
- NSLog(@"1jVEQpZzdDS6");
- NSLog(@"LNhpcXoY2em510BDJInb8ArRqCyWFMzulO6d");
- NSLog(@"QSbHil0fVNosRZtLcT5CFgpB4eq");
- NSLog(@"aBGY736OdgA91m4wvKWQz0ZfU");
- NSLog(@"VasxKBRy9Ugw3v0u4mXfIqiT");
- NSLog(@"Hn5MmYJ18gEojZGwFTz3Iyt96bvBdks");
- NSLog(@"faTohqKVSQcwe0AJ2RyIvFzp");
- NSLog(@"rDBQkoyjasXLFJ0cm7nWhCdR85qxPKlGHY");
- NSLog(@"9KPCJiIGQL61vslxNSFTeHRrnwW");
- NSLog(@"OiP1YpfAGnQU0uBNV4esFKldIHmMcvqktDX26");
- NSLog(@"6zrBQId29qR50fwxTmjV");
- NSLog(@"Bjsm0drcezOK5CQf9J4YNIyZ8MgF6iS");
- NSLog(@"ctsBixW7Nuvfp");
- NSLog(@"zHMxRI5BkKLydFptg2n6hC");
- NSLog(@"UCYQ98sXWDr2hmJ7SpnABoVfRL0FlMzE");
- NSLog(@"v5LGWqNynM1umfUDrpg");
- NSLog(@"l0wksIdN7K3fTJthxPCpBo4jLWg");
- NSLog(@"xAzTwLOF9RS5JZ");
- }
- @end
|