Commit 1de38b03 authored by “Icebear”'s avatar “Icebear”

添加注册页逻辑,调通登录页逻辑

parent 79a7632d
......@@ -14,7 +14,7 @@
-(void)initWindow{
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.coordinator = [[MainCoordinator alloc] initWithWindow:self.window];
self.coordinator = [[MainCoordinator alloc] init];
[self.coordinator start];
}
......
......@@ -6,7 +6,6 @@
//
#import "NRBaseRequest.h"
#import "NRGlobalUrlModel.h"
@interface NRBaseRequest()
......
//
// NRCommonNavigationViewController.h
// NetrainFrame
//
// Created by Gin on 2020/10/12.
//
#import <QMUIKit/QMUIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface NRCommonNavigationViewController : QMUINavigationController
@end
NS_ASSUME_NONNULL_END
//
// NRCommonNavigationViewController.m
// NetrainFrame
//
// Created by Gin on 2020/10/12.
//
#import "NRCommonNavigationViewController.h"
@interface NRCommonNavigationViewController ()
@end
@implementation NRCommonNavigationViewController
- (void)viewDidLoad {
[super viewDidLoad];
QMUICMI.needsBackBarButtonItemTitle = YES;
// Do any additional setup after loading the view.
}
/*
#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
......@@ -28,6 +28,10 @@
- (BOOL)shouldCustomizeNavigationBarTransitionIfHideable {
return YES;
}
-(void)dealloc{
NSLog(@"%@ dealloc",NSStringFromClass([self class]));
}
/*
#pragma mark - Navigation
......
......@@ -11,8 +11,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface MainCoordinator : NSObject
- (instancetype)initWithWindow:(UIWindow *)window;
- (void)start;
@end
......
......@@ -6,26 +6,16 @@
//
#import "MainCoordinator.h"
#import "CTMediator+MainCoordinatorActions.h"
#import "CTMediator+LoginCoordinatorActions.h"
@interface MainCoordinator()
@property(nonatomic, weak) UIWindow *window;
@property(nonatomic, strong) NSMutableArray *childCoordinators;
@end
@implementation MainCoordinator
- (instancetype)initWithWindow:(UIWindow *)window
{
self = [super init];
if (self) {
self.window = window;
}
return self;
}
-(void)start{
BOOL isLogin = YES;
if(isLogin){
......@@ -41,9 +31,10 @@
}
- (void)showLogin{
UIWindow *window = [UIApplication sharedApplication].windows.firstObject;
UIViewController *viewController = [[CTMediator sharedInstance] CTMediator_viewControllerForLoginCoordinator];
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
window.rootViewController = viewController;
[window makeKeyAndVisible];
}
-(void)showNew{
......
......@@ -10,13 +10,121 @@
#ifndef CommonMacros_h
#define CommonMacros_h
#pragma mark - ——————— 用户相关 ————————
#pragma 通知
#define kNotification_update_authStatus @"Notification_update_authStatus" //认证状态
#define KNotification_toAuthStatus @"Notification_toAuthStatus" //咨询页认证通知
#define kNotification_update_recordStatus @"Notification_update_recordStatus" //备案状态
#define kNotification_update_mine_info @"Notification_update_mine_info"
#define kNotification_update_mine_info_more @"Notification_update_mine_info_more"
#define kNotification_update_bank_info_info @"Notification_update_bank_info_info"
#define kNotification_selected_mine_bank_card @"Notification_selected_mine_bank_card"
#define kNotification_delete_bank @"Notification_delete_bank"
#define kNotification_new_sufferer @"Notification_new_sufferer"//新患者通知
#define kNotification_visitAgain @"Notification_visitAgain"//随访通知
#define kNotification_newRequire @"Notification_newRequire"//求药通知
#define kNotification_IMNew_sufferer @"Notification_newIM_sufferer"//IM新患者通知
#define kNotification_sufferer_group_update @"Notification_sufferer_group_update"//分组更新
#define NOTIFICATION_RESIGN_ACTIVE @"appResignActive"//进入后台通知
#define NOTIFICATION_BECOME_ACTIVE @"appBecomeActive"//进入前台通知
#define notificationCenter_newChat @"notificationCenter_newChat" //新消息通知
#define NotificationcheckRecomandId @"messageUpdateWithRecomandId" //审核更改
#define NotificationPrescriptionSign @"prescriptionSignNotice" //处方签名通知
#define NotificationFaceRecognition @"faceRecognition" //人脸识别通知
#define BeginVoiceRecord @"notificationCenter_beginVoiceRecord" //开始录音
#define qlkDurgNotificationCenter @"qlkDurgNotification" //药品链接通知
#define qlkMedichienDeleteAction @"qlkMedichienDeleteNotification" //药品确认页删除药品
#define NotificationCloseVoice @"CloseVoiceAnimation" //关闭语音动画
#define finishDownLoadNotification @"FinishDownLoad" //下载完成
#define NotificatioinPatientByMdc @"TimeOutOfPatientByMdc" //系统确认购药
#define NotificationReservationId @"videoReservationId" //视屏预约通知
#define NotificationReservationIdAdd @"videoReservationIdNumAdd" //视屏红点数量
#define NotificationShowSignInView @"ShowSignInView" // 恢复签到遮罩View通知
#define NotificationCloseByNotificationMaskView @"NotificationMaskView" //关闭签到页面的通知
#define kVideoEndEventNotification @"VideoEndEventNotification" //视频结束通知
#define deleteSuffererNotification @"deleteSuffererNotification"
#define MWPHOTO_DOUBLETAP @"MWPHOTO_DOUBLETAP"
#pragma mark - ——————— 网络状态相关 ————————
#define HomeRefrashData @"refreshHomeConfigData" //刷新首页
#define DeleteSystemMsgData @"DeleteSystemMessageData" //删除通过push点击
#define notificationSystemMsgData @"QLKSystemMessageData" //系统消息通知
#define notificationConsultData @"QLKReloadConsultData"
#define notificationHomeSignDataReFresh @"notificationHomeSignDataReFresh"
#define notificationConsultDataSingleState @"QLKReloadConsultDataSingleState"
#define notificationRequestSufferersNumber @"QLKRequestSufferersNumber"
#define kCheckH5ConfigVersion @"QLKCheckH5ConfigVersion"
#define NotificationSignInEncouragePointsViewRemove @"SignInEncouragePointsViewRemove"//其他弹框出现时,移除该签到积分的view的通知
#define kNotification_update_groups @"Notification_update_groups" //更新分组
#define kNotification_update_groups_text @"Notification_update_groups_text" //更新分组文本 病历中使用
#define KNotification_jumpIntoLoginVC @"QLKLoginMainViewController" //后端返回错误码,vc 切换为登录页面
#define kNotification_update_medical_history_resource @"Notification_update_medical_history_resource"
//网络状态变化
#define KNotificationNetWorkStateChange @"KNotificationNetWorkStateChange"
#define QLKUpdatePrice_NOT @"QLKUpdatePrice_NOT" //改价通知
#define kNotificationInvalidPrescriptMedical @"Notification_invalid_prescript_medical_record" //处方或病历的作废通知
#pragma 参数
#define consumer_Phone (@"0571-29601197")
#define weixin_AppId (@"wxc3ca4f0be2d94db4")
#define weixin_Secret (@"b871f2b9deeae8cb67bef293ccc6b747")
#define qq_AppId (@"1104685355")
#define qq_Secret (@"fQEWrfKIjbffAP2B")
#define UmengShareAppkey @"53290df956240b6b4a0084b3"
#pragma 常量字符串
#define QLK_PAYSETTING_STATE @"qlk_paysetting_state"
#define QLK_PAYSETTING_PRICE @"qlk_paysetting_price"
#define QLK_ClickComment @"QLK_ClickComment"//-wfh- 2.9新加记录用户是否第一次点击评价的标示 key
#define QLK_DoctorClickComment @"QLK_DoctorClickComment"//-wfh- 2.9新加记录用户是否第一次点击评价的标示 value
#define QLKSimulationToken @"QLKSimulationToken"
#define productList_Search (@"productListSearch")
#define ProductImagView @"ProductImagView"
#define NewMsgId @"NewMsgId"//公告虚拟id
#define QLK_chatListHelpShow (@"chatListHelpShow")
#define QLK_save (@"save")
#define toastTextFontSize 15.0
#define newHomeViewTag 1000101
#define BannerBelowViewHeight 52
#define IPHONE5_HEIGHT 568
#define kUnifiedTableViewCellHeight 50
#define kNaviHeight 64 // 导航栏和状态栏高度
// 空字符串转为@""
#define S(x) (x ? x : @"")
#pragma 提示语
#define kEmptyPhoneNumberHint @"请输入手机号码"
#define kErrPhoneNumberHint @"请输入正确的手机号码"
#define kEmptyVerifyCodeHint @"请输入验证码"
#define kEmptyPassword @"请输入9-16位新密码"
#define kPasswordInconformity @"密码不符合规则"
#define kErrNetworkStatus @"网络请求失败,请检查您的网络设置"
#define KErrNoService @"当前网络不给力,请检查网络稍后再试~"
#define KErrDataMsg @"数据异常"
#define KnowMsg @"知道了"
#define ctnMedicen @"继续推荐"
#define ToauthStatus @"去认证"
#define CancleauthStatus @"暂不认证"
#define ToRecordStatus @"去备案"
#define CanclRecordStatus @"暂不备案"
#define checkvideoStatus @"需要通过身份认证\n方可开通视频咨询"
#define cheakingVideoStaus @"您的身份认证正在审核中,通过后才能使用此功能哦!"
#define newHomeAutherStatus @"通过身份认证后可体验更多功能哦"
#define medicenAutherStatus @"由于您尚未通过身份认证审核,仅有有限的推荐用药次数。建议前往进行身份认证!"
#define failWithCheakStatus @"请您完成医生认证后再使用此功能!"
#define cheakingStaus @"您的身份认证正在审核中,请您耐心等待!"
#define recordingFailStaus @"请您完成医生多点执业备案后再使用此功能!"
#define recordingStaus @"您的医生多点执业备案正在审核中,请您耐心等待!"
#define cheakinghealthyStaus @"您的身份认证正在审核中,通过后才能推荐检查哦!"
#define MedchineMsg @"患者提交了处方药购药咨询,请解答患者的相关问题,您可以点击用药确认或重新推荐相关药品"
#define endMsgPrompt @"由于超过30分钟未解答患者的购药咨询,已由药师处理,患者购药后您将不能获得相应积分"
//电子签名和备案
#define requireRecord @"根据卫健委要求,也是为了保障您的处方行为真实有效,请提交互联网医院备案资料"
#define recordFail @"抱歉,您的互联网医院备案审核未通过,请重新提交。"
#define recordAfterCancelContent @"稍后您可以在个人中心>互联网医院备案,提交备案资料"
#endif /* QLKStatic_Stringi_h */
#endif /* CommonMacros_h */
......@@ -66,6 +66,12 @@
#define DLog(...)
#endif
///输入框字数限制
#define kAccountMaxLength 11 //手机号长度限制
#define kPassswordMaxLength 16 //登录密码长度最大限制
#define kPassswordMinLength 9 //登录密码长度最小限制
#define kVerifyCodeMaxLength 4 //验证码长度限制
//拼接字符串
#define NSStringFormat(format,...) [NSString stringWithFormat:format,##__VA_ARGS__]
......
//
// NRNetworkManager.h
// NetrainFrame
//
// Created by Gin on 2020/10/13.
//
#import <Foundation/Foundation.h>
@class NRReachability;
NS_ASSUME_NONNULL_BEGIN
@interface NRNetworkManager : NSObject
SINGLETON_FOR_HEADER(NRNetworkManager)
@property (nonatomic,strong) NRReachability *hostReachability;
-(BOOL/*判断当否有网络*/)currentReachable;
@end
NS_ASSUME_NONNULL_END
//
// NRNetworkManager.m
// NetrainFrame
//
// Created by Gin on 2020/10/13.
//
#import "NRNetworkManager.h"
#import "NRReachability.h"
@implementation NRNetworkManager
SINGLETON_FOR_CLASS(NRNetworkManager)
-(void)checkNetwork{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanging:) name:qlkReachabilityChangedNotification object:nil];
self.hostReachability = [NRReachability reachabilityWithHostName:[NRGlobalUrlModel sharedInstance].kHost];
[self.hostReachability startNotifier];
[self updateInterfaceWithReachability:self.hostReachability];
}
- (void) reachabilityChanging:(NSNotification *)note
{
NRReachability* curReach = [note object];
NSParameterAssert([curReach isKindOfClass:[NRReachability class]]);
[self updateInterfaceWithReachability:curReach];
}
-(BOOL/*判断当否有网络*/)currentReachable{
struct sockaddr_in zeroAddress;
bzero(&zeroAddress, sizeof(zeroAddress));
zeroAddress.sin_len = sizeof(zeroAddress);
zeroAddress.sin_family = AF_INET;
// Recover reachability flags
SCNetworkReachabilityRef defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&zeroAddress);
SCNetworkReachabilityFlags flags;
BOOL didRetrieveFlags = SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags);
CFRelease(defaultRouteReachability);
if (!didRetrieveFlags)
{
return NO;
}
BOOL isReachable = flags & kSCNetworkFlagsReachable;
BOOL needsConnection = flags & kSCNetworkFlagsConnectionRequired;
return (isReachable && !needsConnection) ? YES : NO;
}
- (void/*获取当前网络状态*/)updateInterfaceWithReachability:(NRReachability *)reachability
{
if (reachability == self.hostReachability){
qlkNetworkStatus netStatus = [reachability currentReachabilityStatus];
}
}
@end
/*
Copyright (C) 2016 Apple Inc. All Rights Reserved.
See LICENSE.txt for this sample’s licensing information
Abstract:
Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
*/
#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <netinet/in.h>
typedef enum : NSInteger {
qlkNotReachable = 0,
qlkReachableViaWiFi,
qlkReachableViaWWAN,
kReachableVia2G,
kReachableVia3G,
kReachableVia4G
} qlkNetworkStatus;
#pragma mark IPv6 Support
//Reachability fully support IPv6. For full details, see ReadMe.md.
extern NSString *qlkReachabilityChangedNotification;
@interface NRReachability : NSObject
/*!
* Use to check the reachability of a given host name.
*/
+ (instancetype)reachabilityWithHostName:(NSString *)hostName;
/*!
* Use to check the reachability of a given IP address.
*/
+ (instancetype)reachabilityWithAddress:(const struct sockaddr *)hostAddress;
/*!
* Checks whether the default route is available. Should be used by applications that do not connect to a particular host.
*/
+ (instancetype)reachabilityForInternetConnection;
#pragma mark reachabilityForLocalWiFi
//reachabilityForLocalWiFi has been removed from the sample. See ReadMe.md for more information.
//+ (instancetype)reachabilityForLocalWiFi;
/*!
* Start listening for reachability notifications on the current run loop.
*/
- (BOOL)startNotifier;
- (void)stopNotifier;
- (qlkNetworkStatus)currentReachabilityStatus;
/*!
* WWAN may be available, but not active until a connection has been established. WiFi may require a connection for VPN on Demand.
*/
- (BOOL)connectionRequired;
/**
* 获取运营商编码
* @return 1-中国移动, 2-中国联通, 3-中国电信
*/
- (int)getMobileNetworkCode;
@end
/*
Copyright (C) 2016 Apple Inc. All Rights Reserved.
See LICENSE.txt for this sample’s licensing information
Abstract:
Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
*/
#import <arpa/inet.h>
#import <ifaddrs.h>
#import <netdb.h>
#import <sys/socket.h>
#import <netinet/in.h>
#import <CoreFoundation/CoreFoundation.h>
#import<CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>
#import "NRReachability.h"
#pragma mae
//Reachability fully support IPv6. For full details, see ReadMe.md.
NSString *const kLocalWiFiConnection = @"LocalWiFiConnection";
NSString *qlkReachabilityChangedNotification = @"qlkNetworkReachabilityChangedNotification";
#pragma mark - Supporting functions
#define kShouldPrintReachabilityFlags 1
static void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment)
{
#if kShouldPrintReachabilityFlags
NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n",
(flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
(flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
(flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
(flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
(flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
(flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
(flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
(flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
(flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-',
comment
);
#endif
}
static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)
{
#pragma unused (target, flags)
NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback");
NSCAssert([(__bridge NSObject*) info isKindOfClass: [NRReachability class]], @"info was wrong class in ReachabilityCallback");
NRReachability* noteObject = (__bridge NRReachability *)info;
// Post a notification to notify the client that the network reachability changed.
[[NSNotificationCenter defaultCenter] postNotificationName: qlkReachabilityChangedNotification object: noteObject];
}
#pragma mark - Reachability implementation
@implementation NRReachability
{
SCNetworkReachabilityRef _reachabilityRef;
}
+ (instancetype)reachabilityWithHostName:(NSString *)hostName
{
NRReachability* returnValue = NULL;
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]);
if (reachability != NULL)
{
returnValue= [[self alloc] init];
if (returnValue != NULL)
{
returnValue->_reachabilityRef = reachability;
}
else {
CFRelease(reachability);
}
}
return returnValue;
}
+ (instancetype)reachabilityWithAddress:(const struct sockaddr *)hostAddress
{
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, hostAddress);
NRReachability* returnValue = NULL;
if (reachability != NULL)
{
returnValue = [[self alloc] init];
if (returnValue != NULL)
{
returnValue->_reachabilityRef = reachability;
}
else {
CFRelease(reachability);
}
}
return returnValue;
}
+ (instancetype)reachabilityForInternetConnection
{
struct sockaddr_in zeroAddress;
bzero(&zeroAddress, sizeof(zeroAddress));
zeroAddress.sin_len = sizeof(zeroAddress);
zeroAddress.sin_family = AF_INET;
return [self reachabilityWithAddress: (const struct sockaddr *) &zeroAddress];
}
#pragma mark reachabilityForLocalWiFi
//reachabilityForLocalWiFi has been removed from the sample. See ReadMe.md for more information.
//+ (instancetype)reachabilityForLocalWiFi
#pragma mark - Start and stop notifier
- (BOOL)startNotifier
{
BOOL returnValue = NO;
SCNetworkReachabilityContext context = {0, (__bridge void *)(self), NULL, NULL, NULL};
if (SCNetworkReachabilitySetCallback(_reachabilityRef, ReachabilityCallback, &context))
{
if (SCNetworkReachabilityScheduleWithRunLoop(_reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode))
{
returnValue = YES;
}
}
return returnValue;
}
- (void)stopNotifier
{
if (_reachabilityRef != NULL)
{
SCNetworkReachabilityUnscheduleFromRunLoop(_reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
}
}
- (void)dealloc
{
[self stopNotifier];
if (_reachabilityRef != NULL)
{
CFRelease(_reachabilityRef);
}
}
#pragma mark - Network Flag Handling
- (qlkNetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags
{
if ((flags & kSCNetworkReachabilityFlagsReachable) == 0)
{
// The target host is not reachable.
return qlkNotReachable;
}
qlkNetworkStatus returnValue = qlkNotReachable;
if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0)
{
/*
If the target host is reachable and no connection is required then we'll assume (for now) that you're on Wi-Fi...
*/
returnValue = qlkReachableViaWiFi;
}
if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) ||
(flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))
{
/*
... and the connection is on-demand (or on-traffic) if the calling application is using the CFSocketStream or higher APIs...
*/
if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0)
{
/*
... and no [user] intervention is needed...
*/
returnValue = qlkReachableViaWiFi;
}
}
if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN)
{
/*
... but WWAN connections are OK if the calling application is using the CFNetwork APIs.
*/
CTTelephonyNetworkInfo * info = [[CTTelephonyNetworkInfo alloc] init];
NSString *currentRadioAccessTechnology = info.currentRadioAccessTechnology;
if (currentRadioAccessTechnology) {
if ([CTRadioAccessTechnologyLTE isEqualToString:currentRadioAccessTechnology]) {
returnValue = kReachableVia4G;
}
else if ([CTRadioAccessTechnologyEdge isEqualToString:currentRadioAccessTechnology] || [currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) {
returnValue = kReachableVia2G;
}
else {
returnValue = kReachableVia3G;
}
return returnValue;
}
if ((flags & kSCNetworkReachabilityFlagsTransientConnection) == kSCNetworkReachabilityFlagsTransientConnection) {
if((flags & kSCNetworkReachabilityFlagsConnectionRequired) == kSCNetworkReachabilityFlagsConnectionRequired) {
returnValue = kReachableVia2G;
return returnValue;
}
returnValue = kReachableVia3G;
return returnValue;
}
returnValue = qlkReachableViaWWAN;
}
return returnValue;
}
- (BOOL)connectionRequired
{
NSAssert(_reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef");
SCNetworkReachabilityFlags flags;
if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags))
{
return (flags & kSCNetworkReachabilityFlagsConnectionRequired);
}
return NO;
}
- (qlkNetworkStatus)currentReachabilityStatus
{
NSAssert(_reachabilityRef != NULL, @"currentNetworkStatus called with NULL SCNetworkReachabilityRef");
qlkNetworkStatus returnValue = qlkNotReachable;
SCNetworkReachabilityFlags flags;
if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags))
{
returnValue = [self networkStatusForFlags:flags];
}
return returnValue;
}
- (int)getMobileNetworkCode
{
int ret = 0;
CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [info subscriberCellularProvider];
if (carrier == nil) {
return ret;
}
NSString *code = [carrier mobileNetworkCode];
if (code == nil) {
return ret;
}
/**
00 中国移动
01 中国联通
02 中国移动
03 中国电信
05 中国电信
06 中国联通
07 中国移动
20 中国电信
*/
if ([code isEqualToString:@"00"] || [code isEqualToString:@"02"] || [code isEqualToString:@"07"]) {
ret = 1;
}else if ([code isEqualToString:@"01"] || [code isEqualToString:@"06"]){
ret = 2;
}else {
ret = 3;
}
return ret;
}
@end
//
// NRHomeViewController.h
// NetrainFrame
//
// Created by Gin on 2020/10/13.
//
#import "NRCommonViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface NRHomeViewController : NRCommonViewController
@end
NS_ASSUME_NONNULL_END
//
// NRHomeViewController.m
// NetrainFrame
//
// Created by Gin on 2020/10/13.
//
#import "NRHomeViewController.h"
@interface NRHomeViewController ()
@end
@implementation NRHomeViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
/*
#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
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="NRHomeViewController">
<connections>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="恭喜你,登录成功了!" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FLD-n7-M0w">
<rect key="frame" x="70" y="432" width="274" height="32.5"/>
<fontDescription key="fontDescription" type="system" pointSize="27"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<viewLayoutGuide key="safeArea" id="Q5M-cg-NOt"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="FLD-n7-M0w" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="HRd-Sw-w58"/>
<constraint firstItem="FLD-n7-M0w" firstAttribute="centerY" secondItem="i5M-Pr-FkT" secondAttribute="centerY" id="uvJ-Kg-pcA"/>
</constraints>
<point key="canvasLocation" x="218.84057971014494" y="131.91964285714286"/>
</view>
</objects>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
//
// CTMediator+HomeCoordinatorActions.h
// NetrainFrame
//
// Created by Gin on 2020/10/13.
//
#import <CTMediator/CTMediator.h>
NS_ASSUME_NONNULL_BEGIN
@interface CTMediator (HomeCoordinatorActions)
- (UIViewController *)CTMediator_viewControllerForHomeCoordinator;
@end
NS_ASSUME_NONNULL_END
//
// CTMediator+HomeCoordinatorActions.m
// NetrainFrame
//
// Created by Gin on 2020/10/13.
//
#import "CTMediator+HomeCoordinatorActions.h"
NSString * const kCTMediatorTargetHomeCoordinator = @"HomeCoordinator";
NSString * const kCTMediatorActionHomeCoordinatorRootController = @"HomeCoordinatorRootController";
@implementation CTMediator (HomeCoordinatorActions)
- (UIViewController *)CTMediator_viewControllerForHomeCoordinator{
UIViewController *viewController = [self performTarget:kCTMediatorTargetHomeCoordinator
action:kCTMediatorActionHomeCoordinatorRootController
params:nil
shouldCacheTarget:NO
];
if (viewController) {
// view controller 交付出去之后,可以由外界选择是push还是present
return viewController;
} else {
// 这里处理异常场景,具体如何处理取决于产品
return [[UINavigationController alloc] init];
}
}
@end
//
// Target_HomeCoordinator.h
// NetrainFrame
//
// Created by Gin on 2020/10/13.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface Target_HomeCoordinator : NSObject
- (UIViewController *)Action_HomeCoordinatorRootController:(NSDictionary *)params;
@end
NS_ASSUME_NONNULL_END
//
// Target_HomeCoordinator.m
// NetrainFrame
//
// Created by Gin on 2020/10/13.
//
#import "Target_HomeCoordinator.h"
#import "NRHomeViewController.h"
#import "NRCommonNavigationViewController.h"
@implementation Target_HomeCoordinator
- (UIViewController *)Action_HomeCoordinatorRootController:(NSDictionary *)params{
NRHomeViewController *vc = [[NRHomeViewController alloc] init];
NRCommonNavigationViewController *navigationController = [[NRCommonNavigationViewController alloc] initWithRootViewController:vc];
return navigationController;
}
@end
......@@ -6,12 +6,18 @@
//
#import "NRCommonViewController.h"
@class MainCoordinator;
@protocol NRLoginViewControllerDelegate <NSObject>
- (void)loginSuccessAction;
@end
NS_ASSUME_NONNULL_BEGIN
@interface NRLoginViewController : NRCommonViewController
@property(weak, nonatomic) MainCoordinator *coordinator;
@property(nonatomic, weak) id<NRLoginViewControllerDelegate> controllerDelegate;
@end
......
......@@ -7,6 +7,7 @@
#import "NRLoginViewController.h"
#import "NRLoginLogic.h"
#import "NRCountDownButton.h"
typedef NS_ENUM(NSUInteger, UserSelectLoginMode) {
passswdLogin = 10, //密码登录
......@@ -19,15 +20,12 @@ typedef NS_ENUM(NSUInteger, UserSelectLoginMode) {
@property (weak, nonatomic) IBOutlet QMUITextField *passwdField;
@property (weak, nonatomic) IBOutlet UIButton *showPwdBtn;
@property (weak, nonatomic) IBOutlet UIButton *loginButton;
@property (weak, nonatomic) IBOutlet UIButton *verificationBtn;
@property (weak, nonatomic) IBOutlet NRCountDownButton *verificationBtn;
@property (weak, nonatomic) IBOutlet UIImageView *verificationBtnBottomArc;
@property (weak, nonatomic) IBOutlet UIButton *passwdLogBtn;
@property (weak, nonatomic) IBOutlet UIImageView *passwdBtnBottomArc;
@property (weak, nonatomic) IBOutlet UIButton *verificationLogBtn;
@property (assign, nonatomic) UserSelectLoginMode loginMode;
@property (strong,nonatomic) NSDate *resignBackgroundDate;
@property (assign,nonatomic) int timeout;
@property (strong,nonatomic) NSTimer* countDownTimer;
@property (weak, nonatomic) IBOutlet UIView *forgetAndRegisterView;
@property (weak, nonatomic) IBOutlet UIView *accountView;
@property (weak, nonatomic) IBOutlet UIButton *registerButton;
......@@ -40,11 +38,6 @@ typedef NS_ENUM(NSUInteger, UserSelectLoginMode) {
@end
#define kAccountMaxLength 11 //手机号长度限制
#define kPassswordMaxLength 16 //登录密码长度最大限制
#define kPassswordMinLength 9 //登录密码长度最小限制
#define kVerifyCodeMaxLength 4 //验证码长度限制
@implementation NRLoginViewController
-(BOOL)preferredNavigationBarHidden{
......@@ -71,7 +64,6 @@ typedef NS_ENUM(NSUInteger, UserSelectLoginMode) {
[self.forgetAndRegisterDividingLine setBackgroundColor:UIColorThemeBorderColor];
[self.passwdLogBtn setTitleColor:UIColorThemeColor forState:UIControlStateSelected];
[self.verificationLogBtn setTitleColor:UIColorThemeColor forState:UIControlStateSelected];
[self.verificationBtn setTitleColor:UIColorThemeButtonBlackColor forState:UIControlStateNormal];
}
-(void)configSubviews{
......@@ -121,10 +113,22 @@ typedef NS_ENUM(NSUInteger, UserSelectLoginMode) {
}
#pragma mark -- NRLoginLogicDelegate
-(void)sendMessageCompleted:(BaseHttpModel *)httpModel{
[QMUITips hideAllTips];
if(httpModel.isSucc){
[QMUITips showSucceed:httpModel.errorMsg];
[self.verificationBtn startTimer];
}else{
[QMUITips showError:httpModel.errorMsg];
}
}
-(void)requestDataCompleted:(BaseHttpModel *)httpModel{
[QMUITips hideAllTips];
if(httpModel.isSucc){
[QMUITips showSucceed:httpModel.errorMsg];
if(self.controllerDelegate && [self.controllerDelegate respondsToSelector:@selector(loginSuccessAction)]){
[self.controllerDelegate loginSuccessAction];
}
}else{
[QMUITips showError:httpModel.errorMsg];
}
......@@ -218,7 +222,7 @@ typedef NS_ENUM(NSUInteger, UserSelectLoginMode) {
}
}
}
#pragma mark -- setter/getter
-(NRLoginLogic *)loginLogic{
if(!_loginLogic){
_loginLogic = [[NRLoginLogic alloc] init];
......
......@@ -7,10 +7,20 @@
#import "NRCommonViewController.h"
@protocol NRRegisterViewControllerDelegate <NSObject>
///用户协议
- (void)toUserProtocolAction;
///隐私政策
- (void)toPrivacyPolicyAction;
@end
NS_ASSUME_NONNULL_BEGIN
@interface NRRegisterViewController : NRCommonViewController
@property(nonatomic, weak) id<NRRegisterViewControllerDelegate> controllerDelegate;
@end
NS_ASSUME_NONNULL_END
......@@ -6,8 +6,36 @@
//
#import "NRRegisterViewController.h"
#import "NRRegisterLogic.h"
#import "NRCountDownButton.h"
@interface NRRegisterViewController ()
@interface NRRegisterViewController ()<QMUITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UIView *backView;
@property (weak, nonatomic) IBOutlet QMUITextField *nameTextField;//姓名输入框
@property (weak, nonatomic) IBOutlet QMUITextField *phoneTextField;//显示电话号码输入框
@property (weak, nonatomic) IBOutlet QMUITextField *passwordTextField;//密码输入框
@property (weak, nonatomic) IBOutlet UIButton *registerButton;//注册按钮
@property (weak, nonatomic) IBOutlet UIButton *confirmButton;//是否同意注册协议按钮
@property (strong, nonatomic) IBOutlet UILabel *nameValidLabel;//姓名文本框
@property (strong, nonatomic) IBOutlet UILabel *passwordValidLabel;//密码文本框
@property (weak, nonatomic) IBOutlet UIButton *protocolBtn;
@property (weak, nonatomic) IBOutlet UIButton *privacyPolicyBtn;//隐私政策按钮
@property (weak, nonatomic) IBOutlet QMUITextField *checkCodeTF;///验证码输入框
@property (weak, nonatomic) IBOutlet NRCountDownButton *verificationBtn;
@property (assign,nonatomic) int timeout;
@property (strong,nonatomic) NSTimer* countDownTimer;
@property (weak, nonatomic) IBOutlet UIView *passwordView;
@property (weak, nonatomic) IBOutlet UIView *nameView;
@property (weak, nonatomic) IBOutlet UIView *accountView;
@property (weak, nonatomic) IBOutlet UIView *phoneView;
@property (weak, nonatomic) IBOutlet UIView *line1;
@property (weak, nonatomic) IBOutlet UIView *line2;
@property (weak, nonatomic) IBOutlet UIView *line3;
@property (weak, nonatomic) IBOutlet UIView *line4;
///Logic
@property(strong, nonatomic) NRRegisterLogic *registerLogic;
@end
......@@ -17,13 +45,148 @@
return NO;
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.verificationBtn removeTimer];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self configSubviews];
// Do any additional setup after loading the view.
}
-(void)dealloc{
NSLog(@"register delloc");
- (void)initSubviews{
[super initSubviews];
self.passwordValidLabel.textColor = UIColorThemeColor;
if (@available(iOS 11.0, *)) {
self.passwordTextField.textContentType = UITextContentTypeName;
}
}
-(void)configSubviews{
self.nameTextField.delegate = self;
self.phoneTextField.delegate = self;
self.checkCodeTF.delegate = self;
self.passwordTextField.delegate = self;
[self.nameTextField addTarget:self action:@selector(textFieldDidChange)
forControlEvents:UIControlEventEditingChanged];
[self.phoneTextField addTarget:self action:@selector(textFieldDidChange)
forControlEvents:UIControlEventEditingChanged];
[self.checkCodeTF addTarget:self action:@selector(textFieldDidChange)
forControlEvents:UIControlEventEditingChanged];
[self.passwordTextField addTarget:self action:@selector(textFieldDidChange)
forControlEvents:UIControlEventEditingChanged];
}
#pragma mark -- QMUITextFieldDelegate
-(void)textFieldDidBeginEditing:(UITextField *)textField{
if(textField == self.nameTextField){
self.line1.backgroundColor = UIColorThemeBorderColor;
}else if(textField == self.phoneTextField){
self.line2.backgroundColor = UIColorThemeBorderColor;
}else if(textField == self.checkCodeTF){
self.line3.backgroundColor = UIColorThemeBorderColor;
}else {
self.line4.backgroundColor=UIColorThemeBorderColor;
}
}
- (void)textFieldDidChange{
[self checkRegisterStatus];
}
-(void)textFieldDidEndEditing:(UITextField *)textField{
if(textField == self.nameTextField){
self.line1.backgroundColor = UIColorThemeLineColor;
}else if(textField == self.phoneTextField){
self.line2.backgroundColor = UIColorThemeLineColor;
}else if(textField == self.checkCodeTF){
self.line3.backgroundColor = UIColorThemeLineColor;
}else{
self.line4.backgroundColor=UIColorThemeLineColor;
}
}
#pragma mark -- IBAaction
- (IBAction)privacyPolicyBtnAction:(id)sender {//隐私政策];
if(self.controllerDelegate && [self.controllerDelegate respondsToSelector:@selector(toPrivacyPolicyAction)]){
[self.controllerDelegate toPrivacyPolicyAction];
}
}
- (IBAction)isAgreeUserProtocol:(id)sender{
UIButton *btn = (UIButton *)sender;
btn.selected = !btn.selected;
[self checkRegisterStatus];
}
- (IBAction)userProtocolBtnAction:(id)sender {//用户协议
if(self.controllerDelegate && [self.controllerDelegate respondsToSelector:@selector(toUserProtocolAction)]){
[self.controllerDelegate toUserProtocolAction];
}
}
- (IBAction)registerAction:(id)sender {//注册
if (![self.nameTextField.text isMatchName]) {
self.nameValidLabel.text = @"名字不能包含表情、特殊字符等";
return;
}
if (!self.confirmButton.isSelected) {
[QMUITips showError:@"同意互联网医院注册协议才可以注册"];
return;
}
NSMutableDictionary *params = [NSMutableDictionary dictionary];
params[@"name"] = self.nameTextField.text;
params[@"phoneNum"] = self.phoneTextField.text;
params[@"inviterCode"] = self.checkCodeTF.text;
params[@"password"] = self.passwordTextField.text;
params[@"purepassword"] = self.passwordTextField.text;
params[@"regSource"] = @"0";
[self.registerLogic registerRequestStepWithParams:params.copy];
}
- (IBAction)getVerficationAction:(id)sender {
[self.verificationBtn startTimer];
// [self.registerLogic getVerifyCodeWithPhoneNumber:self.phoneTextField.text];
}
- (IBAction)isShowAction:(id)sender {
UIButton *btn = (UIButton *)sender;
btn.selected = !btn.selected;
self.passwordTextField.secureTextEntry = btn.selected ? NO : YES;
}
#pragma mark -- private method
//按钮状态随文本变化而变化
- (void)checkRegisterStatus{
if(self.nameTextField.text.isNotBlank && self.checkCodeTF.text.length == kVerifyCodeMaxLength && self.passwordTextField.text.length >= kPassswordMinLength && self.passwordTextField.text.length <= kPassswordMaxLength && self.phoneTextField.text.length == kAccountMaxLength && self.confirmButton.isSelected) {
self.registerButton.enabled = YES;
}
else{
if(self.registerButton.isEnabled){
self.registerButton.enabled = NO;
}
}
if(self.phoneTextField.text.length == kAccountMaxLength) {
self.verificationBtn.enabled = YES;
}else{
if(self.verificationBtn.isEnabled){
self.verificationBtn.enabled = NO;
}
}
}
#pragma mark -- setter/getter
-(NRRegisterLogic *)registerLogic{
if(!_registerLogic){
_registerLogic = [[NRRegisterLogic alloc] init];
// _registerLogic.logicDelegate = self;
}
return _registerLogic;
}
/*
......
......@@ -9,7 +9,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface CTMediator (MainCoordinatorActions)
@interface CTMediator (LoginCoordinatorActions)
- (UIViewController *)CTMediator_viewControllerForLoginCoordinator;
@end
......
......@@ -5,13 +5,13 @@
// Created by Gin on 2020/9/23.
//
#import "CTMediator+MainCoordinatorActions.h"
#import "CTMediator+LoginCoordinatorActions.h"
NSString * const kCTMediatorTargetLoginCoordinator = @"LoginCoordinator";
NSString * const kCTMediatorActionLoginCoordinatorRootController = @"LoginCoordinatorRootController";
@implementation CTMediator (MainCoordinatorActions)
@implementation CTMediator (LoginCoordinatorActions)
- (UIViewController *)CTMediator_viewControllerForLoginCoordinator{
UIViewController *viewController = [self performTarget:kCTMediatorTargetLoginCoordinator
......
......@@ -7,21 +7,28 @@
#import "Target_LoginCoordinator.h"
#import "NRLoginViewController.h"
#import "NRCommonNavigationViewController.h"
#import "CTMediator+HomeCoordinatorActions.h"
@interface Target_LoginCoordinator()
@interface Target_LoginCoordinator()<NRLoginViewControllerDelegate>
@property(nonatomic, weak) UINavigationController *navigationController;
@end
@implementation Target_LoginCoordinator
- (UIViewController *)Action_LoginCoordinatorRootController:(NSDictionary *)params{
NRLoginViewController *vc = [NRLoginViewController instantiateWithStoryboardName:@"NRLogin"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:vc];
NRLoginViewController *loginVC = [NRLoginViewController instantiateWithStoryboardName:@"NRLogin"];
loginVC.controllerDelegate = self;
NRCommonNavigationViewController *navigationController = [[NRCommonNavigationViewController alloc] initWithRootViewController:loginVC];
return navigationController;
}
- (void)loginSuccessAction{
UIWindow *window = [UIApplication sharedApplication].windows.firstObject;
UIViewController *viewController = [[CTMediator sharedInstance] CTMediator_viewControllerForHomeCoordinator];
window.rootViewController = viewController;
[window makeKeyAndVisible];
}
@end
......@@ -14,6 +14,11 @@
@protocol NRLoginLogicDelegate <NSObject>
@optional
/**
发送短信
*/
-(void)sendMessageCompleted:(BaseHttpModel *_Nullable)httpModel;
/**
数据加载完成
*/
......
......@@ -6,8 +6,6 @@
//
#import "NRLoginLogic.h"
#import "UIDevice+NRDevice.h"
#import "NSString+NRRSA.h"
#import "NRUserModel.h"
@implementation NRLoginLogic
......@@ -19,8 +17,8 @@
NSString *tvalue = [servertimeRequest.httpModel.data objectAtIndex:0];
[self sendVerifyCodeRequest:tvalue phoneNumber:phoneNumber];
}else{
if (self.logicDelegate && [self.logicDelegate respondsToSelector:@selector(requestDataCompleted:)]) {
[self.logicDelegate requestDataCompleted:request.httpModel];
if (self.logicDelegate && [self.logicDelegate respondsToSelector:@selector(sendMessageCompleted:)]) {
[self.logicDelegate sendMessageCompleted:request.httpModel];
}
}
}];
......@@ -35,8 +33,8 @@
if (!error) {
}
if (self.logicDelegate && [self.logicDelegate respondsToSelector:@selector(requestDataCompleted:)]) {
[self.logicDelegate requestDataCompleted:request.httpModel];
if (self.logicDelegate && [self.logicDelegate respondsToSelector:@selector(sendMessageCompleted:)]) {
[self.logicDelegate sendMessageCompleted:request.httpModel];
}
}];
}
......@@ -103,7 +101,8 @@
[pwdLoginRequest startWithCompletionBlock:^(NRBaseRequest * _Nonnull request, NSString * _Nonnull error) {
if(!error){
[pwdLoginRequest saveModel];
///TO DO 退出过程中有其他人登录该账号,该设备的记录将被清除
///TO DO 当deviceFlag == 0时,说明退出过程中有其他人登录该账号,该设备的记录将被清除
}
if (self.logicDelegate && [self.logicDelegate respondsToSelector:@selector(requestDataCompleted:)]) {
[self.logicDelegate requestDataCompleted:request.httpModel];
......
//
// NRRegisterLogic.h
// NetrainFrame
//
// Created by Gin on 2020/10/13.
//
#import <Foundation/Foundation.h>
#import "NRServerTimeRequest.h"
#import "NRVerifyCodeRequest.h"
#import "NRRegisterRequest.h"
#import "NRRegisterCheckVerifyCodeRequest.h"
#import "NRLoginPublicKeyRequest.h"
#import "NRPasswordLoginRequest.h"
#import "NRLoginKeyRequest.h"
@protocol NRRegisterLogicDelegate <NSObject>
@optional
/**
数据加载完成
*/
-(void)requestDataCompleted:(BaseHttpModel *_Nullable)httpModel;
@end
NS_ASSUME_NONNULL_BEGIN
@interface NRRegisterLogic : NSObject
@property(nonatomic,weak) id<NRRegisterLogicDelegate> logicDelegate;
- (void)getVerifyCodeWithPhoneNumber:(NSString *)phoneNumber;
- (void)registerRequestStepWithParams:(NSMutableDictionary *)params;
@end
NS_ASSUME_NONNULL_END
//
// NRRegisterLogic.m
// NetrainFrame
//
// Created by Gin on 2020/10/13.
//
#import "NRRegisterLogic.h"
@implementation NRRegisterLogic
- (void)getVerifyCodeWithPhoneNumber:(NSString *)phoneNumber{
NRServerTimeRequest *servertimeRequest = [[NRServerTimeRequest alloc] init];
[servertimeRequest startWithCompletionBlock:^(NRBaseRequest * _Nonnull request, NSString * _Nonnull error) {
if (!error) {
NSString *tvalue = [servertimeRequest.httpModel.data objectAtIndex:0];
[self sendVerifyCodeRequest:tvalue phoneNumber:phoneNumber];
}else{
// if (self.logicDelegate && [self.logicDelegate respondsToSelector:@selector(requestDataCompleted:)]) {
// [self.logicDelegate requestDataCompleted:request.httpModel];
// }
}
}];
}
- (void)sendVerifyCodeRequest:(NSString *)tvalue phoneNumber:(NSString *)phoneNumber{
NRVerifyCodeRequest *verifyCodeRequest = [[NRVerifyCodeRequest alloc] init];
verifyCodeRequest.phoneNumber = phoneNumber;
verifyCodeRequest.actionType = @"1";
verifyCodeRequest.tvalue = tvalue ? tvalue : @"";
[verifyCodeRequest startWithCompletionBlock:^(NRBaseRequest * _Nonnull request, NSString * _Nonnull error) {
if (!error) {
}
// if (self.logicDelegate && [self.logicDelegate respondsToSelector:@selector(requestDataCompleted:)]) {
// [self.logicDelegate requestDataCompleted:request.httpModel];
// }
}];
}
- (void)registerRequestStepWithParams:(NSMutableDictionary *)params{
///检查验证码
NRRegisterCheckVerifyCodeRequest *checkVerifyCodeRequest = [[NRRegisterCheckVerifyCodeRequest alloc] init];
checkVerifyCodeRequest.phoneNumber = params[@"phoneNum"];
checkVerifyCodeRequest.verifyCode = params[@"inviterCode"];
[checkVerifyCodeRequest startWithCompletionBlock:^(NRBaseRequest * _Nonnull request, NSString * _Nonnull error) {
if (!error) {
[self getRegisterPublicKeyRequest:params];
}
}];
}
-(void)getRegisterPublicKeyRequest:(NSMutableDictionary *)params{
NRLoginPublicKeyRequest *publicKeyRequest = [[NRLoginPublicKeyRequest alloc] init];
publicKeyRequest.phoneNumber = [params objectForKey:@"phoneNum"];
[publicKeyRequest startWithCompletionBlock:^(NRBaseRequest * _Nonnull request, NSString * _Nonnull error) {
if(!error){
NSString* pubKey = [[publicKeyRequest.httpModel.data objectAtIndex:0] objectForKey:@"publicKey"];
NSString *publicKey=[NSString formatPulicKeys:pubKey password:[params objectForKey:@"password"]];
if(!publicKey.isNotBlank){
return ;
}
[params setObject:publicKey forKey:@"password"];
[self registerActionRequest:params];
}else{
// if (self.logicDelegate && [self.logicDelegate respondsToSelector:@selector(requestDataCompleted:)]) {
// [self.logicDelegate requestDataCompleted:request.httpModel];
// }
}
}];
}
- (void)registerActionRequest:(NSMutableDictionary *)params{
NRRegisterRequest *registerRequest = [[NRRegisterRequest alloc] init];
registerRequest.params = params;
[registerRequest startWithCompletionBlock:^(NRBaseRequest * _Nonnull request, NSString * _Nonnull error) {
if(!error){
[self passwordLoginWithPhoneNumber:params[@"phoneNum"] password:params[@"purepassword"]];
}
// if (self.logicDelegate && [self.logicDelegate respondsToSelector:@selector(requestDataCompleted:)]) {
// [self.logicDelegate requestDataCompleted:request.httpModel];
// }
}];
}
- (void)passwordLoginWithPhoneNumber:(NSString *)phoneNumber password:(NSString *)password{
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
NRLoginKeyRequest *loginKeyRequest = [[NRLoginKeyRequest alloc] init];
loginKeyRequest.phoneNumber = phoneNumber;
[loginKeyRequest startWithCompletionBlock:^(NRBaseRequest * _Nonnull request, NSString * _Nonnull error) {
if(!error){
NSDictionary *loginKeyDict = [loginKeyRequest.httpModel.data objectAtIndex:0];
[params setObject:[loginKeyDict objectForKey:@"loginKey"] forKey:@"loginKey"];
[params setObject:[loginKeyDict objectForKey:@"loginId"] forKey:@"loginId"];
[params setObject:phoneNumber forKey:@"phoneNum"];
[params setObject:password forKey:@"password"];
[self getLoginPublicKeyRequest:params];
}else{
// if (self.logicDelegate && [self.logicDelegate respondsToSelector:@selector(requestDataCompleted:)]) {
// [self.logicDelegate requestDataCompleted:request.httpModel];
// }
}
}];
}
-(void)getLoginPublicKeyRequest:(NSMutableDictionary *)params{
NRLoginPublicKeyRequest *publicKeyRequest = [[NRLoginPublicKeyRequest alloc] init];
publicKeyRequest.phoneNumber = [params objectForKey:@"phoneNum"];
[publicKeyRequest startWithCompletionBlock:^(NRBaseRequest * _Nonnull request, NSString * _Nonnull error) {
if(!error){
NSString* pubKey = [[publicKeyRequest.httpModel.data objectAtIndex:0] objectForKey:@"publicKey"];
NSString *publicKey=[NSString formatPulicKeys:pubKey password:[params objectForKey:@"password"]];
if(!publicKey.isNotBlank){
request.httpModel.code = kHttpCode_NotPublic;
request.httpModel.msg = @"登录失败,请重新登录";
// if (self.logicDelegate && [self.logicDelegate respondsToSelector:@selector(requestDataCompleted:)]) {
// [self.logicDelegate requestDataCompleted:request.httpModel];
// }
return ;
}
[params setObject:publicKey forKey:@"password"];
[self passwordLoginRequest:params];
}else{
// if (self.logicDelegate && [self.logicDelegate respondsToSelector:@selector(requestDataCompleted:)]) {
// [self.logicDelegate requestDataCompleted:request.httpModel];
// }
}
}];
}
-(void)passwordLoginRequest:(NSMutableDictionary *)params{
NRPasswordLoginRequest *pwdLoginRequest = [[NRPasswordLoginRequest alloc] init];
NSString *deviceIdentifier = [UIDevice deviceIdentifier];
if (!deviceIdentifier.isNotBlank) {
deviceIdentifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
}
if(deviceIdentifier.isNotBlank){
[params setObject:deviceIdentifier forKey:@"deviceSN"];
}
pwdLoginRequest.params = params;
[pwdLoginRequest startWithCompletionBlock:^(NRBaseRequest * _Nonnull request, NSString * _Nonnull error) {
if(!error){
[pwdLoginRequest saveModel];
///TO DO 退出过程中有其他人登录该账号,该设备的记录将被清除
}
// if (self.logicDelegate && [self.logicDelegate respondsToSelector:@selector(requestDataCompleted:)]) {
// [self.logicDelegate requestDataCompleted:request.httpModel];
// }
}];
}
@end
......@@ -21,6 +21,9 @@
-(void)saveModel{
NSArray *arr = [[NRBaseModelAgent agent] createModel:NRUserModel.class fromJson:self.httpModel.data];
NRUserModel *userModel = [arr objectAtIndex:0];
if(!userModel.status){
userModel.status = @"4";
}
userModel.phoneNum = [self.params objectForKey:@"phoneNum"];
[[NRBaseModelAgent agent] writeModel:userModel];
}
......
//
// NRRegisterCheckVerifyCodeRequest.h
// NetrainFrame
//
// Created by Gin on 2020/10/13.
//
#import "NRBaseRequest.h"
NS_ASSUME_NONNULL_BEGIN
@interface NRRegisterCheckVerifyCodeRequest : NRBaseRequest
@property(nonatomic, copy) NSString *verifyCode;
@property(nonatomic, copy) NSString *phoneNumber;
@end
NS_ASSUME_NONNULL_END
//
// NRRegisterCheckVerifyCodeRequest.m
// NetrainFrame
//
// Created by Gin on 2020/10/13.
//
#import "NRRegisterCheckVerifyCodeRequest.h"
@implementation NRRegisterCheckVerifyCodeRequest
-(NSString *)requestUrl{
return @"login/validateRegist";
}
-(id)requestArgument{
return @{
@"phoneNum": self.phoneNumber,
@"verifyCode": self.verifyCode,
};
}
@end
......@@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface NRRegisterRequest : NRBaseRequest
@property(copy, nonatomic) NSDictionary *params;
@end
NS_ASSUME_NONNULL_END
......@@ -8,5 +8,12 @@
#import "NRRegisterRequest.h"
@implementation NRRegisterRequest
-(NSString *)requestUrl{
return @"login/regist";
}
-(id)requestArgument{
return self.params;
}
@end
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "navi_return_button@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "navi_return_button@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="kDB-rm-a1x">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<scene sceneID="KcI-v5-LXv">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<viewController storyboardIdentifier="LaunchScreen" id="kDB-rm-a1x" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="p2s-TZ-1jR"/>
<viewControllerLayoutGuide type="bottom" id="dsf-gh-mdf"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Tjz-N3-y2q">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="login_appicon" translatesAutoresizingMaskIntoConstraints="NO" id="rbb-XS-oyO">
<rect key="frame" x="130.5" y="809" width="153" height="30"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" secondItem="rbb-XS-oyO" secondAttribute="height" multiplier="51:10" id="5J6-qz-kPP"/>
<constraint firstAttribute="width" constant="153" id="Wok-Wh-glg"/>
</constraints>
</imageView>
</subviews>
<viewLayoutGuide key="safeArea" id="VkO-Ud-Kfo"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="rbb-XS-oyO" firstAttribute="centerX" secondItem="Tjz-N3-y2q" secondAttribute="centerX" id="kyL-dw-77I"/>
<constraint firstItem="dsf-gh-mdf" firstAttribute="top" secondItem="rbb-XS-oyO" secondAttribute="bottom" constant="23" id="z7R-IQ-KW7"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="RIj-UL-9zB" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
<point key="canvasLocation" x="52.173913043478265" y="375"/>
</scene>
</scenes>
<resources>
<image name="login_appicon" width="153" height="30"/>
</resources>
</document>
......@@ -7,15 +7,21 @@
#ifndef PrefixHeader_pch
#define PrefixHeader_pch
//全局宏
///全局宏
#import "UtilsMacros.h"
#import "URLMacros.h"
#import "FontAndColorMacros.h"
#import "ThirdMacros.h"
#import "NotificationMacros.h"
///Categories
#import "UIDevice+NRAdd.h"
#import "NSString+NRAdd.h"
//第三方
///
#import "NRGlobalUrlModel.h"
///第三方
#import <Masonry.h>
#import <YYModel.h>
#import <SDWebImage/UIImageView+WebCache.h>
......
//
// NRCountDownButton.h
// NetrainFrame
//
// Created by Gin on 2020/10/13.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface NRCountDownButton : UIButton
- (void)startTimer;
-(void)removeTimer;
@end
NS_ASSUME_NONNULL_END
//
// NRCountDownButton.m
// NetrainFrame
//
// Created by Gin on 2020/10/13.
//
#import "NRCountDownButton.h"
@interface NRCountDownButton ()
@property(nonatomic, strong)NSTimer *countDownTimer;
@property(nonatomic, assign)NSInteger timeout;
@property (strong,nonatomic) NSDate *resignBackgroundDate;
@end
@implementation NRCountDownButton
-(instancetype)initWithFrame:(CGRect)frame{
if(self = [super initWithFrame:frame]){
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(resignActiveToRecordState)
name:NOTIFICATION_RESIGN_ACTIVE
object:nil];////进入后台通知
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(becomeActiveToRecordState)
name:NOTIFICATION_BECOME_ACTIVE
object:nil];//进入前台通知
}
return self;
}
-(instancetype)initWithCoder:(NSCoder *)coder{
if(self = [super initWithCoder:coder]){
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(resignActiveToRecordState)
name:NOTIFICATION_RESIGN_ACTIVE
object:nil];////进入后台通知
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(becomeActiveToRecordState)
name:NOTIFICATION_BECOME_ACTIVE
object:nil];//进入前台通知
}
return self;
}
- (void)resignActiveToRecordState {
_resignBackgroundDate = [NSDate date];
}
- (void)becomeActiveToRecordState {
NSTimeInterval timeHasGone = [[NSDate date] timeIntervalSinceDate:_resignBackgroundDate];
if (_timeout - timeHasGone < 0) {
_timeout = 0;
}else{
_timeout = _timeout - timeHasGone;
}
}
- (void)startTimer{
_timeout = 59; //倒计时时间
[self setEnabled:NO];
_countDownTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
}
- (void)timeFireMethod{
if (_timeout > 0) {
_timeout--;
}else{
_timeout = 0;
}
if(_timeout==0){
[self setTitle:@"重新获取" forState:UIControlStateNormal];
[self setEnabled:YES];
[_countDownTimer invalidate];
}else{
int seconds = _timeout % 60;
[self setEnabled:NO];
NSString *strTime = [NSString stringWithFormat:@"%.2ds重试", seconds];
self.titleLabel.textAlignment = NSTextAlignmentCenter;
self.titleLabel.text = strTime;
[self setTitle:strTime forState:UIControlStateNormal];
NSLog(@"%d",seconds);
}
}
- (void)resetVerifyCode {
_timeout = 0;
[self setTitle:@"重新获取" forState:UIControlStateNormal];
[self setEnabled:YES];
[self removeTimer];
}
-(void)removeTimer{
[_countDownTimer invalidate];
_countDownTimer = nil;
}
-(void)dealloc{
NSLog(@"countdown button dealloc");
}
@end
......@@ -9,8 +9,12 @@
NS_ASSUME_NONNULL_BEGIN
@interface NSString (NRRSA)
@interface NSString (NRAdd)
///Match
- (BOOL)isMatchName;
///RSA
+(NSString*)formatPulicKeys:(NSString*)publicKey password:(NSString*)password;
@end
......
......@@ -5,7 +5,7 @@
// Created by Gin on 2020/9/24.
//
#import "NSString+NRRSA.h"
#import "NSString+NRAdd.h"
#import "BDRSACryptor.h"
#import "BDRSACryptorKeyPair.h"
......@@ -13,9 +13,24 @@
#define X509PublicHeader @"-----BEGIN PUBLIC KEY-----"
#define X509PublicFooter @"-----END PUBLIC KEY-----"
@implementation NSString (NRRSA)
@implementation NSString (NRAdd)
#pragma mark-导入公钥
#pragma mark -- Match
- (BOOL)isMatchName{
if(self.isNotBlank){
NSString *regex = @"^[A-Za-z0-9\u4e00-\u9fa5-/:;()$&@\".,?!'\\[\\]{}#%\\^*+=_\\\\|~&#%\\^*+=_\\\\|~&amp;#%\\^*+=_\\\\|~&#%\\^*+=_\\\\|~&amp;amp;#%\\^*+=_\\\\|~&#%\\^*+=_\\\\|~&amp;#%\\^*+=_\\\\|~&#%\\^*+=_\\\\|~&amp;amp;lt;&#%\\^*+=_\\\\|~&amp;amp;lt;&amp;#%\\^*+=_\\\\|~&#%\\^*+=_\\\\|~&amp;amp;lt;&#%\\^*+=_\\\\|~&amp;amp;lt;&amp;amp;#%\\^*+=_\\\\|~&#%\\^*+=_\\\\|~&amp;#%\\^*+=_\\\\|~&#%\\^*+=_\\\\|~&amp;amp;lt;&#%\\^*+=_\\\\|~&amp;amp;lt;&amp;#%\\^*+=_\\\\|~&#%\\^*+=_\\\\|~&amp;amp;lt;&#%\\^*+=_\\\\|~&amp;amp;lt;&amp;amp;gt;€£¥•·]*";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
BOOL isMatch = [pred evaluateWithObject:[NSString stringWithFormat:@"%@",self]];
if ([self containsString:@","]||[self containsString:@"?"]||[self containsString:@"("]||[self containsString:@")"]) {
isMatch=NO;
}
return isMatch;
}
return NO;
}
#pragma mark -- RSA
+(NSString*)formatPulicKeys:(NSString*)publicKey password:(NSString*)password{
......
......@@ -9,7 +9,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface UIDevice (NRDevice)
@interface UIDevice (NRAdd)
/**
* 同步唯一设备标识 (生成并保存唯一设备标识,如已存在则不进行任何处理)
*
......
......@@ -5,12 +5,12 @@
// Created by Gin on 2020/9/24.
//
#import "UIDevice+NRDevice.h"
#import "UIDevice+NRAdd.h"
#import "SFHFKeychainUtils.h"
#define bundleIdentifier [[NSBundle mainBundle]bundleIdentifier]
@implementation UIDevice (NRDevice)
@implementation UIDevice (NRAdd)
/**
* 同步唯一设备标识 (生成并保存唯一设备标识,如已存在则不进行任何处理)
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment