Skip to content

Commit

Permalink
Add login demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan committed Aug 3, 2014
1 parent 57d2bca commit 57dacf7
Show file tree
Hide file tree
Showing 18 changed files with 319 additions and 30 deletions.
84 changes: 77 additions & 7 deletions RTLibrary-ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
941BF2FA1963EF110003559D /* AppUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 941BF2F91963EF110003559D /* AppUtils.m */; };
941BF3021963F9BA0003559D /* RTDatabaseHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 941BF3011963F9BA0003559D /* RTDatabaseHelper.m */; };
941BF3051963F9C80003559D /* BaseDao.m in Sources */ = {isa = PBXBuildFile; fileRef = 941BF3041963F9C80003559D /* BaseDao.m */; };
94301C5C198DEE2700BEBF9B /* LoginView.m in Sources */ = {isa = PBXBuildFile; fileRef = 94301C5B198DEE2700BEBF9B /* LoginView.m */; };
94301C5F198DEE3A00BEBF9B /* LoginStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 94301C5E198DEE3A00BEBF9B /* LoginStorage.m */; };
94301C63198DEE9300BEBF9B /* LoginHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 94301C62198DEE9300BEBF9B /* LoginHandler.m */; };
94301C66198DEEA400BEBF9B /* UserEntity.m in Sources */ = {isa = PBXBuildFile; fileRef = 94301C65198DEEA400BEBF9B /* UserEntity.m */; };
94301C6B198DEF1C00BEBF9B /* LoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 94301C6A198DEF1C00BEBF9B /* LoginViewController.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -82,6 +87,16 @@
941BF3011963F9BA0003559D /* RTDatabaseHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RTDatabaseHelper.m; sourceTree = "<group>"; };
941BF3031963F9C80003559D /* BaseDao.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseDao.h; sourceTree = "<group>"; };
941BF3041963F9C80003559D /* BaseDao.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BaseDao.m; sourceTree = "<group>"; };
94301C5A198DEE2700BEBF9B /* LoginView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginView.h; sourceTree = "<group>"; };
94301C5B198DEE2700BEBF9B /* LoginView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginView.m; sourceTree = "<group>"; };
94301C5D198DEE3A00BEBF9B /* LoginStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginStorage.h; sourceTree = "<group>"; };
94301C5E198DEE3A00BEBF9B /* LoginStorage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginStorage.m; sourceTree = "<group>"; };
94301C61198DEE9300BEBF9B /* LoginHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginHandler.h; sourceTree = "<group>"; };
94301C62198DEE9300BEBF9B /* LoginHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginHandler.m; sourceTree = "<group>"; };
94301C64198DEEA400BEBF9B /* UserEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserEntity.h; sourceTree = "<group>"; };
94301C65198DEEA400BEBF9B /* UserEntity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserEntity.m; sourceTree = "<group>"; };
94301C69198DEF1C00BEBF9B /* LoginViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginViewController.h; sourceTree = "<group>"; };
94301C6A198DEF1C00BEBF9B /* LoginViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginViewController.m; sourceTree = "<group>"; };
D28D886575A94289A4C45723 /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -147,13 +162,14 @@
children = (
941BF306196401FE0003559D /* Application */,
941BF2DE1963AC430003559D /* Base */,
941BF30E196402DD0003559D /* Category */,
94301C67198DEEF000BEBF9B /* Controller */,
941BF309196402680003559D /* Database */,
941BF30A196402790003559D /* Handler */,
941BF30F196403160003559D /* Model */,
941BF2EB1963BE040003559D /* Network */,
941BF30B1964028B0003559D /* Resource */,
941BF308196402420003559D /* Storage */,
941BF30E196402DD0003559D /* Category */,
941BF2F41963EEC00003559D /* Utils */,
941BF307196402280003559D /* View */,
941BF2B61963ABD50003559D /* Supporting Files */,
Expand Down Expand Up @@ -204,20 +220,15 @@
941BF2E01963AC4F0003559D /* BaseTableViewProtocol.m */,
941BF3031963F9C80003559D /* BaseDao.h */,
941BF3041963F9C80003559D /* BaseDao.m */,
941BF3001963F9BA0003559D /* RTDatabaseHelper.h */,
941BF3011963F9BA0003559D /* RTDatabaseHelper.m */,
);
name = Base;
sourceTree = "<group>";
};
941BF2EB1963BE040003559D /* Network */ = {
isa = PBXGroup;
children = (
94D9FDA8196BEE0700086600 /* RTHttpClient */,
941BF2EC1963BE120003559D /* APIConfig.h */,
941BF2ED1963BE120003559D /* RTHttpClient.h */,
941BF2EE1963BE120003559D /* RTHttpClient.m */,
941BF2F11963BF980003559D /* RTJSONResponseSerializerWithData.h */,
941BF2F21963BF980003559D /* RTJSONResponseSerializerWithData.m */,
);
name = Network;
sourceTree = "<group>";
Expand Down Expand Up @@ -246,27 +257,33 @@
941BF307196402280003559D /* View */ = {
isa = PBXGroup;
children = (
94301C59198DEE1B00BEBF9B /* Login */,
);
name = View;
sourceTree = "<group>";
};
941BF308196402420003559D /* Storage */ = {
isa = PBXGroup;
children = (
94301C5D198DEE3A00BEBF9B /* LoginStorage.h */,
94301C5E198DEE3A00BEBF9B /* LoginStorage.m */,
);
name = Storage;
sourceTree = "<group>";
};
941BF309196402680003559D /* Database */ = {
isa = PBXGroup;
children = (
941BF3001963F9BA0003559D /* RTDatabaseHelper.h */,
941BF3011963F9BA0003559D /* RTDatabaseHelper.m */,
);
name = Database;
sourceTree = "<group>";
};
941BF30A196402790003559D /* Handler */ = {
isa = PBXGroup;
children = (
94301C60198DEE8800BEBF9B /* Login */,
);
name = Handler;
sourceTree = "<group>";
Expand Down Expand Up @@ -296,10 +313,58 @@
941BF30F196403160003559D /* Model */ = {
isa = PBXGroup;
children = (
94301C64198DEEA400BEBF9B /* UserEntity.h */,
94301C65198DEEA400BEBF9B /* UserEntity.m */,
);
name = Model;
sourceTree = "<group>";
};
94301C59198DEE1B00BEBF9B /* Login */ = {
isa = PBXGroup;
children = (
94301C5A198DEE2700BEBF9B /* LoginView.h */,
94301C5B198DEE2700BEBF9B /* LoginView.m */,
);
name = Login;
sourceTree = "<group>";
};
94301C60198DEE8800BEBF9B /* Login */ = {
isa = PBXGroup;
children = (
94301C61198DEE9300BEBF9B /* LoginHandler.h */,
94301C62198DEE9300BEBF9B /* LoginHandler.m */,
);
name = Login;
sourceTree = "<group>";
};
94301C67198DEEF000BEBF9B /* Controller */ = {
isa = PBXGroup;
children = (
94301C68198DEF1100BEBF9B /* Login */,
);
name = Controller;
sourceTree = "<group>";
};
94301C68198DEF1100BEBF9B /* Login */ = {
isa = PBXGroup;
children = (
94301C69198DEF1C00BEBF9B /* LoginViewController.h */,
94301C6A198DEF1C00BEBF9B /* LoginViewController.m */,
);
name = Login;
sourceTree = "<group>";
};
94D9FDA8196BEE0700086600 /* RTHttpClient */ = {
isa = PBXGroup;
children = (
941BF2ED1963BE120003559D /* RTHttpClient.h */,
941BF2EE1963BE120003559D /* RTHttpClient.m */,
941BF2F11963BF980003559D /* RTJSONResponseSerializerWithData.h */,
941BF2F21963BF980003559D /* RTJSONResponseSerializerWithData.m */,
);
name = RTHttpClient;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -433,14 +498,19 @@
941BF2E11963AC4F0003559D /* BaseTableViewProtocol.m in Sources */,
941BF2EF1963BE120003559D /* RTHttpClient.m in Sources */,
941BF2EA1963BCA80003559D /* BaseViewController.m in Sources */,
94301C66198DEEA400BEBF9B /* UserEntity.m in Sources */,
94301C5F198DEE3A00BEBF9B /* LoginStorage.m in Sources */,
94301C63198DEE9300BEBF9B /* LoginHandler.m in Sources */,
941BF2C01963ABD50003559D /* AppDelegate.m in Sources */,
94301C6B198DEF1C00BEBF9B /* LoginViewController.m in Sources */,
941BF2F31963BF980003559D /* RTJSONResponseSerializerWithData.m in Sources */,
941BF2BC1963ABD50003559D /* main.m in Sources */,
941BF2E71963BC8F0003559D /* BaseHandler.m in Sources */,
941BF3051963F9C80003559D /* BaseDao.m in Sources */,
941BF2FA1963EF110003559D /* AppUtils.m in Sources */,
941BF2E41963AD110003559D /* BaseEntity.m in Sources */,
941BF3021963F9BA0003559D /* RTDatabaseHelper.m in Sources */,
94301C5C198DEE2700BEBF9B /* LoginView.m in Sources */,
941BF2F71963EEF60003559D /* UserDefaultsUtils.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
13 changes: 1 addition & 12 deletions RTLibrary-ios/APIConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,13 @@
//

#import <Foundation/Foundation.h>

/***************SERVER HOST***************/

//#define SERVER_HOST @"192.168.1.99:3000" //JQ测试机
//#define SERVER_HOST @"182.92.81.132:3000" //阿里云测试机
#define SERVER_HOST @"182.92.81.107:3000" //阿里云生产机
#define API_VERSION @"/api/v1"
#define SERVER_HOST @"192.168.1.1:3000"

/***************SERVER API***************/
//检测版本更新
#define API_CHECK_VERSION @"?pf=2"//FIXME
//登录
#define API_LOGIN @""
//意见反馈(Path: /api/v1/feedbacks)
#define API_POST_FEEDBACK @"/feedbacks"
//修改密码
#define API_MODIFY_PASSWORD @"/doctors/%@?action=chgpwd"
//TODO

@interface APIConfig : NSObject

Expand Down
4 changes: 4 additions & 0 deletions RTLibrary-ios/AppUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@
//根据颜色码取得颜色对象
+ (UIColor *)colorWithHexString:(NSString *)stringToConvert;

/********************* Verification Utils **********************/
//验证手机号码合法性(正则)
+ (BOOL)checkPhoneNumber:(NSString *)phoneNumber;

@end
27 changes: 27 additions & 0 deletions RTLibrary-ios/AppUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,31 @@ + (UIColor *)colorWithHexString:(NSString *)stringToConvert
alpha:1.0f];
}

/********************* Verification Utils **********************/
+ (BOOL)checkPhoneNumber:(NSString *)phoneNumber{

NSString * MOBILE = @"^1(3[0-9]|5[0-35-9]|8[025-9])\\d{8}$";
NSString * CM = @"^1(34[0-8]|(3[5-9]|5[017-9]|8[278])\\d)\\d{7}$";
NSString * CU = @"^1(3[0-2]|5[256]|8[56])\\d{8}$";
NSString * CT = @"^1((33|53|8[09])[0-9]|349)\\d{7}$";

NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE];
NSPredicate *regextestcm = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CM];
NSPredicate *regextestcu = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CU];
NSPredicate *regextestct = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", CT];
BOOL res1 = [regextestmobile evaluateWithObject:phoneNumber];
BOOL res2 = [regextestcm evaluateWithObject:phoneNumber];
BOOL res3 = [regextestcu evaluateWithObject:phoneNumber];
BOOL res4 = [regextestct evaluateWithObject:phoneNumber];

