Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
htoooth
9 years ago
Commit
964f2e6595d1b15d049e786b8cd1fc866976c8bd
1 parent
9e0b414e
调整登录的代码。
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
55 deletions
apps/passport/views/partial/reg/register.hbs
public/js/passport/login/index.js
public/js/passport/reg/reg.js
public/scss/passport/_index.css
apps/passport/views/partial/reg/register.hbs
View file @
964f2e6
...
...
@@ -79,7 +79,7 @@
<li
class=
"clearfix"
>
<input
name=
"refer"
id=
"refer"
type=
"hidden"
value=
"
{{
referUrl
}}
"
>
<div
style=
"width: 100%;text-align: center"
>
<input
id=
"register-btn"
class=
"btn btn-fixed-height
disable
"
type=
"submit"
value=
"
{{
regBtnText
}}
"
<input
id=
"register-btn"
class=
"btn btn-fixed-height"
type=
"submit"
value=
"
{{
regBtnText
}}
"
>
</div>
</li>
...
...
public/js/passport/login/index.js
View file @
964f2e6
...
...
@@ -170,20 +170,23 @@ function validateCaptchaLocal() {
if
(
$captchaWrap
.
hasClass
(
'hide'
))
{
ep
.
emit
(
'captcha'
,
true
);
return
;
return
true
;
}
switch
(
length
)
{
case
0
:
errTip
(
$imgCaptchaInput
,
'请输入验证码'
);
ep
.
emit
(
'captcha'
,
false
);
return
false
;
break
;
case
4
:
ep
.
emit
(
'captcha'
,
true
);
return
true
;
break
;
default
:
errTip
(
$imgCaptchaInput
,
'请输入长度为4字符的验证码'
);
ep
.
emit
(
'captcha'
,
false
);
return
false
;
break
;
}
}
...
...
@@ -197,7 +200,7 @@ function showAccountErrTimes() {
// 登录
function
login
()
{
$
.
ajax
({
return
$
.
ajax
({
url
:
'/passport/login/auth'
,
type
:
'POST'
,
data
:
{
...
...
@@ -231,33 +234,62 @@ function login() {
});
}
// 邮箱自动补全,并验证信息
mailAc
(
$phoneNumInput
,
function
()
{
function
throttle
()
{
return
$
.
ajax
({
url
:
'/passport/login/account'
,
type
:
'GET'
,
data
:
{
account
:
$
.
trim
(
$phoneNumInput
.
val
())
}
});
}
// 登录次数限制接口
function
throttle
()
{
return
$
.
ajax
({
url
:
'/passport/login/account'
,
type
:
'GET'
,
data
:
{
account
:
$
.
trim
(
$phoneNumInput
.
val
())
}
});
}
validateAccount
().
then
(
function
(
result
)
{
// 验证帐号系统
function
validate
()
{
return
validateAccount
().
then
(
function
(
result
)
{
if
(
result
)
{
return
throttle
();
}
else
{
return
false
;
}
}).
then
(
function
(
res
)
{
var
defer
=
$
.
Deferred
();
if
(
!
res
)
{
return
;
defer
.
reject
(
false
)
;
}
if
(
res
.
data
&&
res
.
data
.
needCaptcha
)
{
showAccountErrTimes
();
defer
.
reject
(
false
);
}
defer
.
resolve
(
true
);
return
defer
.
promise
();
});
}
//全部的本地验证
function
loginAsync
()
{
return
validateAccount
().
then
(
function
()
{
var
defer
=
$
.
Deferred
();
if
(
validateCaptchaLocal
()
&&
validatePasswordLocal
())
{
defer
.
resolve
(
true
);
}
else
{
defer
.
reject
(
false
);
}
return
defer
.
promise
();
}).
then
(
function
()
{
return
login
();
})
}
// 邮箱自动补全
mailAc
(
$phoneNumInput
,
function
()
{
});
$phoneNumInput
.
on
(
'focus'
,
function
()
{
...
...
@@ -265,6 +297,7 @@ $phoneNumInput.on('focus', function() {
$phone
.
addClass
(
'focus'
);
}).
on
(
'blur'
,
function
()
{
$phone
.
removeClass
(
'focus'
);
validate
();
});
$
(
'[placeholder]'
).
placeholder
();
...
...
@@ -385,13 +418,13 @@ $loginBtn.on('click', function() {
return
;
}
login
();
login
Async
();
});
// Enter登录
$
(
'input.va'
).
on
(
'keypress'
,
function
(
e
)
{
if
(
e
.
which
===
13
)
{
login
();
login
Async
();
}
});
...
...
public/js/passport/reg/reg.js
View file @
964f2e6
...
...
@@ -331,6 +331,24 @@ function validatePassword() {
});
}
// 验证同意服务条款
function
validateAgreeLocal
()
{
return
$agreeTermsInput
.
hasClass
(
'checked'
);
}
// 验证同意异步调用
function
validateAgree
()
{
var
defer
=
$
.
Deferred
();
if
(
validateAgreeLocal
())
{
defer
.
resolve
(
true
);
}
else
{
defer
.
reject
(
false
);
}
return
defer
.
promise
();
}
// 密码强度验证
function
validatePasswordComplexLocal
(
$obj
)
{
var
pwd
=
$obj
.
val
(),
...
...
@@ -360,9 +378,21 @@ function validatePasswordComplexLocal($obj) {
}
}
/**
* 检查所有的条件
*/
function
validate
()
{
return
$
.
when
(
validatePhoneNum
(),
validateImgCaptcha
(),
validateSMSCaptcha
(),
validatePassword
(),
validateAgree
()
);
}
// 注册
function
register
()
{
$
.
ajax
({
function
registerAsync
()
{
return
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/reg/mobileregister'
,
data
:
{
...
...
@@ -408,6 +438,15 @@ function register() {
});
}
/**
* 增加验证注册
*/
function
register
()
{
return
validate
().
then
(
function
()
{
return
registerAsync
();
})
}
// 发送短信验证码
function
sendSMSCaptcha
()
{
$
.
ajax
({
...
...
@@ -434,23 +473,8 @@ function disableSMSBtn() {
}
exports
.
init
=
function
()
{
// 验证状态同步,所有的验证必须通过才可点击
ep
.
tail
(
'phone-num'
,
'captcha-img'
,
'captcha-sms'
,
'password'
,
'agree'
,
function
(
phoneAuth
,
imgAuth
,
smsAuth
,
passwordAuth
,
agreeAuth
)
{
if
(
phoneAuth
&&
imgAuth
&&
smsAuth
&&
passwordAuth
&&
agreeAuth
)
{
$registerBtn
.
removeClass
(
'disable'
);
}
else
{
$registerBtn
.
addClass
(
'disable'
);
}
});
// 验证手机输入
$phoneNumInput
.
on
(
'
keyup
blur'
,
function
()
{
$phoneNumInput
.
on
(
'blur'
,
function
()
{
validatePhoneNum
();
$
(
'#phone'
).
removeClass
(
'focus'
);
}).
on
(
'focus'
,
function
()
{
...
...
@@ -459,7 +483,7 @@ exports.init = function() {
});
// 验证图形输入
$imgCaptchaInput
.
on
(
'
keyup
blur'
,
function
()
{
$imgCaptchaInput
.
on
(
'blur'
,
function
()
{
validateImgCaptcha
();
$imgCaptchaInput
.
removeClass
(
'focus'
);
}).
on
(
'focus'
,
function
()
{
...
...
@@ -467,9 +491,9 @@ exports.init = function() {
$imgCaptchaInput
.
addClass
(
'focus'
);
});
// 图形验证通过时,发送短信按钮可点击
ep
.
tail
(
'captcha-img'
,
'phone-num'
,
function
(
captchaAuth
,
phoneAuth
)
{
if
(
captchaAuth
&&
phoneAuth
&&
!
$smsCaptchaCtrl
.
hasClass
(
'second-progress'
))
{
// 手机号验证通过,发送短信按钮可点击
ep
.
tail
(
'phone-num'
,
function
(
phoneAuth
)
{
if
(
phoneAuth
&&
!
$smsCaptchaCtrl
.
hasClass
(
'second-progress'
))
{
$smsCaptchaCtrl
.
removeClass
(
'disable'
);
}
else
{
$smsCaptchaCtrl
.
addClass
(
'disable'
);
...
...
@@ -477,7 +501,7 @@ exports.init = function() {
});
// 验证短信输入
$smsCaptchaInput
.
on
(
'
keyup
blur'
,
function
()
{
$smsCaptchaInput
.
on
(
'blur'
,
function
()
{
validateSMSCaptcha
();
$smsCaptchaInput
.
removeClass
(
'focus'
);
}).
on
(
'focus'
,
function
()
{
...
...
@@ -487,16 +511,13 @@ exports.init = function() {
// 验证密码输入
$passwordInput
.
on
(
'keyup'
,
function
()
{
var
$this
=
$
(
this
);
validatePassword
().
always
(
function
()
{
validatePasswordComplexLocal
(
$this
);
});
validatePasswordComplexLocal
(
$passwordInput
);
}).
on
(
'focus'
,
function
()
{
hideTip
(
$passwordInput
);
$passwordInput
.
addClass
(
'focus'
);
}).
on
(
'blur'
,
function
()
{
$passwordInput
.
removeClass
(
'focus'
);
validatePassword
();
});
// 服务条款
...
...
@@ -516,6 +537,7 @@ exports.init = function() {
}
});
// 修改
function
changeHeader
()
{
var
$indicator
=
$regionSelectHeader
.
find
(
'.iconfont'
);
...
...
@@ -565,11 +587,6 @@ exports.init = function() {
// 点击注册提交
$registerBtn
.
on
(
'click'
,
function
()
{
if
(
$registerBtn
.
hasClass
(
'disable'
))
{
return
;
}
$registerBtn
.
addClass
(
'disable'
);
register
();
});
...
...
@@ -586,7 +603,4 @@ exports.init = function() {
$
(
'.change-captcha'
).
click
(
function
()
{
refreshImgCaptcha
();
});
// 初始化,同意服务条款
ep
.
emit
(
'agree'
,
true
);
};
...
...
public/scss/passport/_index.css
View file @
964f2e6
...
...
@@ -78,7 +78,7 @@
width
:
225px
;
top
:
calc
(
$
item-height
+
3px
);
padding
:
0
10px
;
z-index
:
1
;
z-index
:
20
;
margin-top
:
5px
;
border-radius
:
5px
;
cursor
:
pointer
;
...
...
Please
register
or
login
to post a comment