Commit 88b0f4dc authored by Achilles's avatar Achilles

refactor login page

parent dcf57dbf
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#import "AppDelegate.h" #import "AppDelegate.h"
#import "GEToast.h" #import "GEToast.h"
#import "VankeUtil.h" #import "VankeUtil.h"
#import "VankeCommonModel.h"
#define PWD_MASK @" " #define PWD_MASK @" "
...@@ -92,6 +93,20 @@ ON_DID_DISAPPEAR( signal ) ...@@ -92,6 +93,20 @@ ON_DID_DISAPPEAR( signal )
[NSObject cancelPreviousPerformRequestsWithTarget:self]; [NSObject cancelPreviousPerformRequestsWithTarget:self];
} }
ON_LOAD_DATAS( signal )
{
// admin/thoradmin
VankeCommonModel *userModel = [VankeCommonModel sharedInstance];
User *user = [userModel currentUser];
if (nil != user) {
$(self.txtUserName).DATA(user.code);
$(self.txtPwd).DATA([userModel currentUserPassword]);
} else {
[self.txtUserName becomeFirstResponder];
}
[self refreshLoginButtonStyle];
}
ON_SIGNAL3( VankeLoginBoard_iPhone, btnLogin, signal ) ON_SIGNAL3( VankeLoginBoard_iPhone, btnLogin, signal )
{ {
if (![self checkToLogin]) { if (![self checkToLogin]) {
...@@ -103,6 +118,39 @@ ON_SIGNAL3( VankeLoginBoard_iPhone, btnLogin, signal ) ...@@ -103,6 +118,39 @@ ON_SIGNAL3( VankeLoginBoard_iPhone, btnLogin, signal )
[_model login:[self getUserName] password:[self getPassword]]; [_model login:[self getUserName] password:[self getPassword]];
} }
ON_SIGNAL3( VankeLoginBoard_iPhone, txtUserName, signal )
{
if ([signal is:BeeUITextField.CLEAR]) {
[self setLoginButtonEnabled: NO];
} else {
[self refreshLoginButtonStyle];
}
}
ON_SIGNAL3( VankeLoginBoard_iPhone, txtPwd, signal )
{
if ([signal is:BeeUITextField.CLEAR]) {
[self setLoginButtonEnabled: NO];
} else {
[self refreshLoginButtonStyle];
}
}
-(void) refreshLoginButtonStyle {
BOOL disabled = [VankeUtil isBlankString:_txtPwd.text] || [VankeUtil isBlankString:_txtUserName.text];
[self setLoginButtonEnabled: !disabled];
}
-(void) setLoginButtonEnabled: (BOOL) enabled {
if (!enabled) {
$(self.btnLogin).ADD_CLASS(@"disabled-btn");
[self.btnLogin setUserInteractionEnabled:NO];
} else {
$(self.btnLogin).REMOVE_CLASS(@"disabled-btn");
[self.btnLogin setUserInteractionEnabled:YES];
}
}
ON_SIGNAL3( VankeUserModel, RELOADING, signal ) { ON_SIGNAL3( VankeUserModel, RELOADING, signal ) {
} }
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
</linear> </linear>
<linear orientation="v" class="form-wrapper"> <linear orientation="v" class="form-wrapper">
<input id="txtUserName" class="input-field" placeholder="请输入用户名">admin</input> <input id="txtUserName" class="input-field" placeholder="请输入用户名"></input>
<input id="txtPwd" class="input-field pwd" placeholder="请输入密码">thoradmin</input> <input id="txtPwd" class="input-field pwd" placeholder="请输入密码"></input>
<button id="btnLogin" class="login-btn">登 录</button> <button id="btnLogin" class="login-btn disabled-btn">登 录</button>
</linear> </linear>
<linear orientation="h" class="bottom"> <linear orientation="h" class="bottom">
...@@ -105,6 +105,12 @@ ...@@ -105,6 +105,12 @@
background-color: #ed1b23; background-color: #ed1b23;
border-radius: 5px; border-radius: 5px;
margin-top: 10px; margin-top: 10px;
color: white;
}
.disabled-btn {
background-color: #cbcbcb !important;
color: gray;
} }
.disable { .disable {
......
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