LoginWithPassViewController.m 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. //
  2. // LoginViewController.m
  3. // AICity
  4. //
  5. // Created by 刘伟伟 on 2023/7/13.
  6. // Copyright © 2023 wei.z. All rights reserved.
  7. //
  8. #import "LoginWithPassViewController.h"
  9. #import "CommonBarView.h"
  10. #import "AppDelegate.h"
  11. #import "CTTabbarController.h"
  12. #import "RegiestViewController.h"
  13. #import "ComonWKWebViewController.h"
  14. @interface LoginWithPassViewController ()<UITextViewDelegate>
  15. @property(nonatomic,strong)UIImageView *loadNetView;
  16. @property(nonatomic,strong)inputView2 *phone;
  17. @property(nonatomic,strong)inputView2 *pass;
  18. @end
  19. @implementation LoginWithPassViewController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. // Do any additional setup after loading the view.
  23. // [self.view addSubview:self.customerbar];
  24. [self setupUI];
  25. self.view.backgroundColor = rgba(18, 23, 41, 1);
  26. //https://www.apple.com/v/home/bc/images/logos/iphone-tradein/logo_tradein__d1fpktgipvki_large.png
  27. self.loadNetView = [UIImageView new];
  28. [self.loadNetView sd_setImageWithURL:[NSURL URLWithString:@"https://www.apple.com/v/home/bc/images/logos/iphone-tradein/logo_tradein__d1fpktgipvki_large.png"]];
  29. UITapGestureRecognizer *g = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closekeyboard)];
  30. [self.view addGestureRecognizer:g];
  31. }
  32. -(void)closekeyboard{
  33. [self.view endEditing:true];
  34. }
  35. -(UIStatusBarStyle)preferredStatusBarStyle{
  36. return UIStatusBarStyleLightContent;
  37. }
  38. -(void)loginAct{
  39. UIButton *selbtn = [self.view viewWithTag:130];
  40. if(!selbtn.isSelected){
  41. [MBProgressHUD showMessage:@"请仔细阅读并同意《用户协议》和《隐私政策》"];
  42. return;
  43. }
  44. [RequestTool post:@"user/userLogin" params:@{@"account":self.phone.tf.text,@"password":self.pass.tf.text} success:^(id responseObject) {
  45. NSLog(@"user/userLogin-%@",responseObject);
  46. if([responseObject[@"code"] intValue] == 0 || [responseObject[@"code"] intValue] == 200){
  47. [[NSUserDefaults standardUserDefaults] setValue:responseObject[@"data"] forKey:@"existUserData"];
  48. AppDelegate *myDelegate =(AppDelegate *) [[UIApplication sharedApplication] delegate];
  49. CTTabbarController *vtab=[[CTTabbarController alloc] init];
  50. myDelegate.window.rootViewController=vtab;
  51. }else{
  52. [MBProgressHUD showMessage:responseObject[@"msg"]];
  53. }
  54. } failure:^(NSError *error) {
  55. NSLog(@"%@",error);
  56. }];
  57. }
  58. -(void)setupUI{
  59. UILabel *n = [UILabel new];
  60. n.text = @"用户登录";
  61. n.font = [UIFont systemFontOfSize:24];
  62. n.textColor = rgba(255, 255, 255, 1);
  63. [self.view addSubview:n];
  64. [n mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.left.equalTo(self.view).offset(40);
  66. make.top.equalTo(self.view).offset(152);
  67. }];
  68. inputView2 *phone = [inputView2 new];
  69. self.phone = phone;
  70. phone.type = 0;
  71. [self.view addSubview:phone];
  72. [phone mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.left.right.equalTo(self.view);
  74. make.top.equalTo(n.mas_bottom).offset(96);
  75. make.height.mas_equalTo(@35);
  76. }];
  77. inputView2 *pass = [inputView2 new];
  78. self.pass = pass;
  79. pass.type = 1;
  80. pass.tapBlock = ^{
  81. };
  82. [self.view addSubview:pass];
  83. [pass mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.left.right.equalTo(self.view);
  85. make.top.equalTo(phone.mas_bottom).offset(37);
  86. make.height.mas_equalTo(@35);
  87. }];
  88. UILabel *lab = [UILabel new];
  89. lab.text = @"还没有账号,点击注册?";
  90. lab.textColor = rgba(255, 255, 255, 0.4);
  91. lab.font = [UIFont systemFontOfSize:12];
  92. [self.view addSubview:lab];
  93. UITapGestureRecognizer *g= [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(regAct)];
  94. lab.userInteractionEnabled = true;
  95. [lab addGestureRecognizer:g];
  96. // lab.hidden = true;
  97. [lab mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.right.equalTo(self.view).offset(-40);
  99. make.top.equalTo(pass.mas_bottom).offset(8);
  100. }];
  101. UIButton *btn = [UIButton new];
  102. [btn setBackgroundImage:[UIImage imageNamed:@"Rectangle 19465"] forState:UIControlStateNormal];
  103. [btn setTitle:@"登录" forState:UIControlStateNormal];
  104. [btn setTitleColor:rgba(18, 23, 41, 0.5) forState:UIControlStateNormal];
  105. btn.titleLabel.font = [UIFont systemFontOfSize:16];
  106. [btn addTarget:self action:@selector(loginAct) forControlEvents:UIControlEventTouchUpInside];
  107. [self.view addSubview:btn];
  108. [btn mas_makeConstraints:^(MASConstraintMaker *make) {
  109. make.left.equalTo(self.view).offset(40);
  110. make.right.equalTo(self.view).offset(-40);
  111. make.height.mas_equalTo(@48);
  112. make.top.equalTo(pass.mas_bottom).offset(56);
  113. }];
  114. NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:@"已仔细阅读并同意"];
  115. [attributedStr addAttribute:NSForegroundColorAttributeName value:rgba(255, 255, 255, 0.4) range:NSMakeRange(0, attributedStr.length)];
  116. [attributedStr addAttribute:NSFontAttributeName value:[UIFont italicSystemFontOfSize:12.0] range:NSMakeRange(0, attributedStr.length)];
  117. NSMutableAttributedString *attributedStr2 = [[NSMutableAttributedString alloc] initWithString:@"《用户协议》"];
  118. [attributedStr2 addAttribute:NSForegroundColorAttributeName value:rgba(255, 255, 255, 1) range:NSMakeRange(0, attributedStr2.length)];
  119. [attributedStr2 addAttribute:NSFontAttributeName value:[UIFont italicSystemFontOfSize:12.0] range:NSMakeRange(0, attributedStr2.length)];
  120. NSURL *baiduURL = [NSURL URLWithString:@"privateProtocal://www.com"];
  121. [attributedStr2 addAttribute:NSLinkAttributeName value:baiduURL range:NSMakeRange(0, attributedStr2.length)];
  122. NSMutableAttributedString *attributedStr3 = [[NSMutableAttributedString alloc] initWithString:@"和"];
  123. [attributedStr3 addAttribute:NSForegroundColorAttributeName value:rgba(255, 255, 255, 0.4) range:NSMakeRange(0, attributedStr3.length)];
  124. [attributedStr3 addAttribute:NSFontAttributeName value:[UIFont italicSystemFontOfSize:12.0] range:NSMakeRange(0, attributedStr3.length)];
  125. NSMutableAttributedString *attributedStr4 = [[NSMutableAttributedString alloc] initWithString:@"《隐私政策》"];
  126. [attributedStr4 addAttribute:NSForegroundColorAttributeName value:rgba(255, 255, 255, 1) range:NSMakeRange(0, attributedStr4.length)];
  127. [attributedStr4 addAttribute:NSFontAttributeName value:[UIFont italicSystemFontOfSize:12.0] range:NSMakeRange(0, attributedStr4.length)];
  128. NSURL *baiduURL2 = [NSURL URLWithString:@"privacyPolicy://www.com"];
  129. [attributedStr4 addAttribute:NSLinkAttributeName value:baiduURL2 range:NSMakeRange(0, attributedStr4.length)];
  130. [attributedStr appendAttributedString:attributedStr2];
  131. [attributedStr appendAttributedString:attributedStr3];
  132. [attributedStr appendAttributedString:attributedStr4];
  133. UITextView *lab2 = [UITextView new];
  134. lab2.backgroundColor = [UIColor clearColor];
  135. lab2.attributedText = attributedStr;
  136. lab2.textAlignment = NSTextAlignmentCenter;
  137. lab2.linkTextAttributes = @{NSForegroundColorAttributeName:rgba(255, 255, 255, 1)};
  138. lab2.delegate = self;
  139. lab2.editable = NO;
  140. lab2.scrollEnabled = NO;
  141. // lab2.selectable = NO;
  142. // lab.textColor = rgba(255, 255, 255, 0.4);
  143. // lab.font = [UIFont systemFontOfSize:12];
  144. [self.view addSubview:lab2];
  145. [lab2 mas_makeConstraints:^(MASConstraintMaker *make) {
  146. make.centerX.equalTo(self.view).offset(7);
  147. make.top.equalTo(btn.mas_bottom).offset(12);
  148. make.width.mas_equalTo(@270);
  149. // make.height.mas_equalTo(@15);
  150. }];
  151. UIButton *selbtn = [UIButton new];
  152. selbtn.tag = 130;
  153. [selbtn setBackgroundImage:[UIImage imageNamed:@"login_cirle"] forState:UIControlStateNormal];
  154. [selbtn setBackgroundImage:[UIImage imageNamed:@"login_chick"] forState:UIControlStateSelected];
  155. [self.view addSubview:selbtn];
  156. [selbtn addTarget:self action:@selector(changeSelState) forControlEvents:UIControlEventTouchUpInside];
  157. [selbtn mas_makeConstraints:^(MASConstraintMaker *make) {
  158. make.right.equalTo(lab2.mas_left).offset(-2);
  159. make.size.mas_equalTo(CGSizeMake(12, 12));
  160. make.centerY.equalTo(lab2);
  161. }];
  162. UIButton *selbtn2 = [UIButton new];
  163. [self.view addSubview:selbtn2];
  164. [selbtn2 addTarget:self action:@selector(changeSelState) forControlEvents:UIControlEventTouchUpInside];
  165. [selbtn2 mas_makeConstraints:^(MASConstraintMaker *make) {
  166. make.size.mas_equalTo(CGSizeMake(30, 30));
  167. make.center.equalTo(selbtn);
  168. }];
  169. }
  170. -(void)regAct{
  171. RegiestViewController *vc =[RegiestViewController new];
  172. vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
  173. [self presentViewController:vc animated:YES completion:^{
  174. }];
  175. }
  176. -(void)changeSelState{
  177. UIButton *selbtn = [self.view viewWithTag:130];
  178. selbtn.selected = !selbtn.isSelected;
  179. }
  180. -(BOOL)textView:(UITextView *)textView shouldInteractWithURL:(nonnull NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction
  181. {
  182. if ([[URL scheme] isEqualToString:@"privateProtocal"]) {
  183. NSLog(@"看天用户协议");
  184. //用户协议
  185. ComonWKWebViewController *vc =[[ComonWKWebViewController alloc] init];
  186. vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
  187. vc.title = @"用户协议";
  188. vc.url = @"https://backend.jsnoopyay.com/user_agreement.html";
  189. [self presentViewController:vc animated:YES completion:nil];
  190. return NO;
  191. } else if ([[URL scheme] isEqualToString:@"privacyPolicy"]) {
  192. NSLog(@"隐私协议");
  193. ComonWKWebViewController *vc =[[ComonWKWebViewController alloc] init];
  194. vc.title = @"隐私协议";
  195. vc.url = @"https://backend.jsnoopyay.com/unregister.html";
  196. [self presentViewController:vc animated:YES completion:nil];
  197. return NO;
  198. }
  199. return YES;
  200. }
  201. //-(CommonBarView *)customerbar{
  202. // if(!_customerbar){
  203. // CGFloat h=0;
  204. // if(@available(iOS 13.0, *)){
  205. // UIStatusBarManager *sc= [UIApplication sharedApplication].windows.firstObject.windowScene.statusBarManager;
  206. // CGRect f=sc.statusBarFrame;
  207. // h=f.size.height;
  208. // }else{
  209. // h=[UIApplication sharedApplication].statusBarFrame.size.height;
  210. // }
  211. // if(h>=40){
  212. // h=30;
  213. // }
  214. // _customerbar =[[CommonBarView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 72-20+h)];
  215. // _customerbar.bgView.backgroundColor = [UIColor clearColor];
  216. // _customerbar.label.text=@"手机号登录";
  217. // _customerbar.bgView.alpha = 1;
  218. // _customerbar.label.textColor = rgba(255, 255, 255, 1);
  219. // }
  220. // return _customerbar;
  221. //}
  222. @end
  223. @interface inputView2()
  224. @property(nonatomic,strong)NSTimer *mytime;
  225. @property(nonatomic,assign)int second;
  226. @end
  227. @implementation inputView2
  228. - (instancetype)init
  229. {
  230. self = [super init];
  231. if (self) {
  232. self.second = 60;
  233. }
  234. return self;
  235. }
  236. //0手机号 1密码
  237. -(void)setType:(int)type{
  238. _type = type;
  239. [self initView:type];
  240. }
  241. - (void)initView:(int)type{
  242. UIImageView *iv = [UIImageView new];
  243. if(type == 0){
  244. iv.image = [UIImage imageNamed:@"Casino22"];
  245. }else{
  246. iv.image = [UIImage imageNamed:@"Casino2"];
  247. }
  248. [self addSubview:iv];
  249. [iv mas_makeConstraints:^(MASConstraintMaker *make) {
  250. make.left.equalTo(self).offset(40);
  251. make.top.equalTo(self);
  252. make.size.mas_equalTo(CGSizeMake(20, 20));
  253. }];
  254. UITextField *tf =[UITextField new];
  255. self.tf = tf;
  256. [tf addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  257. NSString *str=@"";
  258. if(type == 0){
  259. str=@"用户名";
  260. }else{
  261. str=@"请输入密码";
  262. tf.secureTextEntry = YES;
  263. }
  264. NSMutableAttributedString *attributedPlaceholder = [[NSMutableAttributedString alloc] initWithString:str];
  265. [attributedPlaceholder addAttribute:NSForegroundColorAttributeName value:rgba(255, 255, 255, 0.2) range:NSMakeRange(0, attributedPlaceholder.length)];
  266. [attributedPlaceholder addAttribute:NSFontAttributeName value:[UIFont italicSystemFontOfSize:14.0] range:NSMakeRange(0, attributedPlaceholder.length)];
  267. tf.attributedPlaceholder = attributedPlaceholder;
  268. tf.textColor = [UIColor whiteColor];
  269. tf.font = [UIFont italicSystemFontOfSize:14.0];
  270. [self addSubview:tf];
  271. [tf mas_makeConstraints:^(MASConstraintMaker *make) {
  272. make.left.equalTo(iv.mas_right).offset(12);
  273. make.centerY.equalTo(iv);
  274. make.size.mas_equalTo(CGSizeMake(200, 20));
  275. }];
  276. // if(type == 0){
  277. // UILabel *lab = [UILabel new];
  278. // lab.text = @"+86";
  279. // lab.textColor = rgba(255, 255, 255, 0.4);
  280. // lab.font = [UIFont systemFontOfSize:14];
  281. // [self addSubview:lab];
  282. // [lab mas_makeConstraints:^(MASConstraintMaker *make) {
  283. // make.left.equalTo(iv.mas_right).offset(12);
  284. // make.centerY.equalTo(iv);
  285. // }];
  286. //
  287. // [tf mas_makeConstraints:^(MASConstraintMaker *make) {
  288. // make.left.equalTo(lab.mas_right).offset(8);
  289. // make.centerY.equalTo(iv);
  290. // make.size.mas_equalTo(CGSizeMake(200, 20));
  291. // }];
  292. // }else{
  293. // [tf mas_makeConstraints:^(MASConstraintMaker *make) {
  294. // make.left.equalTo(iv.mas_right).offset(12);
  295. // make.centerY.equalTo(iv);
  296. // make.size.mas_equalTo(CGSizeMake(200, 20));
  297. // }];
  298. //
  299. // UIButton *showP =[UIButton new];
  300. // [showP setTitle:@"获取验证码" forState:UIControlStateNormal];
  301. // [showP setTitleColor:rgba(255, 212, 0, 1) forState:UIControlStateNormal];
  302. // showP.titleLabel.font = [UIFont systemFontOfSize:14];
  303. // [showP addTarget:self action:@selector(getCode:) forControlEvents:UIControlEventTouchUpInside];
  304. // [self addSubview:showP];
  305. // [showP mas_makeConstraints:^(MASConstraintMaker *make) {
  306. // make.right.equalTo(self).offset(-40);
  307. // make.centerY.equalTo(iv);
  308. // make.size.mas_equalTo(CGSizeMake(80, 20));
  309. // }];
  310. // }
  311. UIView *line = [UIView new];
  312. line.backgroundColor = rgba(255, 255, 255, 0.2);
  313. [self addSubview:line];
  314. [line mas_makeConstraints:^(MASConstraintMaker *make) {
  315. make.left.equalTo(iv);
  316. make.right.equalTo(self).offset(-40);
  317. make.bottom.equalTo(self);
  318. make.height.mas_equalTo(@1);
  319. }];
  320. }
  321. - (void)textFieldDidChange:(UITextField *)textField
  322. {
  323. if(textField.text.length>16){
  324. textField.text = [textField.text substringToIndex:16];
  325. }
  326. }
  327. //-(void)getCode:(UIButton *)showP{
  328. // if(self.mytime){
  329. // return;
  330. // }
  331. // self.mytime = [NSTimer scheduledTimerWithTimeInterval:1.0 repeats:YES block:^(NSTimer * _Nonnull timer) {
  332. // [showP setTitle:[NSString stringWithFormat:@"%ds",self.second] forState:UIControlStateNormal];
  333. // self.second -=1;
  334. // if(self.second <= -1){
  335. // [self.mytime invalidate];
  336. // self.mytime = nil;
  337. // self.second = 60;
  338. // [showP setTitle:@"获取验证码" forState:UIControlStateNormal];
  339. // }
  340. // }];
  341. //
  342. // if(self.tapBlock){
  343. // self.tapBlock();
  344. // }
  345. //}
  346. @end