926 lines
36 KiB
Objective-C
926 lines
36 KiB
Objective-C
//
|
|
// XJLoginTopChangeViewController.m
|
|
// XinjiangProject
|
|
//
|
|
// Created by Apple on 2025/10/31.
|
|
//
|
|
|
|
#import "XJLoginTopChangeViewController.h"
|
|
#import "TUIC2CChatViewController.h"
|
|
#import "XJLoginFoundPasswordViewController.h"
|
|
#import "IMUserInfoModel.h"
|
|
#import "RSAObjC.h"
|
|
#import "XJMineCenterUserModel.h"
|
|
#import "ADJumpViewController.h"
|
|
#import "XJRegisterViewController.h"
|
|
#import "LVKeyboard.h"
|
|
#import "MQTextField.h"
|
|
#import "XJTYFoundPassWordViewController.h"
|
|
|
|
#import "SimulationViewController.h"
|
|
|
|
|
|
@interface XJLoginTopChangeViewController ()<V2TIMSDKListener,V2TIMSDKListener,LVKeyboardDelegate,UITextFieldDelegate>
|
|
|
|
@property (nonatomic, strong) UITextField * userNameField;
|
|
|
|
@property (nonatomic, strong) MQTextField * passwordField;
|
|
|
|
@property (nonatomic, strong) UIButton * logoBtn;
|
|
|
|
@property (nonatomic, strong) UIView * loginView;
|
|
|
|
@property (nonatomic, strong) UIButton * privacyPolicyBtn;
|
|
|
|
@property (nonatomic, strong) UIButton * agreenBtn;
|
|
|
|
@property (nonatomic, strong) IMUserInfoModel * model ;
|
|
|
|
@property (nonatomic, strong) NSMutableArray * dataArray;
|
|
|
|
@property (nonatomic, strong) UIButton * regisBtn;
|
|
|
|
@property (nonatomic, strong) LVKeyboard *keyboard;
|
|
|
|
@property (nonatomic, strong) UIButton *toggleButton;
|
|
|
|
@property (nonatomic, strong) UIButton * leftLoginBtn;
|
|
|
|
@property (nonatomic, strong) UIButton * rightLoginBtn;
|
|
|
|
@property (nonatomic, assign) NSInteger loginType;
|
|
|
|
@property (nonatomic, strong) UIButton * foundPasswordBtn;
|
|
|
|
@property (nonatomic, assign) NSInteger tapCount;
|
|
@property (nonatomic, strong) NSDate *firstTapDate;
|
|
|
|
@property (nonatomic, strong) UILabel * topLoginTitleLab;
|
|
|
|
@property (nonatomic, strong) UIButton * bottomChangeBtn;
|
|
|
|
@property (nonatomic, assign) NSTimeInterval lastClickTime;
|
|
|
|
|
|
@end
|
|
|
|
@implementation XJLoginTopChangeViewController
|
|
|
|
- (NSMutableArray *)dataArray {
|
|
|
|
if (!_dataArray) {
|
|
_dataArray = [[NSMutableArray alloc] init];
|
|
}
|
|
return _dataArray;
|
|
}
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
self.isHidenNaviBar = YES;
|
|
self.view.backgroundColor = KWhiteColor;
|
|
[self createUI];
|
|
[self createData];
|
|
self.loginType = 1;
|
|
[self setNeedsStatusBarAppearanceUpdate];
|
|
|
|
//初始化键盘
|
|
LVKeyboard *keyboard = [[LVKeyboard alloc] init];
|
|
keyboard.delegate = self;
|
|
self.keyboard = keyboard;
|
|
|
|
|
|
}
|
|
|
|
- (UIStatusBarStyle)preferredStatusBarStyle {
|
|
return UIStatusBarStyleLightContent;
|
|
}
|
|
|
|
- (void)createUI {
|
|
|
|
UIImageView * topBackImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kRealValue(251))];
|
|
topBackImg.image = IMAGE_NAMED(@"XJLoginTopImg");
|
|
topBackImg.userInteractionEnabled = true;
|
|
[self.view addSubview:topBackImg];
|
|
|
|
|
|
UILabel *headLab = [[UILabel alloc] initWithFrame:CGRectMake(24, topBackImg.bottom - kRealValue(46) - 58, 300, 58)];
|
|
headLab.numberOfLines = 0;
|
|
headLab.textColor = KWhiteColor;
|
|
headLab.userInteractionEnabled = true;
|
|
headLab.textAlignment = NSTextAlignmentLeft;
|
|
|
|
NSString *text = @"你好呀,\n欢迎使用 健康油我";
|
|
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
|
|
style.lineSpacing = 6; // 设置行间距为10
|
|
style.alignment = NSTextAlignmentLeft;
|
|
|
|
NSDictionary *attributes = @{
|
|
NSFontAttributeName: BOLDSYSTEMFONT(20),
|
|
NSForegroundColorAttributeName: KWhiteColor,
|
|
NSParagraphStyleAttributeName: style
|
|
};
|
|
headLab.attributedText = [[NSAttributedString alloc] initWithString:text attributes:attributes];
|
|
|
|
[self.view addSubview:headLab];
|
|
UIButton * homeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
homeBtn.frame = CGRectMake(kRealValue(15), kRealValue(40),kRealValue(100), 41);
|
|
[homeBtn setTitle:@"< 去首页" forState:UIControlStateNormal];
|
|
[homeBtn.titleLabel setFont:BOLDSYSTEMFONT(14)];
|
|
[homeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
[homeBtn addTarget:self action:@selector(backHomeAction) forControlEvents:UIControlEventTouchUpInside];
|
|
[topBackImg addSubview:homeBtn];
|
|
|
|
// 添加点击手势识别器
|
|
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleImageTap:)];
|
|
[headLab addGestureRecognizer:tapGestureRecognizer];
|
|
|
|
// 初始化计数器
|
|
//
|
|
UIView *loginView = [[UIView alloc]init];
|
|
loginView.frame = CGRectMake(0, topBackImg.bottom - kRealValue(20), kScreenWidth, kScreenHeight - topBackImg.bottom - kRealValue(20));
|
|
[self.view addSubview:loginView];
|
|
loginView.backgroundColor = KWhiteColor;
|
|
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:loginView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(16, 16)];
|
|
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
|
|
maskLayer.path = maskPath.CGPath;
|
|
loginView.layer.mask = maskLayer;
|
|
self.loginView = loginView;
|
|
// 新增切换逻辑
|
|
// CGFloat btnWidth = (kScreenWidth - kRealValue(37) * 2) / 2 ;
|
|
//
|
|
// self.leftLoginBtn = [[UIButton alloc] initWithFrame:CGRectMake(kRealValue(37), kRealValue(40), btnWidth, 48)];
|
|
// [self.leftLoginBtn setTitle:@"平台统一认证" forState:UIControlStateNormal];
|
|
// [self.leftLoginBtn setTitleColor:KWhiteColor forState:UIControlStateSelected];
|
|
// [self.leftLoginBtn setTitleColor:UIColorHex(#2EB8B2) forState:UIControlStateNormal];
|
|
// self.leftLoginBtn.selected = true;
|
|
// self.leftLoginBtn.titleLabel.font = MEDIUMFONT(16);
|
|
// [self.leftLoginBtn setBackgroundImage:[UIImage imageNamed:@"leftLoginNomal"] forState:UIControlStateNormal];
|
|
// [self.leftLoginBtn setBackgroundImage:[UIImage imageNamed:@"loginSelectedImg"] forState:UIControlStateSelected];
|
|
// [self.leftLoginBtn addTarget:self action:@selector(accountLoginTypeClick) forControlEvents:UIControlEventTouchUpInside];
|
|
//
|
|
// [self.loginView addSubview:self.leftLoginBtn];
|
|
//
|
|
// self.rightLoginBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.leftLoginBtn.right, kRealValue(40), btnWidth, 48)];
|
|
// [self.rightLoginBtn setTitle:@"健康系统认证" forState:UIControlStateNormal];
|
|
// [self.rightLoginBtn setTitleColor:KWhiteColor forState:UIControlStateSelected];
|
|
// [self.rightLoginBtn setTitleColor:UIColorHex(#2EB8B2) forState:UIControlStateNormal];
|
|
// self.rightLoginBtn.selected = false;
|
|
// self.rightLoginBtn.titleLabel.font = MEDIUMFONT(16);
|
|
// [self.rightLoginBtn setBackgroundImage:[UIImage imageNamed:@"loginNomalImg"] forState:UIControlStateNormal];
|
|
// [self.rightLoginBtn setBackgroundImage:[UIImage imageNamed:@"rightLoginSelected"] forState:UIControlStateSelected];
|
|
// [self.rightLoginBtn addTarget:self action:@selector(healthLoginTypeClick) forControlEvents:UIControlEventTouchUpInside];
|
|
// [self.loginView addSubview:self.rightLoginBtn];
|
|
//
|
|
|
|
//1月21日新需求
|
|
|
|
self.topLoginTitleLab = [[UILabel alloc] init];;
|
|
self.topLoginTitleLab.text = @"平台统一认证";
|
|
self.topLoginTitleLab.font = [UIFont systemFontOfSize:20 weight:UIFontWeightBold];
|
|
self.topLoginTitleLab.textColor = UIColorHex(#2EB8B2);
|
|
self.topLoginTitleLab.textAlignment = NSTextAlignmentCenter;
|
|
[self.loginView addSubview:self.topLoginTitleLab];
|
|
|
|
[self.topLoginTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.mas_offset(0);
|
|
make.top.mas_offset(40);
|
|
make.height.mas_offset(kRealValue(40));
|
|
}];
|
|
|
|
|
|
UITextField *accountField = [[UITextField alloc]init];
|
|
accountField.placeholder = @"请输入员工编号或用户名";
|
|
accountField.font = BOLDSYSTEMFONT(14);
|
|
accountField.textColor = CFontColor1;
|
|
self.userNameField = accountField;
|
|
self.userNameField.backgroundColor = UIColorHex(#EEEEEE);
|
|
self.userNameField.layer.cornerRadius = 8;
|
|
self.userNameField.layer.masksToBounds = true;
|
|
UIView * leftview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 44, 48)];
|
|
UIImageView * userLeftImg = [[UIImageView alloc] initWithFrame:CGRectMake(16, 14, 20, 20)];
|
|
userLeftImg.image = [UIImage imageNamed:@"userInputLeftImg"];
|
|
[leftview addSubview:userLeftImg];
|
|
self.userNameField.leftView = leftview;
|
|
self.userNameField.leftViewMode = UITextFieldViewModeAlways;
|
|
self.userNameField.autocapitalizationType = UITextAutocapitalizationTypeNone;
|
|
[loginView addSubview:accountField ];
|
|
//
|
|
|
|
[self.userNameField mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_offset(25);
|
|
make.right.mas_offset(-25);
|
|
make.height.mas_offset(48);
|
|
make.top.mas_equalTo(self.topLoginTitleLab.mas_bottom).offset(kRealValue(24));
|
|
}];
|
|
|
|
//
|
|
MQTextField * passwordField = [[MQTextField alloc]init];
|
|
// passwordField.frame = CGRectMake(kRealValue(25), accountField.bottom + kRealValue(19), accountField.width, accountField.height);
|
|
passwordField.placeholder = @"请输入密码";
|
|
passwordField.font = BOLDSYSTEMFONT(14);
|
|
passwordField.textColor = CFontColor1;
|
|
passwordField.backgroundColor = UIColorHex(#EEEEEE);
|
|
passwordField.secureTextEntry = YES;
|
|
self.passwordField = passwordField;
|
|
|
|
UIView * passLeftview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 44, 48)];
|
|
UIImageView * passLeftImg = [[UIImageView alloc] initWithFrame:CGRectMake(16, 14, 20, 20)];
|
|
passLeftImg.image = [UIImage imageNamed:@"passLockImg"];
|
|
[passLeftview addSubview:passLeftImg];
|
|
self.passwordField.leftView = passLeftview;
|
|
self.passwordField.leftViewMode = UITextFieldViewModeAlways;
|
|
self.passwordField.layer.cornerRadius = 8;
|
|
self.passwordField.layer.masksToBounds = true;
|
|
self.passwordField.delegate = self;
|
|
self.passwordField.inputView = self.keyboard;
|
|
|
|
self.toggleButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[self.toggleButton setImage:[UIImage imageNamed:@"eye"] forState:UIControlStateNormal];
|
|
[self.toggleButton setImage:[UIImage imageNamed:@"eye.slash"] forState:UIControlStateSelected];
|
|
self.toggleButton.frame = CGRectMake(0, 9, 30,30);
|
|
[self.toggleButton addTarget:self action:@selector(togglePasswordVisibility) forControlEvents:UIControlEventTouchUpInside];
|
|
// 创建一个容器视图来包含按钮,并增加边距
|
|
UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 48)];
|
|
[rightView addSubview:self.toggleButton];
|
|
// 调整按钮在容器视图中的位置,增加边距
|
|
self.toggleButton.center = CGPointMake(rightView.frame.size.width - self.toggleButton.frame.size.width / 2, rightView.frame.size.height / 2);
|
|
self.passwordField.rightView = rightView;
|
|
self.passwordField.rightViewMode = UITextFieldViewModeAlways;
|
|
[loginView addSubview:passwordField];
|
|
|
|
|
|
[self.passwordField mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_offset(25);
|
|
make.right.mas_offset(-25);
|
|
make.height.mas_offset(48);
|
|
make.top.mas_equalTo(self.userNameField.mas_bottom).offset(kRealValue(19));
|
|
}];
|
|
|
|
|
|
UIButton *loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
// loginBtn.frame = CGRectMake(kRealValue(25), self.passwordField.bottom + kRealValue(20), WIDTH - kRealValue(50), 48);
|
|
[loginBtn setTitle:@"登录" forState:UIControlStateNormal];
|
|
[loginBtn.titleLabel setFont:BOLDSYSTEMFONT(16)];
|
|
loginBtn.backgroundColor = UIColorHex(#2EB8B2);
|
|
loginBtn.layer.cornerRadius = 8;
|
|
loginBtn.layer.masksToBounds = true;
|
|
[loginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
[loginBtn addTarget:self action:@selector(toClickFootBtn:) forControlEvents:UIControlEventTouchUpInside];
|
|
[loginView addSubview:loginBtn];
|
|
|
|
[loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_offset(kRealValue(25));
|
|
make.right.mas_offset(-kRealValue(25));
|
|
make.height.mas_offset(48);
|
|
make.top.mas_equalTo(self.passwordField.mas_bottom).offset(kRealValue(20));
|
|
}];
|
|
|
|
|
|
|
|
|
|
UIButton * foundPasswordBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
// foundPasswordBtn.frame = CGRectMake(loginBtn.right - 60, loginBtn.bottom + kRealValue(22), 60, 12);
|
|
[foundPasswordBtn setTitle:@"找回密码" forState:UIControlStateNormal];
|
|
foundPasswordBtn.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightRegular];
|
|
[foundPasswordBtn setTitleColor:UIColorHex(#B6B6B6) forState:UIControlStateNormal];
|
|
[foundPasswordBtn addTarget:self action:@selector(foundUserPasswordAction) forControlEvents:UIControlEventTouchUpInside];
|
|
self.foundPasswordBtn = foundPasswordBtn;
|
|
[loginView addSubview:foundPasswordBtn];
|
|
|
|
|
|
[foundPasswordBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(loginBtn.mas_right);
|
|
make.height.mas_offset(kRealValue(20));
|
|
make.top.mas_equalTo(loginBtn.mas_bottom).offset(18);
|
|
}];
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"LOGINAgree"];
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
|
NSUserDefaults * agreeDefaul = [NSUserDefaults standardUserDefaults];
|
|
|
|
NSString * agree = [agreeDefaul objectForKey:@"LOGINAgree"];
|
|
|
|
|
|
|
|
//隐私
|
|
|
|
self.agreenBtn = [[UIButton alloc] init];
|
|
[self.agreenBtn addTarget:self action:@selector(agreeProtocolAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
[self.agreenBtn setImage:IMAGE_NAMED(@"login_nomalProtocol") forState:UIControlStateNormal];
|
|
[self.agreenBtn setImage:IMAGE_NAMED(@"login_selectProtocol") forState:UIControlStateSelected];
|
|
if ([agree intValue] == 1) {
|
|
self.agreenBtn.selected = true;
|
|
}else
|
|
{
|
|
self.agreenBtn.selected = false;
|
|
}
|
|
[self.loginView addSubview:self.agreenBtn];
|
|
|
|
[self.agreenBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_offset(25);
|
|
make.top.mas_equalTo(loginBtn.mas_bottom).offset(18);
|
|
make.width.height.mas_offset(kRealValue(20));
|
|
}];
|
|
|
|
NSString *string = @"我已阅读并同意用户协议和隐私政策";
|
|
YYLabel * yslabel = [[YYLabel alloc] init];
|
|
yslabel.textColor = UIColorHex(#B6B6B6);
|
|
yslabel.textAlignment = NSTextAlignmentCenter;
|
|
[self.view addSubview:yslabel];
|
|
|
|
[yslabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self.agreenBtn.mas_right).offset(5);
|
|
make.top.mas_equalTo(loginBtn.mas_bottom).offset(22);
|
|
}];
|
|
|
|
yslabel.numberOfLines = 0;
|
|
NSMutableAttributedString *attributed = [[NSMutableAttributedString alloc] initWithString:string];
|
|
// 1️⃣ 给整段文字设置默认样式(灰色)
|
|
attributed.font = [UIFont systemFontOfSize:13 weight:UIFontWeightRegular];
|
|
attributed.color = UIColorHex(#B6B6B6); // 默认灰色
|
|
[attributed setAttribute:NSForegroundColorAttributeName value:UIColorHex(#2EB8B2) range:[string rangeOfString:@"用户协议"]];
|
|
[attributed setAttribute:NSForegroundColorAttributeName value:UIColorHex(#2EB8B2) range:[string rangeOfString:@"隐私政策"]];
|
|
|
|
YYTextHighlight * protocolHightlight = [[YYTextHighlight alloc] init];
|
|
protocolHightlight.userInfo = @{@"协议":@"用户协议"};
|
|
[protocolHightlight setColor:UIColorHex(#2EB8B2)];
|
|
[attributed setTextHighlight:protocolHightlight range:[string rangeOfString:@"用户协议"]];
|
|
|
|
YYTextHighlight * layHightlight = [[YYTextHighlight alloc] init];
|
|
layHightlight.userInfo = @{@"隐私":@"隐私政策"};
|
|
[layHightlight setColor:UIColorHex(#2EB8B2)];
|
|
[attributed setTextHighlight:layHightlight range:[string rangeOfString:@"隐私政策"]];
|
|
attributed.lineSpacing = 3;
|
|
attributed.paragraphSpacing = 5;
|
|
yslabel.attributedText = attributed;
|
|
|
|
yslabel.highlightTapAction = ^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
|
NSString *string = [text.string substringWithRange:range];
|
|
if ([string containsString:@"用户协议"]){
|
|
if (self.dataArray.count <= 0) {
|
|
[EasyTextView showErrorText:@"暂无用户协议"];
|
|
return;
|
|
}
|
|
for (XJMineCenterUserModel * model in self.dataArray) {
|
|
|
|
if ([model.value integerValue] == 1) {
|
|
|
|
ADJumpViewController * webVC= [[ADJumpViewController alloc] init];
|
|
webVC.webTitle = @"用户协议";
|
|
webVC.webUrl = [NSString stringWithFormat:@"%@%@",IntervenH5,model.text];
|
|
[self.navigationController pushViewController:webVC animated:YES];
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
if ([string containsString:@"隐私政策"]){
|
|
if (self.dataArray.count <= 0) {
|
|
[EasyTextView showErrorText:@"暂无隐私政策"];
|
|
return;
|
|
}
|
|
for (XJMineCenterUserModel * model in self.dataArray) {
|
|
if ([model.value integerValue] == 2) {
|
|
|
|
ADJumpViewController * webVC= [[ADJumpViewController alloc] init];
|
|
webVC.webTitle = @"隐私政策";
|
|
webVC.webUrl = [NSString stringWithFormat:@"%@%@",IntervenH5,model.text];
|
|
[self.navigationController pushViewController:webVC animated:YES];
|
|
}
|
|
}
|
|
}
|
|
if ([string containsString:@"相关法律说明"]){
|
|
for (XJMineCenterUserModel * model in self.dataArray) {
|
|
if ([model.value integerValue] == 3) {
|
|
|
|
ADJumpViewController * webVC= [[ADJumpViewController alloc] init];
|
|
webVC.webTitle = @"相关法律说明";
|
|
webVC.webUrl = [NSString stringWithFormat:@"%@%@",IntervenH5,model.text];
|
|
[self.navigationController pushViewController:webVC animated:YES];
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
//底部切换
|
|
self.bottomChangeBtn = [[UIButton alloc] init];
|
|
[self.bottomChangeBtn setTitle:@"非掌油用户登录入口" forState:UIControlStateNormal];
|
|
|
|
[self.bottomChangeBtn setTitle:@"掌油用户登录入口" forState:UIControlStateSelected];
|
|
|
|
[self.bottomChangeBtn setTitleColor:UIColorHex(#2EB8B2) forState:UIControlStateNormal];
|
|
self.bottomChangeBtn.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightRegular];
|
|
self.bottomChangeBtn.selected = false;
|
|
[self.bottomChangeBtn addTarget:self action:@selector(healthLoginTypeClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
[self.view addSubview:self.bottomChangeBtn];
|
|
|
|
[self.bottomChangeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.mas_offset(-40);
|
|
make.centerX.mas_equalTo(self.view);
|
|
make.width.mas_offset(130);
|
|
}];
|
|
// 昨天改的今天不要了 那就隐藏吧
|
|
self.bottomChangeBtn.hidden = true;
|
|
|
|
|
|
|
|
|
|
}
|
|
- (void)createData {
|
|
|
|
XJPNetAPI * agreeAPI = [[XJPNetAPI alloc] init:self tag:@"AGREEAPI" NeedToken:@""];
|
|
|
|
[agreeAPI getUserAgreementPrivacy:nil];
|
|
|
|
}
|
|
|
|
|
|
#pragma mark - ACTION
|
|
- (void)toClickFootBtn:(UIButton *)button{
|
|
|
|
if (self.agreenBtn.selected == false) {
|
|
[EasyTextView showErrorText:@"请选阅读并同意用户服务协议与隐私"];
|
|
return;;
|
|
}
|
|
|
|
if (self.userNameField.text.length < 1) {
|
|
[EasyTextView showErrorText:@"请输入用户名"];
|
|
return;;
|
|
}
|
|
|
|
if (self.passwordField.text.length < 1) {
|
|
[EasyTextView showErrorText:@"请输入密码"];
|
|
return;;
|
|
}
|
|
|
|
NSTimeInterval now = [[NSDate date] timeIntervalSince1970];
|
|
|
|
if (self.lastClickTime > 0 && now - self.lastClickTime < 5) {
|
|
[EasyTextView showErrorText:@"操作过于频繁,请稍候再试!"];
|
|
return; // 👈 只提示,不再继续
|
|
}
|
|
|
|
self.lastClickTime = now;
|
|
|
|
NSString * publish_key = @" MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCmZfR/bA9X3vp86y1aEpvwzXJYKRRF1fLau2+05/ZtaITLpV8bhkmSf3neSy/Q9gAdvG75Fr73E+GWE+K5b0BpvIS1jDGo319+PpZR39SaZTKZ27XFXrosmJTZutN79t819HS1VseleunHAFgMVufE9U5jP6LGzl/wbkSy01GhzwIDAQAB";
|
|
|
|
// 原始数据,要加密的字符串
|
|
NSString *originalString = self.passwordField.text;
|
|
|
|
// RSA 加密,使用字符串格式的公钥私钥加密解密, RSAPublickKey 为公钥字符串(NSString 格式)
|
|
NSString *encryptStr = [RSAObjC encrypt:originalString PublicKey:publish_key];
|
|
|
|
[self showMBProgressHUDWithString:@"登录中" autoHidden:false];
|
|
NSMutableDictionary * parmDic = [[NSMutableDictionary alloc] init];
|
|
|
|
[parmDic setObject:self.userNameField.text forKey:@"username"];
|
|
|
|
[parmDic setObject:encryptStr forKey:@"password"];
|
|
|
|
//新增
|
|
UIDevice *currentDevice = [UIDevice currentDevice];
|
|
NSString * phone = [currentDevice getCurrentDeviceModel];
|
|
// NSString * system = [NSString stringWithFormat:@"%.1f",CurrentSystemVersion] ;
|
|
if (!ValidStr(phone)) {
|
|
[parmDic setObject:phone forKey:@"deviceType"];
|
|
|
|
}
|
|
[parmDic setObject:@(CurrentSystemVersion) forKey:@"deviceSystem"];
|
|
|
|
//统一平台登录
|
|
if (self.loginType == 1) {
|
|
|
|
XJPNetAPI * proctocolApi = [[XJPNetAPI alloc] init:self tag:@"LOGINGAPI" NeedToken:nil];
|
|
[proctocolApi healthAccountLogin:parmDic];
|
|
}
|
|
else //健康系统登录
|
|
{
|
|
// if (self.passwordField.text.length < 12 || self.passwordField.text.length > 32) {
|
|
//
|
|
//
|
|
//
|
|
// UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"密码不安全,请先修改密码" preferredStyle:UIAlertControllerStyleAlert];
|
|
//
|
|
// UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
|
//
|
|
// }];
|
|
// UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
//
|
|
// XJLoginFoundPasswordViewController * modifVC = [[XJLoginFoundPasswordViewController alloc] init];
|
|
// [self.navigationController pushViewController:modifVC animated:YES];
|
|
//
|
|
// }];
|
|
// [alertController addAction:cancelAction];
|
|
// [alertController addAction:sureAction];
|
|
//
|
|
// [self presentViewController:alertController animated:YES completion:nil];
|
|
//
|
|
//
|
|
// return;
|
|
// }
|
|
|
|
XJPNetAPI * proctocolApi = [[XJPNetAPI alloc] init:self tag:@"LOGINGAPI" NeedToken:nil];
|
|
[proctocolApi PostLogin:parmDic];
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#pragma mark -网络请求处理
|
|
- (void)Failed:(NSString*)message tag:(NSString*)tag
|
|
{
|
|
[self hiddenAllMBProgressHUD];
|
|
|
|
[EasyTextView showErrorText:message];
|
|
// [self showMBProgressHUDOnlyWithString:message];
|
|
|
|
|
|
}
|
|
- (void)Sucess:(id)response tag:(NSString*)tag
|
|
{
|
|
|
|
if ([tag isEqualToString:@"LOGINGAPI"]) {
|
|
[self hiddenAllMBProgressHUD];
|
|
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"AVATAR"];
|
|
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"placeholdImg"];
|
|
|
|
NSDictionary * dic = response;
|
|
HQUserInfo * user = [[HQUserInfo alloc] init];
|
|
id (^safeValue)(id obj) = ^id(id obj) {
|
|
return (obj && ![obj isKindOfClass:[NSNull class]]) ? obj : nil;
|
|
};
|
|
|
|
NSDictionary *userInfo = safeValue(dic[@"userInfo"]);
|
|
if ([userInfo isKindOfClass:[NSDictionary class]]) {
|
|
user.userInfo = userInfo;
|
|
}
|
|
|
|
NSString *token = safeValue(dic[@"token"]);
|
|
if ([token isKindOfClass:[NSString class]]) {
|
|
user.token = token;
|
|
}
|
|
[HQCommonUtils keyedArchiverWithData:user key:LoginUserInfo];
|
|
[[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"LOGINAgree"];
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
NSString * avatar = @"";
|
|
NSString * placeholdImg ;
|
|
if (!ValidStr(user.avatar) && ![user.avatar isEqualToString:ResourceAddress]) {
|
|
avatar = user.avatar;
|
|
}else
|
|
{
|
|
if ([user.sex_dictText isEqualToString:@"女"]) {
|
|
placeholdImg = @"heard_woman";
|
|
}else
|
|
{
|
|
placeholdImg = @"heard_man";
|
|
}
|
|
}
|
|
if (ValidStr(user.personType) || [user.personType intValue] != 1 ) {
|
|
|
|
[self showMBProgressHUDOnlyWithString:@"账号或登录密码错误,请重试"];
|
|
return;
|
|
}
|
|
[[NSUserDefaults standardUserDefaults] setObject:avatar forKey:@"AVATAR"];
|
|
[[NSUserDefaults standardUserDefaults] setObject:placeholdImg forKey:@"placeholdImg"];
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
|
KPostNotification(KNotificationLoginStateChange, @YES);
|
|
#if DEBUG
|
|
[self loginImAccount];
|
|
|
|
|
|
#else
|
|
[self loginImAccount];
|
|
|
|
#endif
|
|
}
|
|
if ([tag isEqualToString:@"IMAPI"]) {
|
|
|
|
NSDictionary * pamrDic = response;
|
|
|
|
IMUserInfoModel * model = [IMUserInfoModel modelWithDictionary:pamrDic];
|
|
|
|
IMUserInfoModel * iminfoModel = [[IMUserInfoModel alloc] init];
|
|
iminfoModel.IMInfo = pamrDic;
|
|
[HQCommonUtils keyedArchiverWithData:iminfoModel key:IMLoginUserInfo];
|
|
|
|
|
|
// 1. 从即时通信 IM 控制台获取应用 SDKAppID。
|
|
// 2. 初始化 config 对象
|
|
V2TIMSDKConfig *config = [[V2TIMSDKConfig alloc] init];
|
|
|
|
// 3. 指定 log 输出级别。
|
|
config.logLevel = V2TIM_LOG_INFO;
|
|
// 4. 添加 V2TIMSDKListener 的事件监听器,self 是 id<V2TIMSDKListener> 的实现类,如果您不需要监听 IM SDK 的事件,这个步骤可以忽略。
|
|
[[V2TIMManager sharedInstance] addIMSDKListener:self];
|
|
// 5. 初始化 IM SDK,调用这个接口后,可以立即调用登录接口。
|
|
[[V2TIMManager sharedInstance] initSDK:[model.sdkAppId intValue] config:config];
|
|
|
|
[ESCTUIManager loginInitTUISDKAppidWith:[model.sdkAppId intValue] UserID:model.userId userSig:model.userSig];
|
|
}
|
|
if ([tag isEqualToString:@"AGREEAPI"]) {
|
|
|
|
NSArray * array = response;
|
|
|
|
for (NSDictionary * parmDic in array) {
|
|
|
|
XJMineCenterUserModel * model = [XJMineCenterUserModel modelWithDictionary:parmDic];
|
|
https://api.cqygjk.com/health-consultation/api/consult/conDoctor/selectDictList?dictKey=qh_jump_url
|
|
[self.dataArray addObject:model];
|
|
|
|
}
|
|
|
|
}
|
|
if ([tag isEqualToString:@"VERSIONAPI"]) {
|
|
|
|
NSString * version = response;
|
|
|
|
|
|
NSBundle *mainBundle = [NSBundle mainBundle];
|
|
if (mainBundle) {
|
|
NSString *version = [mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
|
// NSString *build = [mainBundle objectForInfoDictionaryKey:@"CFBundleVersion"];
|
|
// NSString *displayName = [mainBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
|
// NSString *fullVersion = [NSString stringWithFormat:@"%@ %@ (Build %@)", displayName, version, build];
|
|
if([version floatValue] < [version floatValue]) {
|
|
self.regisBtn.hidden = true;
|
|
}else
|
|
{
|
|
self.regisBtn.hidden = false;
|
|
}
|
|
}
|
|
}
|
|
if([tag isEqualToString:@"SIMLOGINGAPI"]) {
|
|
//'人员类型(1:员工 2: 小助手 3: 专家 4: 医疗点 5: 操作人员 6: 专业人员 7:驻场人员 8:其他 9:医院管理员 10: 医院体检医生 11:医院前台 12: 健康室管理员 13: 健康打卡管理员 15:医疗点医护人员)'
|
|
[self hiddenAllMBProgressHUD];
|
|
NSDictionary * dic = response;
|
|
|
|
HQUserInfo * user = [[HQUserInfo alloc] init];
|
|
|
|
user.userInfo = [dic objectForKey:@"userInfo"];
|
|
|
|
user.token = [dic objectForKey:@"token"];
|
|
[HQCommonUtils keyedArchiverWithData:user key:LoginUserInfo];
|
|
[[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"LOGINAgree"];
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:user.token forKey:@"SIMTOKEN"];
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
NSString * avatar = @"";
|
|
NSString * placeholdImg ;
|
|
if (!ValidStr(user.avatar)) {
|
|
avatar = user.avatar;
|
|
}else
|
|
{
|
|
if ([user.sex_dictText isEqualToString:@"女"]) {
|
|
placeholdImg = @"heard_man";
|
|
}else
|
|
{
|
|
placeholdImg = @"heard_woman";
|
|
}
|
|
}
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:avatar forKey:@"AVATAR"];
|
|
[[NSUserDefaults standardUserDefaults] setObject:placeholdImg forKey:@"placeholdImg"];
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
|
KPostNotification(KNotificationLoginStateChange, @YES);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- (void)backHomeAction {
|
|
|
|
KPostNotification(KNotificationLoginStateChange, @YES);
|
|
|
|
}
|
|
|
|
|
|
- (void)loginImAccount {
|
|
|
|
|
|
XJPNetAPI * proctocolApi = [[XJPNetAPI alloc] init:self tag:@"IMAPI" NeedToken:nil];
|
|
[proctocolApi GetIMLoginAccount:nil];
|
|
|
|
|
|
|
|
}
|
|
//建议整体禁用(复制、粘贴、全选等都被禁用了)
|
|
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender{
|
|
|
|
UIMenuController *menuController = [UIMenuController sharedMenuController];
|
|
if (menuController) {
|
|
[UIMenuController sharedMenuController].menuVisible = NO;
|
|
}
|
|
return NO;
|
|
}
|
|
|
|
- (void)agreeProtocolAction:(UIButton *)agreeBtn {
|
|
|
|
agreeBtn.selected = !agreeBtn.selected;
|
|
|
|
|
|
}
|
|
#pragma mark:找回密码
|
|
- (void)foundUserPasswordAction {
|
|
// GastoremteroscopeViewController * resultAppointVC = [[GastoremteroscopeViewController alloc] init];
|
|
// [self.navigationController pushViewController:resultAppointVC animated:YES];
|
|
|
|
if (self.loginType == 1) { //统一平台找回密码
|
|
|
|
XJTYFoundPassWordViewController * xjVC = [[XJTYFoundPassWordViewController alloc] init];
|
|
xjVC.webUrl = @"https://sso.iosp.ydpt.tech/SSOManageClient/userController/changePassword";
|
|
[self.navigationController pushViewController:xjVC animated:YES];
|
|
|
|
}else
|
|
{
|
|
XJLoginFoundPasswordViewController * foundVC = [[XJLoginFoundPasswordViewController alloc] init];
|
|
|
|
[self.navigationController pushViewController:foundVC animated:YES];
|
|
}
|
|
}
|
|
|
|
- (void)ishiderRegisData {
|
|
|
|
|
|
XJPNetAPI * versionAPI = [[XJPNetAPI alloc] init:self tag:@"VERSIONAPI" NeedToken:@""];
|
|
|
|
[versionAPI getVesionHideRegis:@{@"type":@"app_update_user_ios"}.mutableCopy];
|
|
|
|
|
|
}
|
|
|
|
#pragma mark:注册
|
|
- (void)regisAction {
|
|
|
|
XJRegisterViewController * forgetVc = [[XJRegisterViewController alloc] init];
|
|
|
|
[self presentViewController:forgetVc animated:YES completion:nil];
|
|
}
|
|
|
|
|
|
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
|
|
|
|
if(textField == self.passwordField) {
|
|
|
|
self.passwordField.inputView = self.keyboard;
|
|
}
|
|
return YES;
|
|
|
|
}
|
|
|
|
- (void)keyboard:(LVKeyboard *)keyboard didClickDeleteButton:(UIButton *)deleteBtn string:(NSMutableString *)string {
|
|
self.passwordField.text = string;
|
|
}
|
|
|
|
- (void)keyboard:(LVKeyboard *)keyboard didClickTextButton:(UIButton *)textBtn string:(NSMutableString *)string {
|
|
self.passwordField.text = string;
|
|
}
|
|
|
|
|
|
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
[self.passwordField resignFirstResponder];
|
|
}
|
|
|
|
- (void)togglePasswordVisibility {
|
|
self.passwordField.secureTextEntry = !self.passwordField.secureTextEntry;
|
|
self.toggleButton.selected = !self.toggleButton.selected;
|
|
}
|
|
|
|
#pragma mark:顶部点击
|
|
- (void)accountLoginTypeClick {
|
|
self.loginType = 1;
|
|
self.leftLoginBtn.selected = true;
|
|
self.rightLoginBtn.selected = false;
|
|
[self.foundPasswordBtn setTitle:@"统一认证找回密码" forState:UIControlStateNormal];
|
|
|
|
|
|
}
|
|
//健康系统登录方法
|
|
- (void)healthLoginTypeClick:(UIButton *)changeBtn {
|
|
|
|
changeBtn.selected = !changeBtn.selected;
|
|
|
|
if (changeBtn.selected == true) {
|
|
self.loginType = 2;
|
|
self.topLoginTitleLab.text = @"健康系统认证";
|
|
|
|
}else
|
|
{
|
|
self.loginType = 1;
|
|
self.topLoginTitleLab.text = @"平台统一认证";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
//模拟功能
|
|
- (void)handleImageTap:(UITapGestureRecognizer *)sender {
|
|
// 获取当前点击时间
|
|
NSDate *currentTapDate = [NSDate date];
|
|
|
|
// 如果是第一次点击,记录时间
|
|
if (self.tapCount == 0) {
|
|
self.firstTapDate = currentTapDate;
|
|
}
|
|
|
|
// 计算点击间隔时间
|
|
NSTimeInterval timeInterval = [currentTapDate timeIntervalSinceDate:self.firstTapDate];
|
|
|
|
// 如果间隔时间超过2秒,重置计数器
|
|
if (timeInterval > 2.0) {
|
|
self.tapCount = 0;
|
|
self.firstTapDate = currentTapDate;
|
|
}
|
|
|
|
// 增加点击计数
|
|
self.tapCount += 1;
|
|
|
|
// 如果点击次数达到5次,触发事件
|
|
if (self.tapCount == 5) {
|
|
[self handleFiveContinuousTaps];
|
|
|
|
// 重置计数器
|
|
self.tapCount = 0;
|
|
}
|
|
}
|
|
|
|
- (void)handleFiveContinuousTaps {
|
|
// 在这里实现击5次触发事件的逻辑
|
|
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"你已经触发模拟用户功能!" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
}];
|
|
UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
self.userNameField.text = @"admin";
|
|
self.passwordField.text = @"#fCjW%x2dv@a";
|
|
//模拟用户system登录
|
|
[self loginModelUser];
|
|
|
|
}];
|
|
[alertController addAction:cancelAction];
|
|
[alertController addAction:sureAction];
|
|
|
|
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertController animated:YES completion:nil];
|
|
}
|
|
|
|
- (void)loginModelUser {
|
|
|
|
|
|
//测试
|
|
//#if DEBUG
|
|
// self.passwordField.text = @"#fCjW%x2dv@a";
|
|
|
|
|
|
|
|
//#else
|
|
// self.passwordField.text = @"&ZzW$3**@VLA";
|
|
|
|
//#endif
|
|
|
|
|
|
NSString * publish_key = @" MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCmZfR/bA9X3vp86y1aEpvwzXJYKRRF1fLau2+05/ZtaITLpV8bhkmSf3neSy/Q9gAdvG75Fr73E+GWE+K5b0BpvIS1jDGo319+PpZR39SaZTKZ27XFXrosmJTZutN79t819HS1VseleunHAFgMVufE9U5jP6LGzl/wbkSy01GhzwIDAQAB";
|
|
|
|
// 原始数据,要加密的字符串
|
|
NSString *originalString = self.passwordField.text;
|
|
|
|
// RSA 加密,使用字符串格式的公钥私钥加密解密, RSAPublickKey 为公钥字符串(NSString 格式)
|
|
NSString *encryptStr = [RSAObjC encrypt:originalString PublicKey:publish_key];
|
|
|
|
[self showMBProgressHUDWithString:@"登录中" autoHidden:false];
|
|
NSMutableDictionary * parmDic = [[NSMutableDictionary alloc] init];
|
|
|
|
[parmDic setObject:self.userNameField.text forKey:@"username"];
|
|
//新增
|
|
UIDevice *currentDevice = [UIDevice currentDevice];
|
|
NSString * phone = [currentDevice getCurrentDeviceModel];
|
|
// NSString * system = [NSString stringWithFormat:@"%.1f",CurrentSystemVersion] ;
|
|
if (!ValidStr(phone)) {
|
|
[parmDic setObject:phone forKey:@"deviceType"];
|
|
|
|
}
|
|
[parmDic setObject:@(CurrentSystemVersion) forKey:@"deviceSystem"];
|
|
|
|
[parmDic setObject:encryptStr forKey:@"password"];
|
|
|
|
XJPNetAPI * proctocolApi = [[XJPNetAPI alloc] init:self tag:@"SIMLOGINGAPI" NeedToken:nil];
|
|
[proctocolApi PostLogin:parmDic];
|
|
|
|
|
|
}
|
|
|
|
|
|
@end
|
|
|