You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
544 lines
22 KiB
544 lines
22 KiB
// |
|
// LoginViewController.m |
|
// LekangGuard |
|
// |
|
// Created by ecell on 2022/10/8. |
|
// |
|
|
|
#import "LoginViewController.h" |
|
#import "AppDelegate.h" |
|
#import "EmailLoginViewController.h" |
|
#import "commWebViewController.h" |
|
#import "RegisterViewController.h" |
|
#import <WXApi.h> |
|
#import "SYTouchLabel.h" |
|
|
|
@interface LoginViewController ()<UITextViewDelegate,UIScrollViewDelegate> |
|
|
|
|
|
@property (nonatomic ,strong) UIScrollView *scrollView; |
|
@property (nonatomic ,strong) UIPageControl *pageControl; |
|
|
|
/// 用户协议按钮 |
|
@property (nonatomic ,weak) UIButton *agreementBtn; |
|
|
|
/// 密码View |
|
@property (nonatomic ,weak) UIView *passView; |
|
|
|
/// 手机号TextField |
|
@property (nonatomic ,weak) UITextField *phoneField; |
|
|
|
/// 密码TextField |
|
@property (nonatomic ,weak) UITextField *passField; |
|
|
|
/// 记住密码按钮 |
|
@property (nonatomic ,weak) UIButton *rememberPassBtn; |
|
|
|
/// 是否记得密码 |
|
@property (nonatomic ,assign) BOOL isRememberPWD; |
|
|
|
/// 登录 |
|
@property (nonatomic ,weak) UIButton *loginBtn; |
|
|
|
@end |
|
|
|
@implementation LoginViewController |
|
|
|
- (void)viewDidLoad { |
|
[super viewDidLoad]; |
|
// Do any additional setup after loading the view. |
|
self.view.backgroundColor = KKWhiteColorColor; |
|
self.zx_navBarBackgroundColor = KKClearColor; |
|
|
|
UIImageView *logoBgImg = [UICommon ui_imageView:CGRectZero fileName:@"login_bg"]; |
|
[self.view addSubview:logoBgImg]; |
|
[logoBgImg mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.top.equalTo(self.view); |
|
make.left.right.equalTo(self.view); |
|
make.height.mas_equalTo(logoBgImg.image.size.height); |
|
}]; |
|
|
|
UIImageView *logoImg = [UICommon ui_imageView:CGRectZero fileName:@"login_logo"]; |
|
[self.view addSubview:logoImg]; |
|
[logoImg mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.centerX.equalTo(self.view); |
|
make.top.equalTo(self.view).offset(Adapted(97)); |
|
make.size.mas_equalTo(logoImg.image.size); |
|
}]; |
|
|
|
CGFloat yy = iPhoneX_TabbarSafeBottomMargin > 0 ? AdaptedHeight(130) : AdaptedHeight(120); |
|
for (int i = 0; i < 2; i++) |
|
{ |
|
UIView *bgView = [UICommon ui_view:CGRectZero backgroundColor:KKClearColor cornerRadius:0 borderWidth:0 borderColor:KKClearColor]; |
|
if (i == 1) self.passView = bgView; |
|
[self.view addSubview:bgView]; |
|
[bgView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.right.equalTo(self.view).inset(35); |
|
make.top.equalTo(logoImg.mas_bottom).offset(yy+i*Adapted(62)); |
|
make.height.mas_equalTo(Adapted(62)); |
|
|
|
}]; |
|
|
|
UIImageView *leftImg = [UICommon ui_imageView:CGRectZero fileName:i == 0 ? @"login_phone_icon" : @"login_password_icon"]; |
|
[bgView addSubview:leftImg]; |
|
[leftImg mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(bgView).offset(0); |
|
make.centerY.equalTo(bgView); |
|
make.size.mas_equalTo(CGSizeMake(Adapted(leftImg.image.size.width), Adapted(leftImg.image.size.height))); |
|
}]; |
|
|
|
/// 密码可视或不可视按钮 |
|
UIButton *rightBtn; |
|
if (i == 1) |
|
{ |
|
rightBtn = [UICommon ui_buttonSimple:CGRectZero font:Font_(0) normalColor:KKClearColor normalText:@"" click:^(UIButton *sender) { |
|
[sender setSelected:!sender.isSelected]; |
|
self.passField.secureTextEntry = !sender.isSelected; |
|
}]; |
|
[rightBtn setImage:[UIImage imageNamed:@"login_password_icon_hidden"] forState:UIControlStateNormal]; |
|
[rightBtn setImage:[UIImage imageNamed:@"login_password_icon_show"] forState:UIControlStateSelected]; |
|
[bgView addSubview:rightBtn]; |
|
[rightBtn mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.centerY.equalTo(bgView); |
|
make.right.equalTo(bgView.mas_right); |
|
make.size.mas_equalTo(CGSizeMake(Adapted(22), Adapted(22))); |
|
}]; |
|
} |
|
|
|
|
|
UITextField *textfield = [UICommon ui_textField:CGRectZero textColor:KKTextBlackColor backColor:KKClearColor font:FontADA_(15) maxTextNum:i == 0 ? 11 : 16 placeholderColor:KKGrey143 placeholder:i == 0 ? GJText(@"请输入手机号") : GJText(@"请输入密码") toMaxNum:^(UITextField *textField) { |
|
|
|
} change:^(UITextField *textField) { |
|
|
|
}]; |
|
if (i == 0) |
|
{ |
|
textfield.keyboardType = UIKeyboardTypePhonePad; |
|
self.phoneField = textfield; |
|
} |
|
else |
|
{ |
|
textfield.secureTextEntry = YES; |
|
self.passField = textfield; |
|
} |
|
[bgView addSubview:textfield]; |
|
|
|
[textfield mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(leftImg.mas_right).offset(15); |
|
if (i == 0) |
|
make.right.equalTo(bgView).inset(15); |
|
else |
|
make.right.equalTo(rightBtn.mas_left).inset(15); |
|
make.centerY.equalTo(bgView); |
|
make.height.mas_equalTo(Adapted(44)); |
|
}]; |
|
|
|
UIImageView *line = [UIImageView new]; |
|
line.backgroundColor = KKLineColor; |
|
[bgView addSubview:line]; |
|
[line mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.right.equalTo(bgView); |
|
make.bottom.equalTo(bgView.mas_bottom); |
|
make.height.mas_equalTo(0.5); |
|
}]; |
|
} |
|
|
|
/// 登录 |
|
UIButton *loginBtn = [UICommon ui_buttonSimple:CGRectZero font:FontADA_(16) normalColor:KKWhiteColorColor normalText:GJText(@"登录") click:^(UIButton *btn) { |
|
// btn.selected = !btn.selected; |
|
[self UserLogin]; |
|
}]; |
|
[loginBtn setBackgroundImage:ImageName_(@"login_button_bg_no") forState:UIControlStateNormal]; |
|
[loginBtn setBackgroundImage:ImageName_(@"login_button_bg_select") forState:UIControlStateSelected]; |
|
[loginBtn setTitle:@"登录中" forState:UIControlStateSelected]; |
|
self.loginBtn = loginBtn; |
|
[self.view addSubview:loginBtn]; |
|
[loginBtn mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.top.equalTo(self.passView.mas_bottom).offset(AdaptedHeight(28)); |
|
make.centerX.equalTo(self.view); |
|
make.size.mas_equalTo(CGSizeMake(Adapted(230), Adapted(45))); |
|
}]; |
|
|
|
UIImageView *line = [UIImageView new]; |
|
line.backgroundColor = KKMainColor; |
|
[self.view addSubview:line]; |
|
[line mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.centerX.equalTo(self.view); |
|
make.top.equalTo(loginBtn.mas_bottom).offset(AdaptedHeight(18)); |
|
make.size.mas_equalTo(CGSizeMake(1, 16)); |
|
}]; |
|
|
|
/// 立即注册 |
|
UIButton *registerBtn = [UICommon ui_buttonSimple:CGRectZero font:FontADA_(16) normalColor:KKMainColor normalText:GJText(@"注册账号") click:^(UIButton *sender) { |
|
|
|
RegisterViewController *vc = [RegisterViewController new]; |
|
vc.navTitle = @"注册"; |
|
vc.isViewType = 0; |
|
vc.isRegisterSuccess = ^{ |
|
//[self aucnTexg]; |
|
}; |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
}]; |
|
[self.view addSubview:registerBtn]; |
|
|
|
CGRect rect1 = [UICommon GetTextWidth:registerBtn.currentTitle ViewHeight:30 fontSize:FontADA_(16) type:@"w"]; |
|
[registerBtn mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(line.mas_right).offset(3); |
|
make.centerY.equalTo(line); |
|
make.size.mas_equalTo(CGSizeMake(Adapted(rect1.size.width+5), 16.5)); |
|
}]; |
|
|
|
/// 忘记密码 |
|
UIButton *forgetBtn = [UICommon ui_buttonSimple:CGRectZero font:FontADA_(16) normalColor:KKMainColor normalText:GJText(@"忘记密码") click:^(UIButton *sender) { |
|
RegisterViewController *vc = [RegisterViewController new]; |
|
vc.navTitle = @"忘记密码"; |
|
vc.isViewType = 1; |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
}]; |
|
[self.view addSubview:forgetBtn]; |
|
CGRect rect = [UICommon GetTextWidth:forgetBtn.currentTitle ViewHeight:30 fontSize:FontADA_(16) type:@"w"]; |
|
[forgetBtn mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.right.equalTo(line.mas_left).inset(3); |
|
make.centerY.equalTo(line); |
|
make.size.mas_equalTo(CGSizeMake(Adapted(rect.size.width+5), 16.5)); |
|
}]; |
|
|
|
|
|
UIImageView *line1 = [UIImageView new]; |
|
line1.backgroundColor = KKLineColor; |
|
[self.view addSubview:line1]; |
|
[line1 mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.right.equalTo(self.view).inset(35); |
|
make.top.equalTo(line.mas_bottom).offset(iPhoneX_TabbarSafeBottomMargin > 0 ? AdaptedHeight(45) : AdaptedHeight(35)); |
|
make.height.mas_equalTo(1); |
|
}]; |
|
|
|
UILabel *otherLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:FontADA_(10) textColor:KKGrey133 text:@"其他方式登录" Radius:0]; |
|
otherLabel.backgroundColor = KKWhiteColorColor; |
|
[self.view addSubview:otherLabel]; |
|
[otherLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.centerX.equalTo(self.view); |
|
make.centerY.equalTo(line1); |
|
make.size.mas_equalTo(CGSizeMake(104.5, 14)); |
|
}]; |
|
|
|
NSArray *btnTitleArr = [WXApi isWXAppInstalled] ? @[@"微信",@"验证码"] : @[@"验证码"]; |
|
NSArray *btnImageArr = [WXApi isWXAppInstalled] ? @[@"login_wechatBtn",@"login_codeBtn"] : @[@"login_codeBtn"]; |
|
// NSArray *btnTitleArr = @[@"验证码"]; |
|
// NSArray *btnImageArr = @[@"login_codeBtn"]; |
|
for (int i = 0; i < btnTitleArr.count; i++) |
|
{ |
|
UIButton *btn = [UICommon ui_buttonSimple:CGRectZero font:FontADA_(10) normalColor:KKGrey133 normalText:btnTitleArr[i] click:^(UIButton *b) { |
|
if ([b.currentTitle isEqualToString:@"微信"]) |
|
{ |
|
[self WXAccredit]; |
|
} |
|
else |
|
{ |
|
RegisterViewController *vc = [RegisterViewController new]; |
|
vc.navTitle = @"验证码登录"; |
|
vc.isViewType = 3; |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
} |
|
}]; |
|
btn.size = CGSizeMake(50, 75); |
|
[btn setImage:ImageName_(btnImageArr[i]) forState:UIControlStateNormal]; |
|
[UICommon setTitleAndImage:btn :1.2]; |
|
[self.view addSubview:btn]; |
|
[btn mas_makeConstraints:^(MASConstraintMaker *make) { |
|
if (btnTitleArr.count == 1) |
|
make.centerX.equalTo(self.view); |
|
else |
|
{ |
|
if (i == 0) |
|
make.right.equalTo(self.view.mas_centerX).inset(Adapted(21)); |
|
else |
|
make.left.equalTo(self.view.mas_centerX).offset(Adapted(21)); |
|
} |
|
make.top.equalTo(otherLabel.mas_bottom).offset(AdaptedHeight(12)); |
|
make.size.mas_equalTo(CGSizeMake(50, 75)); |
|
}]; |
|
} |
|
|
|
|
|
|
|
SYTouchLabel *label = [[SYTouchLabel alloc] init]; |
|
label.lineBreakMode = NSLineBreakByCharWrapping; |
|
label.sy_highColor = KKMainColor; |
|
label.sy_normalColor = KKTextBlackColor; |
|
label.font = Font_(12); |
|
label.numberOfLines = 0; |
|
label.text = GJText(@"登录即代表同意《用户服务协议》和《隐私政策》并使用本机号码登录"); |
|
label.sy_clickString = GJText(@"《隐私政策》"); |
|
label.sy_clickRange = NSMakeRange(7, 8); |
|
[self.view addSubview:label]; |
|
[label mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(self.view).offset(40+Adapted(15)+5); |
|
make.right.equalTo(self.view.mas_right).inset(40); |
|
make.bottom.equalTo(self.view.mas_bottom).inset(iPhoneX_TabbarSafeBottomMargin > 0 ? iPhoneX_TabbarSafeBottomMargin : 15); |
|
}]; |
|
|
|
label.clickBlock = ^(NSString *clickString) |
|
{ |
|
NSLog(@"点击的文本为 %@",clickString); |
|
commWebViewController *vc = [[commWebViewController alloc] init]; |
|
vc.navTitle = [clickString isEqualToString:GJText(@"《用户服务协议》")] ? GJText(@"用户协议") : GJText(@"隐私政策"); |
|
vc.url = [clickString isEqualToString:GJText(@"《用户服务协议》")] ? AccoutXieYiURLStr : PrivacyPolicyURLStr; |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
}; |
|
|
|
UIButton *agreementBtn = [UICommon ui_buttonSimple:CGRectZero font:FontADA_(0) normalColor:KKWhiteColorColor normalText:@"" click:^(UIButton *btn) { |
|
btn.selected = !btn.selected; |
|
}]; |
|
[agreementBtn setImage:ImageName_(@"login_no_the_selected_icon") forState:UIControlStateNormal]; |
|
[agreementBtn setImage:ImageName_(@"login_the_selected_icon") forState:UIControlStateSelected]; |
|
// agreementBtn.selected = YES; |
|
self.agreementBtn = agreementBtn; |
|
[self.view addSubview:agreementBtn]; |
|
[agreementBtn mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.centerY.equalTo(label.mas_centerY); |
|
make.left.equalTo(self.view).offset(40); |
|
make.size.mas_equalTo(CGSizeMake(Adapted(15), Adapted(15))); |
|
}]; |
|
|
|
[self aucnTexg]; |
|
|
|
|
|
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; |
|
if (![userDefaults objectForKey:@"启动次数"]) |
|
{ |
|
// [userDefaults setObject:@"不止一次" forKey:@"启动次数"]; |
|
// [userDefaults synchronize]; |
|
|
|
self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame]; |
|
self.scrollView.pagingEnabled = YES; |
|
self.scrollView.contentSize = CGSizeMake(CGRectGetWidth(self.scrollView.frame) * 4, CGRectGetHeight(self.scrollView.frame)); |
|
self.scrollView.delegate = self; |
|
self.scrollView.showsVerticalScrollIndicator = NO; |
|
self.scrollView.showsHorizontalScrollIndicator = NO; |
|
self.scrollView.backgroundColor = [UIColor whiteColor]; |
|
|
|
[self.view addSubview:self.scrollView]; |
|
|
|
self.pageControl = [[UIPageControl alloc] init]; |
|
self.pageControl.numberOfPages = 4; |
|
self.pageControl.pageIndicatorTintColor = [KKMainColor colorWithAlphaComponent:0.3]; |
|
self.pageControl.currentPageIndicatorTintColor = KKMainColor; |
|
[self.view addSubview:self.pageControl]; |
|
[self.pageControl mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.centerX.equalTo(self.scrollView.mas_centerX); |
|
make.bottom.equalTo(self.scrollView.mas_bottom).offset(-10); |
|
}]; |
|
|
|
NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0]; |
|
NSArray *array = [language componentsSeparatedByString:@"-"]; |
|
NSString *currentLanguage = array[0]; |
|
for (int i = 0; i < 4; i++) |
|
{ |
|
UIImage *image = [currentLanguage isEqualToString:@"zh"] ? ImageName_(F(@"q-zh-%d", i+1)) : ImageName_(F(@"q-en-%d", i+1)); |
|
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetWidth(self.scrollView.frame) * i, |
|
0, |
|
CGRectGetWidth(self.scrollView.frame), |
|
CGRectGetHeight(self.scrollView.frame))]; |
|
imageView.image = image; |
|
[self.scrollView addSubview:imageView]; |
|
|
|
if (i == 3) |
|
{ |
|
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; |
|
// [btn setImage:[myHelper getImageWithName:@"立即体验按钮"] forState:UIControlStateNormal]; |
|
[btn setTitleColor:KKMainColor forState:UIControlStateNormal]; |
|
btn.frame = CGRectMake(SCREEN_WIDTH*3 + SCREEN_WIDTH/4, SCREEN_HEIGHT-45-30, SCREEN_WIDTH/2, 45); |
|
[btn setTitle:GJText(@"开始体验") forState:0]; |
|
btn.layer.masksToBounds = YES; |
|
btn.layer.cornerRadius = btn.height/2.0; |
|
[btn setBackgroundColor:KKMainColor]; |
|
[btn setTitleColor:[UIColor whiteColor] forState:0]; |
|
|
|
[btn addTarget:self action:@selector(removeScrollView)forControlEvents:UIControlEventTouchUpInside]; |
|
[self.scrollView addSubview:btn]; |
|
} |
|
} |
|
} |
|
|
|
|
|
} |
|
|
|
/// 微信登录跳转微信授权 |
|
- (void)WXAccredit |
|
{ |
|
[[APHandleManager sharedManager] authorizationWachat:^(NSDictionary *authInfo) { |
|
|
|
NSLog(@"%@",authInfo); |
|
[self WXLogin:authInfo]; |
|
} failure:^(HandleStatus code) { |
|
|
|
}]; |
|
} |
|
|
|
|
|
|
|
#pragma mark 微信授权后调用本地微信登录解救 |
|
/// 微信授权后调用本地微信登录解救 |
|
- (void)WXLogin:(NSDictionary *)authInfo |
|
{ |
|
[UICommon MessageUpload:@"加载中"]; |
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
|
[parameters setValue:authInfo[@"city"] forKey:@"city"]; |
|
[parameters setValue:authInfo[@"country"] forKey:@"country"]; |
|
[parameters setValue:authInfo[@"headimgurl"] forKey:@"headimgurl"]; |
|
[parameters setValue:authInfo[@"nickname"] forKey:@"nickname"]; |
|
[parameters setValue:authInfo[@"openid"] forKey:@"openid"]; |
|
[parameters setValue:authInfo[@"privilege"] forKey:@"privilege"]; |
|
[parameters setValue:authInfo[@"province"] forKey:@"province"]; |
|
[parameters setValue:authInfo[@"sex"] forKey:@"sex"]; |
|
[parameters setValue:authInfo[@"unionid"] forKey:@"unionid"]; |
|
[[[APIManager sharedManager] APPOST:WechatLogin_URL parameters:parameters isJson:YES resultClass:LoginModel.class] subscribeNext:^(id _Nullable x) { |
|
[UICommon HidenLoading]; |
|
AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate; |
|
[app showRootViewController]; |
|
|
|
} error:^(NSError * _Nullable error) { |
|
NSDictionary *dic = error.userInfo; |
|
if ([dic[@"detail"] intValue] == 302) |
|
{ |
|
RegisterViewController *vc = [[RegisterViewController alloc] init]; |
|
vc.navTitle = @"绑定手机号"; |
|
vc.isViewType = 2; |
|
vc.authInfo = parameters; |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
return; |
|
} |
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]]; |
|
}]; |
|
} |
|
|
|
#pragma mark 登录 |
|
/// 登录 |
|
- (void)UserLogin |
|
{ |
|
self.loginBtn.selected = NO; |
|
if (!self.phoneField.text || self.phoneField.text.length != 11) |
|
{ |
|
[UICommon MessageErrorText:GJText(@"请输入正确的手机号")]; |
|
return; |
|
} |
|
else if (self.passField.text.length < 6) |
|
{ |
|
[UICommon MessageErrorText:GJText(@"密码为6~16位字符内")]; |
|
return; |
|
} |
|
if (!self.agreementBtn.selected) |
|
{ |
|
[UICommon MessageErrorText:GJText(@"请同意用户服务协议和隐私政策")]; |
|
return; |
|
} |
|
self.loginBtn.selected = YES; |
|
self.loginBtn.enabled = NO; |
|
[UICommon MessageUpload:@"登录中"]; |
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
|
[parameters setValue:self.phoneField.text forKey:@"phone"]; |
|
[parameters setValue:self.passField.text forKey:@"password"]; |
|
[[[APIManager sharedManager] APPOST:UserLogin_URL parameters:parameters isJson:YES resultClass:LoginModel.class] subscribeNext:^(id _Nullable x) { |
|
NSMutableDictionary *userDic = [NSMutableDictionary dictionary]; |
|
[userDic setValue:self.phoneField.text forKey:@"phone"]; |
|
[userDic setValue:self.isRememberPWD ? self.passField.text : @"" forKey:@"password"]; |
|
[userDic setValue:self.isRememberPWD ? @"1" : @"0" forKey:@"isRememberPWD"]; |
|
// [userDic setValue:self.countryCodeLabel.text forKey:@"code"]; |
|
// [userDic setValue:self.countryTitleLabel.text forKey:@"gj"]; |
|
YYCache *userCache = [YYCache cacheWithName:UserCacheName]; |
|
[userCache setObject:userDic forKey:UserCacheKey]; |
|
|
|
AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate; |
|
[app showRootViewController]; |
|
self.loginBtn.enabled = YES; |
|
self.loginBtn.selected = NO; |
|
|
|
} error:^(NSError * _Nullable error) { |
|
self.loginBtn.enabled = YES; |
|
self.loginBtn.selected = NO; |
|
NSDictionary *dic = error.userInfo; |
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]]; |
|
}]; |
|
} |
|
|
|
|
|
|
|
#pragma mark UITextViewDelegate |
|
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange |
|
{ |
|
|
|
if ([URL.absoluteString containsString:AccoutXieYiURLStr]) |
|
{ |
|
commWebViewController *vc = [commWebViewController new]; |
|
vc.url = AccoutXieYiURLStr; |
|
vc.navTitle = GJText(@"用户协议"); |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
return NO; |
|
} |
|
else if ([URL.absoluteString containsString:PrivacyPolicyURLStr]) |
|
{ |
|
commWebViewController *vc = [commWebViewController new]; |
|
vc.url = AccoutXieYiURLStr; |
|
vc.navTitle = GJText(@"隐私政策"); |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
return NO; |
|
} |
|
return YES; |
|
} |
|
|
|
- (void)scrollViewDidScroll:(UIScrollView *)scrollView |
|
{ |
|
int page = scrollView.contentOffset.x / scrollView.frame.size.width; |
|
//NSLog(@"%d", page); |
|
//NSLog(@"%f", scrollView.contentOffset.x); |
|
|
|
// 设置页码 |
|
self.pageControl.currentPage = page; |
|
if (/*scrollView.contentOffset.x > ScreenWidth*/ page==3 ){ // update by lsz 2021-7-23 |
|
[self.pageControl setHidden: YES]; |
|
}else{ |
|
[self.pageControl setHidden: NO]; |
|
} |
|
} |
|
|
|
- (void)removeScrollView |
|
{ |
|
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; |
|
[userDefaults setObject:@"不止一次" forKey:@"启动次数"]; |
|
[userDefaults synchronize]; |
|
[self.scrollView removeFromSuperview]; |
|
[self.pageControl removeFromSuperview]; |
|
} |
|
|
|
|
|
/// 如果有账号缓存,填充账号密码 |
|
- (void)aucnTexg |
|
{ |
|
kWeakSelf(self) |
|
YYCache *yyCache = [YYCache cacheWithName:UserCacheName]; |
|
BOOL isContains = [yyCache containsObjectForKey:UserCacheKey]; |
|
if (isContains) |
|
{ |
|
NSDictionary *dic = (NSDictionary *)[yyCache objectForKey:UserCacheKey]; |
|
weakself.phoneField.text = dic[@"phone"]; |
|
weakself.passField.text = dic[@"password"]; |
|
// weakself.countryCodeLabel.text = dic[@"code"]; |
|
// weakself.countryTitleLabel.text = dic[@"gj"]; |
|
NSString *is = dic[@"isRememberPWD"]; |
|
[weakself.rememberPassBtn setSelected:[is isEqualToString:@"1"] ? YES : NO]; |
|
weakself.isRememberPWD = [is isEqualToString:@"1"] ? YES : NO; |
|
} |
|
} |
|
|
|
/* |
|
#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. |
|
} |
|
*/ |
|
|
|
@end
|
|
|