Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
NetRainMVVMProject
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
邹志胜
NetRainMVVMProject
Commits
13d972ff
Commit
13d972ff
authored
Sep 24, 2020
by
“Icebear”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调试通过登录验证码
parent
6742b09f
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
81 additions
and
32 deletions
+81
-32
BaseHttpModel.h
...ainFrame/NetrainFrame/Base/BaseModelAgent/BaseHttpModel.h
+7
-3
BaseHttpModel.m
...ainFrame/NetrainFrame/Base/BaseModelAgent/BaseHttpModel.m
+9
-0
NRGlobalUrlModel.h
...Frame/NetrainFrame/Base/BaseModelAgent/NRGlobalUrlModel.h
+1
-1
NRGlobalUrlModel.m
...Frame/NetrainFrame/Base/BaseModelAgent/NRGlobalUrlModel.m
+2
-2
NRBaseRequest.h
NetrainFrame/NetrainFrame/Base/BaseRequest/NRBaseRequest.h
+3
-4
NRBaseRequest.m
NetrainFrame/NetrainFrame/Base/BaseRequest/NRBaseRequest.m
+3
-12
NRLoginViewController.m
...inFrame/Modules/Login/Controllers/NRLoginViewController.m
+17
-1
NRLoginLogic.h
NetrainFrame/NetrainFrame/Modules/Login/Logic/NRLoginLogic.h
+7
-3
NRLoginLogic.m
NetrainFrame/NetrainFrame/Modules/Login/Logic/NRLoginLogic.m
+17
-5
NRVerifyCodeRequest.h
.../NetrainFrame/Modules/Login/Service/NRVerifyCodeRequest.h
+4
-0
NRVerifyCodeRequest.m
.../NetrainFrame/Modules/Login/Service/NRVerifyCodeRequest.m
+11
-1
No files found.
NetrainFrame/NetrainFrame/Base/BaseModelAgent/BaseHttpModel.h
View file @
13d972ff
...
...
@@ -10,9 +10,13 @@
NS_ASSUME_NONNULL_BEGIN
@interface
BaseHttpModel
:
NSObject
@property
(
nonatomic
,
assign
)
NSInteger
errcode
;
@property
(
nonatomic
,
strong
)
NSString
*
errmsg
;
@property
(
nonatomic
,
strong
)
NSDictionary
*
data
;
@property
(
nonatomic
,
assign
)
NSInteger
code
;
@property
(
nonatomic
,
strong
)
NSString
*
msg
;
@property
(
nonatomic
,
strong
)
id
data
;
-
(
BOOL
)
isSucc
;
-
(
NSString
*
)
errorMsg
;
@end
NS_ASSUME_NONNULL_END
NetrainFrame/NetrainFrame/Base/BaseModelAgent/BaseHttpModel.m
View file @
13d972ff
...
...
@@ -8,6 +8,15 @@
#import "BaseHttpModel.h"
#define kBaseApiOtherError @"服务器错误,请稍后再试"
#define kSuccHttpCode 0
@implementation
BaseHttpModel
-
(
BOOL
)
isSucc
{
return
self
.
code
==
kSuccHttpCode
;
}
-
(
NSString
*
)
errorMsg
{
return
self
.
msg
.
length
>
0
?
self
.
msg
:
kBaseApiOtherError
;
}
@end
NetrainFrame/NetrainFrame/Base/BaseModelAgent/NRGlobalUrlModel.h
View file @
13d972ff
...
...
@@ -8,7 +8,7 @@
#import <Foundation/Foundation.h>
typedef
enum
:
NSUInteger
{
AppServer_Developer
,
AppServer_Developer
=
0
,
AppServer_Product
,
}
AppServer
;
...
...
NetrainFrame/NetrainFrame/Base/BaseModelAgent/NRGlobalUrlModel.m
View file @
13d972ff
...
...
@@ -15,7 +15,7 @@
dispatch_once
(
&
onceToken
,
^
{
if
(
!
sharedInstance
)
{
sharedInstance
=
[[
self
alloc
]
init
];
sharedInstance
.
appServer
=
1
;
sharedInstance
.
appServer
=
AppServer_Product
;
sharedInstance
.
useSSL
=
NO
;
[
sharedInstance
cofigureAppServer
];
}
...
...
@@ -32,7 +32,7 @@
NSData
*
jsonData
=
[
str
dataUsingEncoding
:
NSUTF8StringEncoding
];
NSDictionary
*
dict
=
[
NSJSONSerialization
JSONObjectWithData
:
jsonData
options
:
NSJSONReadingMutableContainers
error
:
nil
];
NSDictionary
*
urlDict
=
[
NSDictionary
dictionary
];
if
(
self
.
appServer
==
ProductSever
){
if
(
self
.
appServer
==
AppServer_Product
){
urlDict
=
_useSSL
?
(
dict
[
@"product"
][
@"https"
])
:
(
dict
[
@"product"
][
@"http"
]);
self
.
kHost
=
[
dict
objectForKey
:
@"kHost"
];
}
else
{
...
...
NetrainFrame/NetrainFrame/Base/BaseRequest/NRBaseRequest.h
View file @
13d972ff
...
...
@@ -9,7 +9,7 @@
///环境Url
#import "NRGlobalUrlModel.h"
#import "NRBaseModelAgent.h"
#import "BaseHttpModel.h"
/*
接口请求基类,所有请求必须继承此类
这里采用的是YTKNetwork网络库,中大型APP专用,可满足所有网络需求
...
...
@@ -18,9 +18,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface
NRBaseRequest
:
YTKBaseRequest
//自定义属性值
@property
(
nonatomic
,
assign
)
BOOL
isSuccess
;
//是否成功
@property
(
nonatomic
,
copy
)
NSString
*
message
;
//服务器返回的信息
@property
(
nonatomic
,
copy
)
NSDictionary
*
result
;
//服务器返回的数据 已解密
@property
(
nonatomic
,
readonly
)
BaseHttpModel
*
httpModel
;
-
(
void
)
startWithCompletionBlock
:(
void
(
^
)(
NRBaseRequest
*
request
,
NSString
*
error
))
block
;
...
...
NetrainFrame/NetrainFrame/Base/BaseRequest/NRBaseRequest.m
View file @
13d972ff
...
...
@@ -7,10 +7,8 @@
#import "NRBaseRequest.h"
#import "NRGlobalUrlModel.h"
#import "BaseHttpModel.h"
#define kBaseApiOtherError @"服务器错误,请稍后再试"
#define kSuccHttpCode 0
@interface
NRBaseRequest
()
...
...
@@ -45,14 +43,7 @@
return
_httpModel
;
}
-
(
BOOL
)
isSucc
{
BaseHttpModel
*
httpModel
=
self
.
httpModel
;
return
httpModel
&&
httpModel
.
errcode
==
kSuccHttpCode
;
}
-
(
NSString
*
)
errorMsg
{
BaseHttpModel
*
httpModel
=
self
.
httpModel
;
return
httpModel
.
errmsg
.
length
>
0
?
httpModel
.
errmsg
:
kBaseApiOtherError
;
}
-
(
NSDictionary
*
)
requestHeaderFieldValueDictionary
{
NSDictionary
*
headers
=
[
NSDictionary
dictionaryWithObjectsAndKeys
:
@"application/x-www-form-urlencoded;charset=utf-8"
,
@"Content-Type"
,
@"iPhone 8"
,
@"_m"
,
@"1"
,
@"_p"
,
@"1"
,
@"_o"
,
@"1"
,
@"_n"
,
@"1.0.0"
,
@"_v"
,
@"1.0"
,
@"_nv"
,
@"14.55.27.328"
,
@"startTime"
,
nil
];
...
...
@@ -67,11 +58,11 @@
return
;
}
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
if
([
strongSelf
isSucc
])
{
if
([
strongSelf
.
httpModel
isSucc
])
{
block
(
strongSelf
,
nil
);
}
else
{
block
(
strongSelf
,
[
strongSelf
errorMsg
]);
block
(
strongSelf
,
[
strongSelf
.
httpModel
errorMsg
]);
}
}
failure
:
^
(
__kindof
YTKBaseRequest
*
_Nonnull
request
)
{
...
...
NetrainFrame/NetrainFrame/Modules/Login/Controllers/NRLoginViewController.m
View file @
13d972ff
...
...
@@ -13,7 +13,7 @@ typedef NS_ENUM(NSUInteger, UserSelectLoginMode) {
verificationLogin
,
//验证码登录
};
@interface
NRLoginViewController
()
<
QMUITextFieldDelegate
>
@interface
NRLoginViewController
()
<
QMUITextFieldDelegate
,
NRLoginLogicDelegate
>
@property
(
weak
,
nonatomic
)
IBOutlet
QMUITextField
*
phoneNumberField
;
@property
(
weak
,
nonatomic
)
IBOutlet
QMUITextField
*
passwdField
;
...
...
@@ -106,6 +106,16 @@ typedef NS_ENUM(NSUInteger, UserSelectLoginMode) {
}
}
#pragma mark -- NRLoginLogicDelegate
-
(
void
)
requestDataCompleted
:
(
BaseHttpModel
*
)
httpModel
{
[
QMUITips
hideAllTips
];
if
(
httpModel
.
isSucc
){
[
QMUITips
showSucceed
:
httpModel
.
errorMsg
];
}
else
{
[
QMUITips
showError
:
httpModel
.
errorMsg
];
}
}
#pragma mark -- IBAction
///显示密码
-
(
IBAction
)
showPassword
:
(
id
)
sender
{
...
...
@@ -124,6 +134,11 @@ typedef NS_ENUM(NSUInteger, UserSelectLoginMode) {
}
///获取验证码
-
(
IBAction
)
getVerification
:
(
id
)
sender
{
if
([
self
.
phoneNumberField
.
text
qmui_trimAllWhiteSpace
].
length
!=
11
){
[
QMUITips
showError
:
@"请输入正确的手机号"
];
return
;
}
[
QMUITips
showLoading
:
@"获取中"
inView
:
self
.
view
];
[
self
.
loginLogic
getVerifyCodeAction
:
self
.
phoneNumberField
.
text
];
}
...
...
@@ -189,6 +204,7 @@ typedef NS_ENUM(NSUInteger, UserSelectLoginMode) {
-
(
NRLoginLogic
*
)
loginLogic
{
if
(
!
_loginLogic
){
_loginLogic
=
[[
NRLoginLogic
alloc
]
init
];
_loginLogic
.
logicDelegate
=
self
;
}
return
_loginLogic
;
}
...
...
NetrainFrame/NetrainFrame/Modules/Login/Logic/NRLoginLogic.h
View file @
13d972ff
...
...
@@ -6,6 +6,10 @@
//
#import "NRBaseRequest.h"
#import "NRPasswordLoginRequest.h"
#import "NRServerTimeRequest.h"
#import "NRVerifyCodeRequest.h"
@protocol
NRLoginLogicDelegate
<
NSObject
>
@optional
...
...
@@ -16,15 +20,15 @@
/**
数据加载完成
*/
-
(
void
)
requestDataCompleted
;
-
(
void
)
requestDataCompleted
:(
BaseHttpModel
*
_Nullable
)
httpModel
;
@end
NS_ASSUME_NONNULL_BEGIN
@interface
NRLoginLogic
:
N
RBaseReques
t
@interface
NRLoginLogic
:
N
SObjec
t
@property
(
nonatomic
,
weak
)
id
<
NRLoginLogicDelegate
>
delegag
te
;
@property
(
nonatomic
,
weak
)
id
<
NRLoginLogicDelegate
>
logicDelega
te
;
-
(
void
)
getVerifyCodeAction
:(
NSString
*
)
phoneNumber
;
...
...
NetrainFrame/NetrainFrame/Modules/Login/Logic/NRLoginLogic.m
View file @
13d972ff
...
...
@@ -6,9 +6,6 @@
//
#import "NRLoginLogic.h"
#import "NRPasswordLoginRequest.h"
#import "NRServerTimeRequest.h"
#import "NRVerifyCodeRequest.h"
@implementation
NRLoginLogic
...
...
@@ -16,11 +13,26 @@
NRServerTimeRequest
*
servertimeRequest
=
[[
NRServerTimeRequest
alloc
]
init
];
[
servertimeRequest
startWithCompletionBlock
:
^
(
NRBaseRequest
*
_Nonnull
request
,
NSString
*
_Nonnull
error
)
{
if
(
!
error
)
{
if
(
self
.
delegagte
&&
[
self
.
delegagte
respondsToSelector
:
@selector
(
requestDataCompleted
)])
{
[
self
.
delegagte
requestDataCompleted
];
NSString
*
tvalue
=
[
servertimeRequest
.
httpModel
.
data
objectAtIndex
:
0
];
NRVerifyCodeRequest
*
verifyCodeRequest
=
[[
NRVerifyCodeRequest
alloc
]
init
];
verifyCodeRequest
.
phoneNumber
=
phoneNumber
;
verifyCodeRequest
.
actionType
=
@"6"
;
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
];
}
}];
}
else
{
if
(
self
.
logicDelegate
&&
[
self
.
logicDelegate
respondsToSelector
:
@selector
(
requestDataCompleted
:)])
{
[
self
.
logicDelegate
requestDataCompleted
:
request
.
httpModel
];
}
}
}];
}
-
(
void
)
verifyCodeLoginAction
{
...
...
NetrainFrame/NetrainFrame/Modules/Login/Service/NRVerifyCodeRequest.h
View file @
13d972ff
...
...
@@ -11,8 +11,12 @@ NS_ASSUME_NONNULL_BEGIN
@interface
NRVerifyCodeRequest
:
NRBaseRequest
@property
(
nonatomic
,
copy
)
NSString
*
actionType
;
@property
(
nonatomic
,
copy
)
NSString
*
phoneNumber
;
@property
(
nonatomic
,
copy
)
NSString
*
tvalue
;
@end
NS_ASSUME_NONNULL_END
NetrainFrame/NetrainFrame/Modules/Login/Service/NRVerifyCodeRequest.m
View file @
13d972ff
...
...
@@ -6,10 +6,20 @@
//
#import "NRVerifyCodeRequest.h"
#define SECRET_KEY @"wu268m4iu8phczre4b"
@implementation
NRVerifyCodeRequest
-
(
NSString
*
)
requestUrl
{
return
@"/sendSms"
;
return
@"sendSms"
;
}
-
(
id
)
requestArgument
{
return
@{
@"sign"
:
[[[
NSString
stringWithFormat
:
@"actionType=%@&phoneNum=%@&t=%@%@"
,
self
.
actionType
,
self
.
phoneNumber
,
self
.
tvalue
,
SECRET_KEY
]
qmui_md5
]
lowercaseString
],
@"t"
:
self
.
tvalue
,
@"phoneNum"
:
self
.
phoneNumber
,
@"actionType"
:
self
.
actionType
,
};
}
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment