| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- //
- // LoginViewController.m
- // AICity
- //
- // Created by 刘伟伟 on 2023/7/13.
- // Copyright © 2023 wei.z. All rights reserved.
- //
- #import "LoginWithPassViewController.h"
- #import "CommonBarView.h"
- #import "AppDelegate.h"
- #import "CTTabbarController.h"
- #import "RegiestViewController.h"
- #import "ComonWKWebViewController.h"
- @interface LoginWithPassViewController ()<UITextViewDelegate>
- @property(nonatomic,strong)UIImageView *loadNetView;
- @property(nonatomic,strong)inputView2 *phone;
- @property(nonatomic,strong)inputView2 *pass;
- @end
- @implementation LoginWithPassViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- // [self.view addSubview:self.customerbar];
- [self setupUI];
- self.view.backgroundColor = rgba(18, 23, 41, 1);
- //https://www.apple.com/v/home/bc/images/logos/iphone-tradein/logo_tradein__d1fpktgipvki_large.png
- self.loadNetView = [UIImageView new];
- [self.loadNetView sd_setImageWithURL:[NSURL URLWithString:@"https://www.apple.com/v/home/bc/images/logos/iphone-tradein/logo_tradein__d1fpktgipvki_large.png"]];
-
- UITapGestureRecognizer *g = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closekeyboard)];
- [self.view addGestureRecognizer:g];
- }
- -(void)closekeyboard{
- [self.view endEditing:true];
- }
- -(UIStatusBarStyle)preferredStatusBarStyle{
- return UIStatusBarStyleLightContent;
- }
- -(void)loginAct{
- UIButton *selbtn = [self.view viewWithTag:130];
- if(!selbtn.isSelected){
- [MBProgressHUD showMessage:@"请仔细阅读并同意《用户协议》和《隐私政策》"];
- return;
- }
- [RequestTool post:@"user/userLogin" params:@{@"account":self.phone.tf.text,@"password":self.pass.tf.text} success:^(id responseObject) {
- NSLog(@"user/userLogin-%@",responseObject);
- if([responseObject[@"code"] intValue] == 0 || [responseObject[@"code"] intValue] == 200){
- [[NSUserDefaults standardUserDefaults] setValue:responseObject[@"data"] forKey:@"existUserData"];
- AppDelegate *myDelegate =(AppDelegate *) [[UIApplication sharedApplication] delegate];
- CTTabbarController *vtab=[[CTTabbarController alloc] init];
- myDelegate.window.rootViewController=vtab;
- }else{
- [MBProgressHUD showMessage:responseObject[@"msg"]];
- }
- } failure:^(NSError *error) {
- NSLog(@"%@",error);
- }];
- }
- -(void)setupUI{
- UILabel *n = [UILabel new];
- n.text = @"用户登录";
- n.font = [UIFont systemFontOfSize:24];
- n.textColor = rgba(255, 255, 255, 1);
- [self.view addSubview:n];
- [n mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view).offset(40);
- make.top.equalTo(self.view).offset(152);
- }];
-
- inputView2 *phone = [inputView2 new];
- self.phone = phone;
- phone.type = 0;
- [self.view addSubview:phone];
- [phone mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.equalTo(self.view);
- make.top.equalTo(n.mas_bottom).offset(96);
- make.height.mas_equalTo(@35);
- }];
-
- inputView2 *pass = [inputView2 new];
- self.pass = pass;
- pass.type = 1;
- pass.tapBlock = ^{
-
- };
- [self.view addSubview:pass];
- [pass mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.equalTo(self.view);
- make.top.equalTo(phone.mas_bottom).offset(37);
- make.height.mas_equalTo(@35);
- }];
-
- UILabel *lab = [UILabel new];
- lab.text = @"还没有账号,点击注册?";
- lab.textColor = rgba(255, 255, 255, 0.4);
- lab.font = [UIFont systemFontOfSize:12];
- [self.view addSubview:lab];
- UITapGestureRecognizer *g= [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(regAct)];
- lab.userInteractionEnabled = true;
- [lab addGestureRecognizer:g];
- // lab.hidden = true;
- [lab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.view).offset(-40);
- make.top.equalTo(pass.mas_bottom).offset(8);
- }];
-
- UIButton *btn = [UIButton new];
- [btn setBackgroundImage:[UIImage imageNamed:@"Rectangle 19465"] forState:UIControlStateNormal];
- [btn setTitle:@"登录" forState:UIControlStateNormal];
- [btn setTitleColor:rgba(18, 23, 41, 0.5) forState:UIControlStateNormal];
- btn.titleLabel.font = [UIFont systemFontOfSize:16];
- [btn addTarget:self action:@selector(loginAct) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:btn];
- [btn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view).offset(40);
- make.right.equalTo(self.view).offset(-40);
- make.height.mas_equalTo(@48);
- make.top.equalTo(pass.mas_bottom).offset(56);
- }];
-
-
- NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:@"已仔细阅读并同意"];
- [attributedStr addAttribute:NSForegroundColorAttributeName value:rgba(255, 255, 255, 0.4) range:NSMakeRange(0, attributedStr.length)];
- [attributedStr addAttribute:NSFontAttributeName value:[UIFont italicSystemFontOfSize:12.0] range:NSMakeRange(0, attributedStr.length)];
-
- NSMutableAttributedString *attributedStr2 = [[NSMutableAttributedString alloc] initWithString:@"《用户协议》"];
- [attributedStr2 addAttribute:NSForegroundColorAttributeName value:rgba(255, 255, 255, 1) range:NSMakeRange(0, attributedStr2.length)];
- [attributedStr2 addAttribute:NSFontAttributeName value:[UIFont italicSystemFontOfSize:12.0] range:NSMakeRange(0, attributedStr2.length)];
- NSURL *baiduURL = [NSURL URLWithString:@"privateProtocal://www.com"];
- [attributedStr2 addAttribute:NSLinkAttributeName value:baiduURL range:NSMakeRange(0, attributedStr2.length)];
-
- NSMutableAttributedString *attributedStr3 = [[NSMutableAttributedString alloc] initWithString:@"和"];
- [attributedStr3 addAttribute:NSForegroundColorAttributeName value:rgba(255, 255, 255, 0.4) range:NSMakeRange(0, attributedStr3.length)];
- [attributedStr3 addAttribute:NSFontAttributeName value:[UIFont italicSystemFontOfSize:12.0] range:NSMakeRange(0, attributedStr3.length)];
-
- NSMutableAttributedString *attributedStr4 = [[NSMutableAttributedString alloc] initWithString:@"《隐私政策》"];
- [attributedStr4 addAttribute:NSForegroundColorAttributeName value:rgba(255, 255, 255, 1) range:NSMakeRange(0, attributedStr4.length)];
- [attributedStr4 addAttribute:NSFontAttributeName value:[UIFont italicSystemFontOfSize:12.0] range:NSMakeRange(0, attributedStr4.length)];
- NSURL *baiduURL2 = [NSURL URLWithString:@"privacyPolicy://www.com"];
- [attributedStr4 addAttribute:NSLinkAttributeName value:baiduURL2 range:NSMakeRange(0, attributedStr4.length)];
-
-
-
- [attributedStr appendAttributedString:attributedStr2];
- [attributedStr appendAttributedString:attributedStr3];
- [attributedStr appendAttributedString:attributedStr4];
-
-
- UITextView *lab2 = [UITextView new];
- lab2.backgroundColor = [UIColor clearColor];
- lab2.attributedText = attributedStr;
- lab2.textAlignment = NSTextAlignmentCenter;
- lab2.linkTextAttributes = @{NSForegroundColorAttributeName:rgba(255, 255, 255, 1)};
- lab2.delegate = self;
- lab2.editable = NO;
- lab2.scrollEnabled = NO;
- // lab2.selectable = NO;
- // lab.textColor = rgba(255, 255, 255, 0.4);
- // lab.font = [UIFont systemFontOfSize:12];
- [self.view addSubview:lab2];
- [lab2 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.view).offset(7);
- make.top.equalTo(btn.mas_bottom).offset(12);
- make.width.mas_equalTo(@270);
- // make.height.mas_equalTo(@15);
- }];
-
-
- UIButton *selbtn = [UIButton new];
- selbtn.tag = 130;
- [selbtn setBackgroundImage:[UIImage imageNamed:@"login_cirle"] forState:UIControlStateNormal];
- [selbtn setBackgroundImage:[UIImage imageNamed:@"login_chick"] forState:UIControlStateSelected];
- [self.view addSubview:selbtn];
- [selbtn addTarget:self action:@selector(changeSelState) forControlEvents:UIControlEventTouchUpInside];
- [selbtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(lab2.mas_left).offset(-2);
- make.size.mas_equalTo(CGSizeMake(12, 12));
- make.centerY.equalTo(lab2);
- }];
-
- UIButton *selbtn2 = [UIButton new];
- [self.view addSubview:selbtn2];
- [selbtn2 addTarget:self action:@selector(changeSelState) forControlEvents:UIControlEventTouchUpInside];
- [selbtn2 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.size.mas_equalTo(CGSizeMake(30, 30));
- make.center.equalTo(selbtn);
- }];
- }
- -(void)regAct{
- RegiestViewController *vc =[RegiestViewController new];
- vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
- [self presentViewController:vc animated:YES completion:^{
-
- }];
- }
- -(void)changeSelState{
- UIButton *selbtn = [self.view viewWithTag:130];
- selbtn.selected = !selbtn.isSelected;
- }
- -(BOOL)textView:(UITextView *)textView shouldInteractWithURL:(nonnull NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction
- {
- if ([[URL scheme] isEqualToString:@"privateProtocal"]) {
- NSLog(@"看天用户协议");
- //用户协议
- ComonWKWebViewController *vc =[[ComonWKWebViewController alloc] init];
- vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
- vc.title = @"用户协议";
- vc.url = @"https://backend.jsnoopyay.com/user_agreement.html";
- [self presentViewController:vc animated:YES completion:nil];
- return NO;
- } else if ([[URL scheme] isEqualToString:@"privacyPolicy"]) {
- NSLog(@"隐私协议");
- ComonWKWebViewController *vc =[[ComonWKWebViewController alloc] init];
- vc.title = @"隐私协议";
- vc.url = @"https://backend.jsnoopyay.com/unregister.html";
- [self presentViewController:vc animated:YES completion:nil];
- return NO;
- }
- return YES;
- }
- //-(CommonBarView *)customerbar{
- // if(!_customerbar){
- // CGFloat h=0;
- // if(@available(iOS 13.0, *)){
- // UIStatusBarManager *sc= [UIApplication sharedApplication].windows.firstObject.windowScene.statusBarManager;
- // CGRect f=sc.statusBarFrame;
- // h=f.size.height;
- // }else{
- // h=[UIApplication sharedApplication].statusBarFrame.size.height;
- // }
- // if(h>=40){
- // h=30;
- // }
- // _customerbar =[[CommonBarView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 72-20+h)];
- // _customerbar.bgView.backgroundColor = [UIColor clearColor];
- // _customerbar.label.text=@"手机号登录";
- // _customerbar.bgView.alpha = 1;
- // _customerbar.label.textColor = rgba(255, 255, 255, 1);
- // }
- // return _customerbar;
- //}
- @end
- @interface inputView2()
- @property(nonatomic,strong)NSTimer *mytime;
- @property(nonatomic,assign)int second;
- @end
- @implementation inputView2
- - (instancetype)init
- {
- self = [super init];
- if (self) {
- self.second = 60;
- }
- return self;
- }
- //0手机号 1密码
- -(void)setType:(int)type{
- _type = type;
- [self initView:type];
- }
- - (void)initView:(int)type{
- UIImageView *iv = [UIImageView new];
- if(type == 0){
- iv.image = [UIImage imageNamed:@"Casino22"];
- }else{
- iv.image = [UIImage imageNamed:@"Casino2"];
- }
- [self addSubview:iv];
- [iv mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self).offset(40);
- make.top.equalTo(self);
- make.size.mas_equalTo(CGSizeMake(20, 20));
- }];
-
-
- UITextField *tf =[UITextField new];
- self.tf = tf;
- [tf addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
- NSString *str=@"";
- if(type == 0){
- str=@"用户名";
- }else{
- str=@"请输入密码";
- tf.secureTextEntry = YES;
- }
- NSMutableAttributedString *attributedPlaceholder = [[NSMutableAttributedString alloc] initWithString:str];
- [attributedPlaceholder addAttribute:NSForegroundColorAttributeName value:rgba(255, 255, 255, 0.2) range:NSMakeRange(0, attributedPlaceholder.length)];
- [attributedPlaceholder addAttribute:NSFontAttributeName value:[UIFont italicSystemFontOfSize:14.0] range:NSMakeRange(0, attributedPlaceholder.length)];
- tf.attributedPlaceholder = attributedPlaceholder;
- tf.textColor = [UIColor whiteColor];
- tf.font = [UIFont italicSystemFontOfSize:14.0];
- [self addSubview:tf];
-
-
- [tf mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(iv.mas_right).offset(12);
- make.centerY.equalTo(iv);
- make.size.mas_equalTo(CGSizeMake(200, 20));
- }];
- // if(type == 0){
- // UILabel *lab = [UILabel new];
- // lab.text = @"+86";
- // lab.textColor = rgba(255, 255, 255, 0.4);
- // lab.font = [UIFont systemFontOfSize:14];
- // [self addSubview:lab];
- // [lab mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.equalTo(iv.mas_right).offset(12);
- // make.centerY.equalTo(iv);
- // }];
- //
- // [tf mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.equalTo(lab.mas_right).offset(8);
- // make.centerY.equalTo(iv);
- // make.size.mas_equalTo(CGSizeMake(200, 20));
- // }];
- // }else{
- // [tf mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.equalTo(iv.mas_right).offset(12);
- // make.centerY.equalTo(iv);
- // make.size.mas_equalTo(CGSizeMake(200, 20));
- // }];
- //
- // UIButton *showP =[UIButton new];
- // [showP setTitle:@"获取验证码" forState:UIControlStateNormal];
- // [showP setTitleColor:rgba(255, 212, 0, 1) forState:UIControlStateNormal];
- // showP.titleLabel.font = [UIFont systemFontOfSize:14];
- // [showP addTarget:self action:@selector(getCode:) forControlEvents:UIControlEventTouchUpInside];
- // [self addSubview:showP];
- // [showP mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.right.equalTo(self).offset(-40);
- // make.centerY.equalTo(iv);
- // make.size.mas_equalTo(CGSizeMake(80, 20));
- // }];
- // }
-
-
-
-
- UIView *line = [UIView new];
- line.backgroundColor = rgba(255, 255, 255, 0.2);
- [self addSubview:line];
- [line mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(iv);
- make.right.equalTo(self).offset(-40);
- make.bottom.equalTo(self);
- make.height.mas_equalTo(@1);
- }];
- }
- - (void)textFieldDidChange:(UITextField *)textField
- {
- if(textField.text.length>16){
- textField.text = [textField.text substringToIndex:16];
- }
- }
- //-(void)getCode:(UIButton *)showP{
- // if(self.mytime){
- // return;
- // }
- // self.mytime = [NSTimer scheduledTimerWithTimeInterval:1.0 repeats:YES block:^(NSTimer * _Nonnull timer) {
- // [showP setTitle:[NSString stringWithFormat:@"%ds",self.second] forState:UIControlStateNormal];
- // self.second -=1;
- // if(self.second <= -1){
- // [self.mytime invalidate];
- // self.mytime = nil;
- // self.second = 60;
- // [showP setTitle:@"获取验证码" forState:UIControlStateNormal];
- // }
- // }];
- //
- // if(self.tapBlock){
- // self.tapBlock();
- // }
- //}
- @end
|