if (res1 || res2 || res3 || res4 )
{
return YES;
}
else
{
return NO;
}
}

@end
2 changes: 1 addition & 1 deletion RTLibrary-ios/BaseTableViewProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
* @param entity Cell对应的实体
* @param indexPath
*/
typedef void (^TableViewCellConfigurate)(UITableViewCell *cell, id entity, NSIndexPath *indexPath);
typedef void (^TableViewCellConfigurate)(id cell, id entity, NSIndexPath *indexPath);

/**
* 配置不同section中的cell的行数(rows)
Expand Down
2 changes: 1 addition & 1 deletion RTLibrary-ios/BaseTableViewProtocol.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (self.delegate) {
if (self.delegate && [self.delegate respondsToSelector:@selector(selectRowAtIndexPath:)]) {
[self.delegate selectRowAtIndexPath:indexPath];
}
}
Expand Down
23 changes: 23 additions & 0 deletions RTLibrary-ios/LoginHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// LoginHandler.h
// RTLibrary-ios
//
// Created by Ryan on 14-8-3.
// Copyright (c) 2014年 zlycare. All rights reserved.
//

#import "BaseHandler.h"
#import "UserEntity.h"

@interface LoginHandler : BaseHandler

/**
* 用户登录业务逻辑处理
*
* @param user
* @param success
* @param failed
*/
- (void)executeLoginTaskWithUser:(UserEntity *)user success:(SuccessBlock)success failed:(FailedBlock)failed;

@end
13 changes: 13 additions & 0 deletions RTLibrary-ios/LoginHandler.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// LoginHandler.m
// RTLibrary-ios
//
// Created by Ryan on 14-8-3.
// Copyright (c) 2014年 zlycare. All rights reserved.
//

#import "LoginHandler.h"

@implementation LoginHandler

@end
27 changes: 27 additions & 0 deletions RTLibrary-ios/LoginStorage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// LoginStorage.h
// RTLibrary-ios
//
// Created by Ryan on 14-8-3.
// Copyright (c) 2014年 zlycare. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface LoginStorage : NSObject

/**
* 获取登录用户名
*
* @return
*/
+ (NSString *)userName;

/**
* 保存登录用户名
*
* @param userName
*/
+ (void)saveUserName:(NSString *)userName;

@end
26 changes: 26 additions & 0 deletions RTLibrary-ios/LoginStorage.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// LoginStorage.m
// RTLibrary-ios
//
// Created by Ryan on 14-8-3.
// Copyright (c) 2014年 zlycare. All rights reserved.
//

#import "LoginStorage.h"
#import "UserDefaultsUtils.h"

static NSString * const USER_NAME = @"username";

@implementation LoginStorage

+ (void)saveUserName:(NSString *)userName
{
[UserDefaultsUtils saveValue:userName forKey:USER_NAME];
}

+ (NSString *)userName
{
return [UserDefaultsUtils valueWithKey:USER_NAME];
}

@end
13 changes: 13 additions & 0 deletions RTLibrary-ios/LoginView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// LoginView.h
// RTLibrary-ios
//
// Created by Ryan on 14-8-3.
// Copyright (c) 2014年 zlycare. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface LoginView : UIView

@end
Loading

0 comments on commit 57dacf7

Please sign in to comment.