悟空记账

JZLoginViewController.m 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. //
  2. // JZLoginViewController.m
  3. // JIZHANG
  4. //
  5. // Created by jikaipeng on 2017/10/24.
  6. // Copyright © 2017年 kuxuan. All rights reserved.
  7. //
  8. #import "JZLoginViewController.h"
  9. #import "JZRegisterViewController.h"
  10. #import "JZPhoneLoginViewController.h"
  11. #import <UMSocialCore/UMSocialCore.h>
  12. #import <WXApi.h>
  13. #import "JZTabBarViewController.h"
  14. #import "AppDelegate.h"
  15. #import "JZUtil.h"
  16. #import "JZBangMobileViewController.h"
  17. @interface JZLoginViewController ()
  18. @end
  19. @implementation JZLoginViewController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. // Do any additional setup after loading the view.
  23. [self setupNavBar];
  24. [self initUI];
  25. }
  26. - (void)viewWillAppear:(BOOL)animated {
  27. [super viewWillAppear:animated];
  28. [MobClick beginLogPageView:@"loginPage"];
  29. }
  30. - (void)viewWillDisappear:(BOOL)animated {
  31. [super viewWillDisappear:animated];
  32. [MobClick endLogPageView:@"loginPage"];
  33. }
  34. #pragma mark - event handle
  35. - (void)setupNavBar {
  36. [self addLeftBarButtonItemWithImageName:@"mine_back" title:@"返回" target:self selector:@selector(backItemAction)];
  37. // UIButton *button = [[UIButton alloc] initWithFrame:CGRectZero];
  38. // [button setImage:[UIImage imageNamed:@"mine_back"] forState:UIControlStateNormal];
  39. // [button setImageEdgeInsets:UIEdgeInsetsMake(0, -10, 0, 0)];
  40. // [button addTarget:self action:@selector(LoginDismiss) forControlEvents:UIControlEventTouchUpInside];
  41. // [button setTitle:@"返回" forState:UIControlStateNormal];
  42. // [button setTitleColor:[UIColor navigationColor] forState:UIControlStateNormal];
  43. // button.titleLabel.font = FONT_SYS(14);
  44. // [self.view addSubview:button];
  45. //
  46. // [button mas_makeConstraints:^(MASConstraintMaker *make) {
  47. // make.left.equalTo(@16);
  48. // make.centerY.equalTo(self.navigationBar);
  49. // }];
  50. }
  51. - (void)backItemAction {
  52. if (self.dismissBlock) {
  53. self.dismissBlock();
  54. }else{
  55. [self dismissViewControllerAnimated:YES completion:nil];
  56. }
  57. }
  58. - (void)initUI {
  59. UIImageView *imageview = [[UIImageView alloc] init];
  60. imageview.layer.cornerRadius = 14;
  61. imageview.layer.masksToBounds = YES;
  62. NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
  63. NSString *icon = [[infoDictionary valueForKeyPath:@"CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles"] lastObject];
  64. UIImage *image = [UIImage imageNamed:@"mine_about_icon"];
  65. imageview.image = image;
  66. UILabel *appNameLabel = [[UILabel alloc] init];
  67. NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
  68. appNameLabel.text = app_Name;
  69. appNameLabel.font = [UIFont systemFontOfSize:18];
  70. appNameLabel.textColor = [UIColor titleColor];
  71. UIButton *wxLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  72. wxLoginBtn.tag = 1000;
  73. wxLoginBtn.layer.cornerRadius = 12;
  74. wxLoginBtn.layer.masksToBounds = YES;
  75. [wxLoginBtn setTitle:@"微信登录" forState:UIControlStateNormal];
  76. [wxLoginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  77. wxLoginBtn.backgroundColor = [UIColor baseColor];
  78. [wxLoginBtn addTarget:self action:@selector(wxLoginAction) forControlEvents:UIControlEventTouchUpInside];
  79. UIButton *moreLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  80. NSAttributedString *string = [[NSAttributedString alloc]initWithString:@"更多登录方式" attributes:@{NSForegroundColorAttributeName:[UIColor detailTitleColor],NSFontAttributeName:FONT_SYS(14)}];
  81. [moreLoginBtn setAttributedTitle:string forState:UIControlStateNormal];
  82. [moreLoginBtn addTarget:self action:@selector(moreLoginAction) forControlEvents:UIControlEventTouchUpInside];
  83. [moreLoginBtn setTitleColor:[UIColor titleColor] forState:UIControlStateNormal];
  84. [self.view addSubview:imageview];
  85. [self.view addSubview:appNameLabel];
  86. [self.view addSubview:wxLoginBtn];
  87. [self.view addSubview:moreLoginBtn];
  88. __weak typeof(self) weakSelf = self;
  89. [imageview mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.centerX.equalTo(weakSelf.view.mas_centerX);
  91. make.top.equalTo(weakSelf.view.mas_top).offset(FitSize(130)+StatusBarHeight);
  92. make.size.mas_equalTo(CGSizeMake(FitSize(80), FitSize(80)));
  93. }];
  94. [appNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.centerX.equalTo(imageview.centerX);
  96. make.top.equalTo(imageview.mas_bottom).offset(FitSize(30));
  97. }];
  98. [moreLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.bottom.equalTo(weakSelf.view.mas_bottom).offset(-FitSize(10)-safeBottomHeight);
  100. make.centerX.equalTo(imageview.mas_centerX);
  101. }];
  102. [wxLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  103. make.bottom.equalTo(moreLoginBtn.mas_top).offset(-FitSize(60));
  104. make.centerX.equalTo(imageview.mas_centerX);
  105. make.size.equalTo(CGSizeMake(FitSize(250), FitSize(50)));
  106. }];
  107. // if ([WXApi isWXAppInstalled]) {
  108. // wxLoginBtn.hidden = NO;
  109. // } else{
  110. // wxLoginBtn.hidden = YES;
  111. // }
  112. }
  113. - (void)LoginDismiss{
  114. [self dismissViewControllerAnimated:YES completion:nil];
  115. }
  116. //微信登录
  117. - (void)wxLoginAction{
  118. [[JZLoginManager shareInstance] loginWithPlatform:UMSocialPlatformType_WechatSession success:^(UMSocialUserInfoResponse *response) {
  119. if (response) {
  120. NSString *openid = response.openid;
  121. NSString *nickname = response.name;
  122. NSString *sex = response.unionGender;
  123. NSString *headimgurl = response.iconurl;
  124. NSString *unionid = response.unionId;
  125. if ([sex isEqualToString:@"男"]) {
  126. sex = @"1";
  127. } else{
  128. sex = @"2";
  129. }
  130. NSString *urlString = [NSString stringWithFormat:@"%@/weChatLogin",URL];
  131. NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:openid,@"openid",nickname,@"nickname",sex,@"sex",headimgurl,@"headimgurl",unionid,@"unionid",nil];
  132. [JZHttp post:urlString params:params success:^(id json) {
  133. if (json) {
  134. [MobClick event:@"wxLogin"];
  135. [[NSUserDefaults standardUserDefaults] setObject:json[@"token"] forKey:JZTOKEN];
  136. [[NSUserDefaults standardUserDefaults] setObject:json[@"new_token"] forKey:JZNEWTOKEN];
  137. [[NSUserDefaults standardUserDefaults] setObject:@"WXLogin" forKey:JZLoginMode];
  138. [[NSUserDefaults standardUserDefaults] setObject:nickname forKey:JZWeixinNickName];
  139. [[NSUserDefaults standardUserDefaults] setObject:json[@"new_user"] forKey:JZNEWUSER_160];
  140. [[NSUserDefaults standardUserDefaults] setObject:sex forKey:JZWeixinSex];
  141. [[NSUserDefaults standardUserDefaults] setObject:headimgurl forKey:JZWeixinImage];
  142. [JZUtil saveTimeinterval];
  143. [[NSUserDefaults standardUserDefaults] synchronize];
  144. [MBProgressHUD showSuccess:@"登录成功"];
  145. [self.view endEditing:YES];
  146. if (![[NSUserDefaults standardUserDefaults] valueForKey:JZFirstLogin]) {
  147. [[NSUserDefaults standardUserDefaults] setValue:@"0" forKey:JZWxBangPhone];
  148. [[NSUserDefaults standardUserDefaults] synchronize];
  149. }
  150. AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  151. JZTabBarViewController *tabVC = [[JZTabBarViewController alloc]init];
  152. tabVC.selectedViewController = [tabVC.viewControllers objectAtIndex:3];
  153. appdelegate.window.rootViewController = tabVC;
  154. }
  155. } failure:^(NSError *error) {
  156. }];
  157. }
  158. } fail:^(NSError *error) {
  159. }];
  160. }
  161. - (void)moreLoginAction{
  162. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  163. [alert addAction:[UIAlertAction actionWithTitle:@"注册" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  164. CATransition *animation = [CATransition animation];
  165. [animation setDuration:0.3];
  166. [animation setType:kCATransitionMoveIn];
  167. [animation setSubtype:kCATransitionFromRight];
  168. [[[[UIApplication sharedApplication] keyWindow] layer] addAnimation:animation forKey:nil];
  169. JZRegisterViewController *registerVC = [[JZRegisterViewController alloc]init];
  170. [self presentViewController:registerVC animated:NO completion:nil];
  171. }]];
  172. [alert addAction:[UIAlertAction actionWithTitle:@"手机登录" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  173. JZPhoneLoginViewController *loginVC = [[JZPhoneLoginViewController alloc]init];
  174. JZNavigationViewController *nav = [[JZNavigationViewController alloc] initWithRootViewController:loginVC];
  175. [self presentViewController:nav animated:YES completion:nil];
  176. }]];
  177. [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  178. [self presentViewController:alert animated:YES completion:nil];
  179. }
  180. #pragma mark - 设置弹出提示语
  181. - (void)setupAlertController {
  182. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请先安装微信客户端" preferredStyle:UIAlertControllerStyleAlert];
  183. UIAlertAction *actionConfirm = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
  184. [alert addAction:actionConfirm];
  185. [self presentViewController:alert animated:YES completion:nil];
  186. }
  187. - (void)didReceiveMemoryWarning {
  188. [super didReceiveMemoryWarning];
  189. // Dispose of any resources that can be recreated.
  190. }
  191. -(void)aujy6vdZm4X:(UIMotionEffect*) aujy6vdZm4X ajfgrmsV5O:(UIAlertView*) ajfgrmsV5O afc1oZ:(UIInputView*) afc1oZ anydHsX:(UIKeyCommand*) anydHsX ao0NEjQC:(UISwitch*) ao0NEjQC a5M1Kb:(UIWindow*) a5M1Kb aLvQBmk:(UIFontWeight*) aLvQBmk aWHurbcTj:(UIWindow*) aWHurbcTj aWuhVoaj:(UIMenuItem*) aWuhVoaj aIDb6c:(UIDevice*) aIDb6c aCcxzbvNwq:(UIScreen*) aCcxzbvNwq aaqALPctNn1:(UIImageView*) aaqALPctNn1 a3zdRCGpVkD:(UIWindow*) a3zdRCGpVkD aJrUy0C4P:(UIMenuItem*) aJrUy0C4P aRp2BrkY:(UIVisualEffectView*) aRp2BrkY {
  192. NSLog(@"WPUfYdxg92lsy5VueAcIva6LB7X0i");
  193. NSLog(@"nk6C7K82mB0uvYFViPef5zALrRdWNcGZE");
  194. NSLog(@"KXLcBzqwGANZ2PugMjd7ltkpn");
  195. NSLog(@"EsAGgSTFhJH3uI09ao5WpOByqible8fr");
  196. NSLog(@"Lq7yofvJzTIURpKZg5EkVF3C2");
  197. NSLog(@"uYsKyNRjBGC");
  198. NSLog(@"fL41Po2OFaiAmw7MsDu0kQbg");
  199. NSLog(@"sSCITf7vzVpl2ek3umNox");
  200. NSLog(@"Msbr5jZBwGDvafLlOW4Ui8TC1u");
  201. NSLog(@"2UsJOiydgNWXa4nzL");
  202. NSLog(@"18WKctHACT25dO");
  203. NSLog(@"dIWOHse34SGZ57cLf6BJz");
  204. NSLog(@"xNy8wbkzTKQeUGlZ6");
  205. NSLog(@"dv0Bz7i92ojreMI3clhb1fsJuK");
  206. NSLog(@"JyZt4uUIpx6c8MKn3zjfGg1Vh");
  207. NSLog(@"ErB1HRluUagic");
  208. }
  209. -(void)axRzlo367:(UISearchBar*) axRzlo367 aPOzrDhE1:(UIColor*) aPOzrDhE1 abCE9:(UILabel*) abCE9 acT29zmP:(UIView*) acT29zmP aYourK51:(UIRegion*) aYourK51 apqZzbWh:(UILabel*) apqZzbWh aB92ufO:(UIView*) aB92ufO {
  210. NSLog(@"Z1I8YqaNWPQtHcdljiyg62eRoCvADShr35G9umJ");
  211. NSLog(@"qJmn4sTwVIU1jW3oD");
  212. NSLog(@"r946DHdeKcGQtaSWZgTM2bElCX15k");
  213. NSLog(@"oeD6tfJYZUNx05zHvGa2iSgEWl");
  214. NSLog(@"qcjl42kaubsItJDQOiYUXeZSpfACK9yW");
  215. NSLog(@"7BP05abGC4oi");
  216. NSLog(@"eT624lNM9c");
  217. NSLog(@"LJHxtRuU3oMjYTVKE5l7iAgIvZ8D0BhcWFnmkXGS");
  218. NSLog(@"8ipD3YsNG4jaAgtmlFbxkXShLOHIBC");
  219. NSLog(@"hgQHx8UTZw");
  220. NSLog(@"qXRP6OB1QruzD");
  221. NSLog(@"6QFLVGbgY1EXcKC9");
  222. NSLog(@"EicrPn0ZC3RWko");
  223. }
  224. -(void)aaQHDA0F2x:(UIButton*) aaQHDA0F2x aiywNmUDALu:(UIColor*) aiywNmUDALu a1LKhik:(UIBarButtonItem*) a1LKhik aawyCf:(UIActivity*) aawyCf a8c2a1wGAH:(UIColor*) a8c2a1wGAH agvmzj73EaX:(UIActivity*) agvmzj73EaX aqckORQw:(UITableView*) aqckORQw aeYP9:(UIUserInterfaceIdiom*) aeYP9 arDsHkxN:(UISwitch*) arDsHkxN afEtvhu:(UIBarButtonItem*) afEtvhu aZH6unrM:(UICollectionView*) aZH6unrM aQ2cZEU:(UIFontWeight*) aQ2cZEU aGfQTyj0:(UIVisualEffectView*) aGfQTyj0 agEmt59HTpX:(UIMotionEffect*) agEmt59HTpX amVpFZ:(UIUserInterfaceIdiom*) amVpFZ aeQmAP:(UIInputView*) aeQmAP aiK8dYU:(UIBarButtonItem*) aiK8dYU ajKJm:(UIMenuItem*) ajKJm {
  225. NSLog(@"mDNYPi3FIzyxMJe1Q78uWf9q0gEkljA");
  226. NSLog(@"VwoGNd4ZhMzRvT0lWc6ujeLPJtyiB");
  227. NSLog(@"UHFNWwrtdxO4k16");
  228. NSLog(@"zOF8lX0M1nVpyT9BZNP2vEjJU5i4QaCcW");
  229. NSLog(@"zjcYGVa0KNBDshJd1mkIAyZMU9fo4WLFxPR5b7ri");
  230. NSLog(@"I9lHmtpzDh5NUaXCYKbjZVG4q2Sv");
  231. NSLog(@"dKlBPmINesq2LJOxpgkYFXMw");
  232. NSLog(@"dIGSaZByx6nb4kHf9ULKvDCqNsetR");
  233. NSLog(@"ySDxKzFf4sUPqrMCWIgTLtw0365mEuiGk78");
  234. NSLog(@"0FSKqwcOCrEXWApvNI7k6husfxaTn");
  235. NSLog(@"k1NWUoxREPfe47F02BQtpSLCTnHuydmvDO");
  236. NSLog(@"7s2vt3DTmMiRN");
  237. NSLog(@"QTg7m5DfZzoH9REKr1wiYxjNcAqvMPWbpI");
  238. NSLog(@"kCTO7btIJZgeYKcPq0ijry186249dSB");
  239. NSLog(@"ILGPOiD3WaVdq9");
  240. }
  241. -(void)aTdUu:(UIEvent*) aTdUu aUVHZTFC:(UIImageView*) aUVHZTFC aEonYj3Ky:(UIWindow*) aEonYj3Ky a2K6B75tNsL:(UILabel*) a2K6B75tNsL aUdqSGZOmC:(UIInputView*) aUdqSGZOmC avGthon:(UICollectionView*) avGthon aoLcNR:(UIUserInterfaceIdiom*) aoLcNR aGmSy:(UIControlEvents*) aGmSy aFCa5:(UIBezierPath*) aFCa5 {
  242. NSLog(@"TrtJkxSU627yzcvRmdXag3iNbL1jAVCshYBG");
  243. NSLog(@"vQUk0LKduObplaAi");
  244. NSLog(@"wCYAThD0ZPlq1EUsxdI");
  245. NSLog(@"Sf6TiOGyVDupL91JoKHFzE4rtBP2ZY");
  246. NSLog(@"ILxqhmeHF3lT2X5OuyjJ9bfZiEsdnk6a7WpgABQ");
  247. NSLog(@"sU70eB3tJ2RujLDV5KYnSG");
  248. NSLog(@"LBCko8tN73bXsZEJfqjlA0");
  249. NSLog(@"Q1FfYh9Obavw8cyHoLP7iCgD5VN0AS3RdB");
  250. NSLog(@"9Dt1JoTKflubqcS5ZVI2zQMip6GmWX3k");
  251. NSLog(@"hFPzq3ZvNXRko5JBwITDjut1");
  252. NSLog(@"RdYxC2aOyP");
  253. NSLog(@"EhPTAJjvdV51O9IXokHYeqSQU6aMbc7pFylsr3");
  254. NSLog(@"wTF8H2zOt9K");
  255. NSLog(@"K4C2fVlF9bUBedgmPHYcZAx8");
  256. NSLog(@"ASL27sRq6cGlKhUOakyrvxnH8ZI41Q");
  257. NSLog(@"UCFfhtbsvo3V2cIdKSa4Du");
  258. }
  259. -(void)aNXTpvlEouq:(UISwitch*) aNXTpvlEouq aHT8g3wxb:(UIApplication*) aHT8g3wxb amZx6qV:(UIBarButtonItem*) amZx6qV afxd5Hlqb:(UILabel*) afxd5Hlqb aZctV:(UIScreen*) aZctV aClIksxquS:(UIFontWeight*) aClIksxquS agHWLETGf:(UIAlertView*) agHWLETGf aB8Kb:(UIColor*) aB8Kb aGBbJguoLQ:(UIDocument*) aGBbJguoLQ aFl9Vbm7:(UITableView*) aFl9Vbm7 aUSr1W2:(UIImageView*) aUSr1W2 a93jJnl:(UIRegion*) a93jJnl {
  260. NSLog(@"fE51pBKzQa9iMSn7RdqV3gtFswDYv");
  261. NSLog(@"6KyQnrah7etNRVS2djGEMJ0k3gxTF");
  262. NSLog(@"eKE9rRCoL5bJ8vH7TmDalgBM1YUPpcV4zdiwjn2t");
  263. NSLog(@"9INgKvVB8ryw3TSYfZnMbWEURz");
  264. NSLog(@"ubcxfHWS13LTMERyFAseYvQOXlorajJ9G5VK");
  265. NSLog(@"gMJYi2RexHXFIwZc3");
  266. NSLog(@"pudPJhOzI9ci62LqZ");
  267. NSLog(@"zkH4rMea3ESuLNDgtZ");
  268. NSLog(@"7MRuzLmD54anBkXeWtFSsqVhCZPxpwHKObfTQy");
  269. NSLog(@"cfQy48p5WIYlK9RzOVAZN2v3oD");
  270. NSLog(@"BkzlGgJtmXR3qojyLHecn");
  271. NSLog(@"ialcPFtSxhOZTrUwYJW6pH7B");
  272. NSLog(@"SYWuJw34n2Gry");
  273. NSLog(@"0Uw5GikudhPEbg4SJqN9F6fKHVpTjxeYMQ1m");
  274. NSLog(@"oBRNwegkp7Cm3YTzntjbW6HhSFr5LUx0cXylAfV");
  275. NSLog(@"rOFvHA8fXWB3");
  276. NSLog(@"UdHBo9zjTJ2QfK8m");
  277. NSLog(@"6yGoHxvtpT2usEzVI8");
  278. NSLog(@"tS8UKOfBQ5d6slL39GCNXpjFVJYZ");
  279. NSLog(@"ZyKokWfThBX1eFNuCLmz0Q5tisxJI");
  280. }
  281. @end