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
ed07cee5487292f0e1fea39dde150d550731c33e
1 parent
9af2d9de
master
...
develop
feature/catch
feature/docker
feature/login-msg
feature/login-ua-ip
feature/removCamel
feature/safe-bug
feature/sessionKey
feature/setting
feature/vip
feature/webpack2
feature/wsl5.3
gray
release/2.0
release/fontBack2.0
refactor ok
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
848 additions
and
1220 deletions
apps/passport/router.js
apps/passport/views/action/back/index.hbs
apps/passport/views/action/back/reset-pwd.hbs
apps/passport/views/action/back/verification.hbs
apps/passport/views/action/bind/bind-set-pwd.hbs
apps/passport/views/action/bind/index.hbs
apps/passport/views/action/bind/noregist.hbs
apps/passport/views/action/bind/relate.hbs
apps/passport/views/action/bind/success.hbs
apps/passport/views/partial/reg/register.hbs
public/js/passport/back-index.page.js
public/js/passport/back/back.js
public/js/passport/back/reset.js
public/js/passport/back/verification.js
public/js/passport/bind/third-login.js
public/js/passport/bind/third-pwd.js
public/js/passport/login/index.js
public/js/passport/reg/reg.js
public/scss/passport/_back.css
apps/passport/router.js
View file @
ed07cee
...
...
@@ -43,23 +43,23 @@ router.get('/login/account', login.common.needCaptcha);
// 第三方登录后绑定
router
.
get
(
'/thirdlogin/index'
,
bind
.
indexPage
);
router
.
post
(
'/thirdlogin/bindsetpwd'
,
bind
.
bindSetPwdPage
);
// 第三方登录后绑定确认
router
.
post
(
'/thirdlogin/bindConfirm'
,
bind
.
bindConfirmPage
);
router
.
get
(
'/thirdlogin/bindSuccess'
,
bind
.
bindSuccessPage
);
// 第三方登录后关联确认
router
.
post
(
'/thirdlogin/relateConfirm'
,
bind
.
relateConfirmPage
);
router
.
get
(
'/thirdlogin/relateSuccess'
,
bind
.
relateSuccessPage
);
// 第三方登录api
router
.
post
(
'/autouserinfo/bindMobile'
,
bind
.
bindMobile
);
router
.
post
(
'/autouserinfo/bindCheck'
,
bind
.
bindCheck
);
router
.
post
(
'/autouserinfo/sendBindMsg'
,
bind
.
sendBindMsg
);
router
.
post
(
'/autouserinfo/checkBindMsg'
,
bind
.
checkBindMsg
);
router
.
post
(
'/autouserinfo/relatemobile'
,
bind
.
relateMobile
);
// 第三方登录后关联
router
.
post
(
'/thirdlogin/relateConfirm'
,
bind
.
relateConfirmPage
);
router
.
get
(
'/thirdlogin/relateSuccess'
,
bind
.
relateSuccessPage
);
/**
* 注册页面路由
*/
...
...
@@ -79,7 +79,6 @@ router.get('/back/index', back.index);
// 实时验证输入是否正确
router
.
post
(
'/back/authcode'
,
captcha
.
requiredAPI
,
back
.
validateInputAPI
,
back
.
getUserInfoAPI
);
...
...
apps/passport/views/action/back/index.hbs
View file @
ed07cee
...
...
@@ -64,19 +64,21 @@
<a
class=
"left link change-captcha"
><span
class=
"iconfont gray"
>

</span></a>
</div>
<span
id=
"captcha-err"
class=
"err-tip captcha-err hide"
>
<i></i>
<em>
验证码不能为空
</em>
</span>
</li>
<li
class=
"clearfix"
>
<input
name=
"refer"
id=
"refer"
type=
"hidden"
value=
"http%3A%2F%2Fwww.yohoblk.com%2F"
>
<div
class=
"center"
>
<input
id=
"find-btn"
class=
"find-btn disable"
type=
"submit"
value=
"下一步"
disabled=
""
>
<input
id=
"find-btn"
class=
"find-btn disable"
type=
"submit"
value=
"下一步"
>
</div>
</li>
</form>
</ul>
<div
class=
"tips hide"
>
<div
class=
"triangle"
></div>
<div
class=
"rectangle"
></div>
</div>
{{/
back
}}
</div>
...
...
apps/passport/views/action/back/reset-pwd.hbs
View file @
ed07cee
...
...
@@ -46,28 +46,10 @@
<li
class=
"input-container-li po-re"
>
<input
id=
"pwd"
class=
"input va pwd"
type=
"password"
name=
"pwd"
placeholder=
"新的登录密码"
maxlength=
"20"
>
<div
id=
"pwd-tips"
class=
"pwd-tips hide"
>
<div
class=
"default"
id=
"pwd-tip1"
>
<i></i>
密码只支持6-20位字符
</div>
<div
class=
"default"
id=
"pwd-tip2"
>
<i></i>
由字母、 数字组合,不能包含特殊符号
</div>
</div>
<span
id=
"pwd-err"
class=
"err-tip hide"
>
<i></i>
<em>
请输入密码
</em>
</span>
</li>
<li
class=
"clearfix"
>
<input
id=
"re-input"
class=
"input va re-input repwd"
type=
"password"
name=
"re-input"
placeholder=
"确认登录密码"
maxlength=
"20"
>
<span
id=
"repwd-err"
class=
"err-tip hide"
>
<i></i>
<em>
请输入密码确认
</em>
</span>
</li>
<li
class=
"clearfix blank"
>
<input
type=
"hidden"
name=
"code"
value=
"
{{
code
}}
"
>
...
...
@@ -79,11 +61,17 @@
<li>
<div>
<input
id=
"reset-pwd-btn"
class=
"reset-pwd-btn
"
type=
"submit"
value=
"下一步"
disabled=
"
"
>
<input
id=
"reset-pwd-btn"
class=
"reset-pwd-btn
disable"
type=
"submit"
value=
"下一步
"
>
</div>
</li>
</form>
</ul>
<div
class=
"tips hide"
>
<div
class=
"triangle"
></div>
<div
class=
"rectangle"
></div>
</div>
{{/
resetPwd
}}
</div>
...
...
apps/passport/views/action/back/verification.hbs
View file @
ed07cee
...
...
@@ -51,13 +51,10 @@
<form
id=
"verification-form"
class=
"verification-form"
method=
"POST"
action=
"/passport/back/backmobile"
>
<li>
<input
id=
"captcha"
class=
"input va captcha"
type=
"text"
name=
"code"
maxlength=
"4"
<input
id=
"captcha"
class=
"input va captcha
left
"
type=
"text"
name=
"code"
maxlength=
"4"
placeholder=
"请输入短信验证码"
>
<input
id=
"send-captcha"
class=
"input send-captcha"
type=
"button"
value=
"获取短信验证码"
disabled=
""
>
<span
id=
"err-tip"
class=
"err-tip hide"
>
<i></i>
<em>
请输入验证码
</em>
</span>
<a
id=
"send-captcha"
class=
"btn send-captcha left"
>
获取短信验证码
</a>
</li>
<li
class=
"blank"
>
<input
name=
"area"
id=
"area"
type=
"hidden"
value=
"
{{
area
}}
"
>
...
...
@@ -71,6 +68,11 @@
</form>
</ul>
<div
class=
"tips hide"
>
<div
class=
"triangle"
></div>
<div
class=
"rectangle"
></div>
</div>
{{/
verification
}}
</div>
...
...
apps/passport/views/action/bind/bind-set-pwd.hbs
View file @
ed07cee
...
...
@@ -32,6 +32,11 @@
</div>
<div
class=
"tips hide"
>
<div
class=
"triangle"
></div>
<div
class=
"rectangle"
></div>
</div>
<input
type=
"hidden"
id=
"sourceType"
value=
"
{{
sourceType
}}
"
>
<input
type=
"hidden"
id=
"openId"
value=
"
{{
openId
}}
"
>
<input
type=
"hidden"
id=
"mobile"
value=
"
{{
mobile
}}
"
>
...
...
apps/passport/views/action/bind/index.hbs
View file @
ed07cee
...
...
@@ -21,13 +21,11 @@
{{/
each
}}
</select>
<div
id=
"mobile"
class=
"ctrl left"
>
<div
id=
"region-code"
class=
"code left"
>
{{
local
}}
</div>
<div
id=
"phone"
class=
"ctrl left"
>
<div
id=
"region-code"
class=
"code left"
>
{{
local
}}
</div>
<div
id=
"phone-num"
>
<input
id=
"phoneNum"
class=
"phone-num"
type=
"text"
placeholder=
"Phone Number"
>
<div
>
<input
id=
"phone-num"
class=
"phone-num"
type=
"text"
placeholder=
"Phone Number"
>
</div>
</div>
...
...
@@ -64,6 +62,11 @@
</ul>
</div>
<div
class=
"tips hide"
>
<div
class=
"triangle"
></div>
<div
class=
"rectangle"
></div>
</div>
<div>
<input
id=
"openId"
type=
"hidden"
value=
"
{{
openId
}}
"
>
<input
id=
"sourceType"
type=
"hidden"
value=
"
{{
sourceType
}}
"
>
...
...
apps/passport/views/action/bind/noregist.hbs
deleted
100644 → 0
View file @
9af2d9d
<div
class=
"bindwrapper"
>
<h3
class=
"welcomeword"
>
欢迎加入
<span
class=
"yoho"
>
YOHO!FAMILY
</span>
</h3>
<p
class=
"safeword"
>
为了您的账户安全,请您完善账户信息,以便为您提供更优质的服务
</p>
<p
class=
"sendnotify"
>
验证码已发送至
<span
class=
"sendphone"
>
{{
mobile
}}
</span>
</p>
<form
action=
"infoform"
method=
"post"
>
<div
class=
"validaterow"
>
<div
class=
"name phonetag"
>
短信验证码
</div>
<div
class=
"content"
>
<div
class=
"yohophonewrapper"
>
<input
type=
"text"
class=
"validatenum phonenum"
value=
""
id=
"validatenum"
maxlength=
"4"
/>
<span
class=
"err-tip code-err-tip hide"
>
<i></i>
<em></em>
</span>
</div>
</div>
<div
class=
"validatewrapper"
>
<a
href=
"javascript:void(0)"
class=
"yohobindbtn"
id=
"sendmessage"
>
免费获取短信验证码
</a>
</div>
<div
class=
"hide"
id=
"nopermissionmessage"
>
<span
class=
"second"
>
60
</span>
秒后可重新操作
</div>
</div>
<div
class=
"setpwdcontent"
>
<div
class=
"yohobindrow setpwdwrapper"
>
<div
class=
"name setpwdtag"
>
设置密码
</div>
<div
class=
"content"
>
<div
class=
"yohophonewrapper"
>
<input
type=
"password"
class=
"phonenum pwdcontent"
maxlength=
"20"
id=
"pwd"
name=
"password"
/>
<span
class=
"err-tip pwd-err-tip hide"
>
<i></i>
<em></em>
</span>
<div
id=
"pwd-tips"
class=
"hide pwd-tips"
>
<div
class=
"default"
id=
"pwd-tip1"
>
<i></i>
密码只支持6-20位字符
</div>
<div
class=
"default"
id=
"pwd-tip2"
>
<i></i>
由字母、 数字组合,不能包含特殊符号
</div>
</div>
</div>
</div>
</div>
<div
class=
"safelevel clearfix"
>
安全程度:
<span
class=
"low pwd-intensity"
>
低
</span>
<span
class=
"mid pwd-intensity"
>
中
</span>
<span
class=
"high pwd-intensity"
>
高
</span>
</div>
</div>
<div
class=
"btnwrapper confirmwrapper"
>
<a
href=
"javascript:void(0)"
class=
"yohobindbtn"
id=
"confirmsubmit"
>
确定
</a>
</div>
<input
type=
"hidden"
value=
"
{{
openId
}}
"
name=
"openId"
id=
"openId"
>
<input
type=
"hidden"
value=
"
{{
sourceType
}}
"
name=
"sourceType"
id=
"sourceType"
>
<input
type=
"hidden"
value=
"
{{
mobile
}}
"
id=
"mobile"
name=
"mobile"
/>
<input
type=
"hidden"
value=
"
{{
area
}}
"
id=
"area"
/>
</form>
</div>
apps/passport/views/action/bind/relate.hbs
deleted
100644 → 0
View file @
9af2d9d
{{>
layout
/
header
}}
<div
class=
"third-relate-page passport-page yoho-page clearfix"
>
{{#
relate
}}
<div
id=
"relate-main"
class=
"relate-main"
>
<div
class=
"user-wrapper"
>
<div
class=
"user-thumb"
>
<img
src=
"
{{
thumb
}}
"
>
</div>
<label>
用户名:
{{
userName
}}
</label>
</div>
<div
class=
"remind-info"
>
<h3>
手机号
<span>
{{
phoneNum
}}
</span>
已经被以上账户注册,点击
<a
href=
"
{{
loginHref
}}
"
target=
"_blank"
>
登录该账号
</a>
</h3>
<p>
您可以使用此号码进行账户关联或更换一个新的手机号码
</p>
</div>
<div
class=
"option-btn"
>
<a
id=
"next-step-btn"
>
关联此手机号
</a>
<a
href=
"
{{
changeHref
}}
"
>
更换新手机号
</a>
</div>
<p
class=
"remind-tips"
>
注:关联的手机号码不能用来登录此账户
</p>
</div>
<div
id=
"code-validate"
class=
"code-validate hide"
>
<div
class=
"action-link"
>
短信验证码已发送至
<span>
{{
phoneNum
}}
</span></div>
<div
class=
"validate-wrapper action-link"
>
<div
class=
"code-name"
>
短信验证码
</div>
<input
type=
"text"
class=
"msg-code"
>
<label
class=
"get-code"
>
免费获取短信验证码
</label>
<label
class=
"count-down"
><span>
60
</span>
秒后可重新操作
</label>
<div
class=
"code-error hide"
>
<i></i>
验证码错误
</div>
</div>
<div
class=
"action-link"
>
<button
id=
"relate-btn"
class=
"relate-btn"
>
确定
</button>
</div>
<p
class=
"remind-tips"
>
<span
class=
"left"
>
注:关联的手机号码不能用来登录此账户
</span>
<a
class=
"perv-step right"
>
返回上一步
</a>
</p>
</div>
<div
id=
"hide-info"
data-mobile=
"
{{
phoneNum
}}
"
data-area=
"
{{
areaCode
}}
"
data-openid=
"
{{
openId
}}
"
data-source=
"
{{
sourceType
}}
"
></div>
{{/
relate
}}
</div>
{{>
layout
/
footer
}}
\ No newline at end of file
apps/passport/views/action/bind/success.hbs
deleted
100644 → 0
View file @
9af2d9d
<div
class=
"bindsuccesswrapper"
>
<div
class=
"successwrapper"
>
<span
class=
"successtag"
></span>
<span
class=
"congratulation"
>
恭喜!
</span>
{{#if
relate
}}
<span
class=
"successnotify"
>
您的手机号码已经关联成功
</span>
{{^}}
<span
class=
"successnotify"
>
您的号码已经绑定成功
</span>
{{/if}}
</div>
{{#if
relate
}}
<h3
class=
"info"
>
该手机号码不能用来登录此账户,您可以选择继续使用
{{
sourceName
}}
登录
</h3>
{{^}}
<h3
class=
"info"
>
今后您可以选择
{{
sourceName
}}
或绑定的手机号码+密码的方式登录此账户
</h3>
{{/if}}
<a
href=
"
{{
goShopping
}}
"
class=
"yohobindbtn gobuynow"
>
立即购物
</a>
</div>
\ No newline at end of file
apps/passport/views/partial/reg/register.hbs
View file @
ed07cee
...
...
@@ -13,14 +13,14 @@
</select>
<div
id=
"phone"
class=
"left phone relative"
>
<span
id=
"country-code"
class=
"country-code"
>
{{
location
}}
</span>
<input
value=
""
id=
"phone-num"
class=
"input
va
phone-num"
type=
"text"
name=
"phoneNum"
<input
value=
""
id=
"phone-num"
class=
"input phone-num"
type=
"text"
name=
"phoneNum"
placeholder=
"Phone Number"
autocomplete=
"off"
>
</div>
</li>
<li
class=
"clearfix"
data-index=
"1"
>
<input
id=
"captcha"
class=
"input
va
captcha"
type=
"text"
name=
"captcha"
placeholder=
"图形验证码"
<input
id=
"captcha"
class=
"input captcha"
type=
"text"
name=
"captcha"
placeholder=
"图形验证码"
autocomplete=
"off"
maxlength=
"4"
>
<div
class=
"left captcha-component"
>
...
...
@@ -31,9 +31,9 @@
</li>
<li
class=
"clearfix"
data-index=
"2"
>
<input
id=
"msg-captcha"
class=
"input
va
msg-captcha"
type=
"text"
name=
"msgCaptcha"
placeholder=
"短信验证码"
<input
id=
"msg-captcha"
class=
"input msg-captcha"
type=
"text"
name=
"msgCaptcha"
placeholder=
"短信验证码"
autocomplete=
"off"
maxlength=
"4"
>
<
input
id=
"send-captcha"
class=
"btn send-captcha disable"
type=
"button"
value=
"获取短信验证码"
>
<
a
id=
"send-captcha"
class=
"btn send-captcha disable"
>
获取短信验证码
</a
>
<span
id=
"msg-tip"
class=
"hide msg-tip"
>
短信验证码已发送至您的手机,请查收
</span>
</li>
...
...
@@ -46,13 +46,8 @@
</li>
<li
class=
"clearfix"
>
<input
id=
"pwd"
class=
"input
va
pwd"
name=
"pwd"
placeholder=
"Password"
autocomplete=
"off"
maxlength=
"20"
<input
id=
"pwd"
class=
"input pwd"
name=
"pwd"
placeholder=
"Password"
autocomplete=
"off"
maxlength=
"20"
type=
"password"
>
<div
id=
"pwd-tips"
class=
"hide pwd-tips"
>
<div
class=
"default"
id=
"pwd-tip1"
><i></i>
密码只支持6-20位字符
</div>
<div
class=
"default"
id=
"pwd-tip2"
><i></i>
由字母、 数字组合,不能包含特殊符号
</div>
</div>
</li>
<li
class=
"clearfix"
>
...
...
@@ -68,7 +63,7 @@
<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
}}
"
disabled=
""
>
>
</div>
</li>
<li
class=
"clearfix quick-login-container"
>
...
...
public/js/passport/back-index.page.js
View file @
ed07cee
...
...
@@ -2,4 +2,4 @@
* Created by TaoHuang on 2016/6/21.
*/
require
(
'./back/back'
);
require
(
'./back/back'
)
.
init
()
;
...
...
public/js/passport/back/back.js
View file @
ed07cee
...
...
@@ -5,28 +5,41 @@
*/
var
$
=
require
(
'yoho-jquery'
),
regx
=
require
(
'../common/mail-phone-regx'
);
regx
=
require
(
'../common/mail-phone-regx'
),
EventProxy
=
require
(
'../common/eventproxy'
);
var
emailAc
=
require
(
'../common/ac-email'
);
// 邮箱自动完成
var
$cr
=
$
(
'#country-code'
),
$phoneNum
=
$
(
'.phone-num'
),
$ca
=
$
(
'#verifyCode'
),
$ccList
=
$
(
'#area'
),
$cc
=
$
(
'#country-code'
),
$btn
=
$
(
'#find-btn'
),
$accErr
=
$
(
'#account-err'
),
$caErr
=
$
(
'#captcha-err'
),
caCount
=
4
,
// 验证码位数
hasPh
=
false
,
hasCa
=
false
;
var
emailReg
=
regx
.
emailRegx
,
var
$regionCodeText
=
$
(
'#country-code'
),
$phoneNumInput
=
$
(
'.phone-num'
),
$imgCaptchaInput
=
$
(
'#verifyCode'
),
$regionSelectCtrl
=
$
(
'#area'
),
$nextBtn
=
$
(
'#find-btn'
),
$phone
=
$
(
'#phone'
);
var
emailRegx
=
regx
.
emailRegx
,
phoneRegx
=
regx
.
phoneRegx
;
var
ep
=
new
EventProxy
();
var
$errTip
=
$
(
'.tips'
),
$errMsg
=
$errTip
.
find
(
'.rectangle'
);
function
errTip
(
ele
,
msg
)
{
var
topLeft
=
ele
.
offset
();
$errMsg
.
text
(
msg
);
return
$errTip
.
css
({
top
:
topLeft
.
top
+
ele
.
height
()
-
2
,
left
:
topLeft
.
left
,
width
:
ele
.
width
()
+
2
,
height
:
ele
.
height
}).
removeClass
(
'hide'
);
}
require
(
'yoho-jquery-placeholder'
);
function
imgcode
()
{
function
refreshImgCaptcha
()
{
var
time
=
new
Date
(),
$captchaImg
=
$
(
'#captcha-img'
),
captchaImgSrc
=
$captchaImg
.
attr
(
'src'
).
split
(
'?'
)[
0
];
...
...
@@ -34,169 +47,203 @@ function imgcode() {
$
(
'#captcha-img'
).
attr
(
'src'
,
captchaImgSrc
+
'?t='
+
time
.
getTime
());
}
$ccList
.
change
(
function
()
{
'use strict'
;
$cc
.
text
(
$ccList
.
val
());
});
function
enableBtn
()
{
if
(
hasPh
&&
hasCa
)
{
$btn
.
removeClass
(
'disable'
).
prop
(
'disabled'
,
false
);
}
else
{
$btn
.
addClass
(
'disable'
).
prop
(
'disabled'
,
true
);
}
}
function
authcode
()
{
if
(
!
hasPh
||
!
hasCa
)
{
enableBtn
();
return
;
}
$
.
ajax
({
function
validatePhoneNumAsync
()
{
return
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/back/authcode'
,
data
:
{
verifyCode
:
$
.
trim
(
$ca
.
val
()),
phoneNum
:
$phoneNum
.
val
(),
area
:
$cr
.
text
()
phoneNum
:
$phoneNumInput
.
val
(),
area
:
$regionCodeText
.
text
()
}
}).
then
(
function
(
data
)
{
if
(
data
.
code
===
200
)
{
hasCa
=
true
;
return
true
;
}
else
if
(
data
.
code
===
402
)
{
hasPh
=
false
;
hasCa
=
true
;
$accErr
.
removeClass
(
'hide'
).
find
(
'em'
).
text
(
'该账号不存在'
);
$phoneNum
.
addClass
(
'error'
);
errTip
(
$phone
,
'该账号不存在'
);
return
false
;
}
else
if
(
data
.
code
===
400
)
{
hasCa
=
false
;
imgcode
();
refreshImgCaptcha
();
return
false
;
}
enableBtn
();
});
}
function
vaPn
(
v
)
{
var
pass
=
true
,
errTxt
=
''
;
function
nextStep
(
url
)
{
return
$
.
ajax
({
type
:
'POST'
,
url
:
url
,
data
:
{
verifyCode
:
$
.
trim
(
$imgCaptchaInput
.
val
()),
phoneNum
:
$phoneNumInput
.
val
(),
area
:
$regionCodeText
.
text
()
}
});
}
v
=
$
.
trim
(
v
);
if
(
v
!==
''
)
{
if
(
/^
[
0-9
]
+$/
.
test
(
v
))
{
if
(
phoneRegx
[
$cr
.
text
()].
test
(
v
))
{
pass
=
true
;
function
validatePhoneNumLocal
()
{
var
val
=
$
.
trim
(
$phoneNumInput
.
val
());
if
(
val
!==
''
)
{
if
(
/^
[
0-9
]
+$/
.
test
(
val
))
{
if
(
phoneRegx
[
$regionCodeText
.
text
()].
test
(
val
))
{
return
true
;
}
else
{
errTxt
=
'手机号码格式不正确, 请重新输入'
;
pass
=
false
;
errTip
(
$phone
,
'手机号码格式不正确,请重新输入'
);
return
false
;
}
}
else
{
if
(
emailReg
.
test
(
v
))
{
pass
=
true
;
if
(
emailRegx
.
test
(
val
))
{
return
true
;
}
else
{
errTxt
=
'邮箱格式不正确, 请重新输入'
;
pass
=
false
;
errTip
(
$phone
,
'邮箱格式不正确,请重新输入'
);
return
false
;
}
}
}
else
{
errTxt
=
'账户名不能为空'
;
pass
=
false
;
errTip
(
$phone
,
'请输入帐号'
);
return
false
;
}
hasPh
=
pass
;
authcode
();
return
{
pass
:
pass
,
errTxt
:
errTxt
};
}
function
validatePhoneNum
()
{
function
validate
()
{
var
defer
=
$
.
Deferred
();
//eslint-disable-line
if
(
validatePhoneNumLocal
())
{
validatePhoneNumAsync
().
then
(
function
(
result
)
{
if
(
result
)
{
defer
.
resolve
(
true
);
}
else
{
errTip
(
$phone
,
'帐号不存在'
);
defer
.
reject
(
false
);
}
});
}
else
{
defer
.
reject
(
false
);
}
return
defer
.
promise
();
}
return
validate
().
then
(
function
()
{
ep
.
emit
(
'phone-num'
,
true
);
}).
fail
(
function
()
{
ep
.
emit
(
'phone-num'
,
false
);
});
}
function
vaCa
()
{
var
v
=
$
.
trim
(
$ca
.
val
());
function
validateImgCaptchaLocal
()
{
var
v
=
$
.
trim
(
$imgCaptchaInput
.
val
());
if
(
v
===
''
||
v
.
length
<
caCount
)
{
hasCa
=
false
;
enableBtn
();
return
;
if
(
v
===
''
)
{
errTip
(
$imgCaptchaInput
,
'请输入图形验证码'
);
return
false
;
}
else
if
(
v
.
length
!==
4
)
{
errTip
(
$imgCaptchaInput
,
'验证码不正确'
);
return
false
;
}
hasCa
=
true
;
return
true
;
}
authcode
();
function
validateImgCaptchaAsync
()
{
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/images/check'
,
data
:
{
verifyCode
:
$
.
trim
(
$imgCaptchaInput
.
val
())
}
}).
then
(
function
(
result
)
{
if
(
result
.
code
===
200
)
{
return
true
;
}
else
{
errTip
(
$imgCaptchaInput
,
'验证码不正确'
);
return
false
;
}
});
}
emailAc
(
$phoneNum
,
function
()
{
var
pnVa
=
vaPn
(
$phoneNum
.
val
());
function
validateImgCaptcha
()
{
function
validate
()
{
var
defer
=
$
.
Deferred
();
//eslint-disable-line
if
(
validateImgCaptchaLocal
())
{
validateImgCaptchaAsync
().
then
(
function
(
result
)
{
if
(
result
)
{
defer
.
resolve
(
true
);
}
else
{
errTip
(
$phone
,
'验证码不正确'
);
defer
.
reject
(
false
);
}
});
}
else
{
defer
.
reject
(
false
);
}
if
(
pnVa
.
pass
)
{
$accErr
.
addClass
(
'hide'
);
$phoneNum
.
removeClass
(
'error'
);
}
else
{
$accErr
.
removeClass
(
'hide'
).
find
(
'em'
).
text
(
pnVa
.
errTxt
);
$phoneNum
.
addClass
(
'error'
);
return
defer
.
promise
();
}
return
validate
().
then
(
function
()
{
ep
.
emit
(
'captcha-img'
,
true
);
}).
fail
(
function
()
{
ep
.
emit
(
'captcha-img'
,
false
);
});
}
);
$ca
.
attr
(
'maxlength'
,
caCount
);
emailAc
(
$phoneNumInput
,
function
()
{
validatePhoneNum
();
});
$imgCaptchaInput
.
attr
(
'maxlength'
,
4
);
// IE8 placeholder
$
(
'input'
).
placeholder
();
$
(
'.change-captcha, #captcha-img'
).
on
(
'click'
,
function
()
{
imgcode
();
});
exports
.
init
=
function
()
{
ep
.
tail
(
'phone-num'
,
'captcha-img'
,
function
(
phoneAuth
,
imgAuth
)
{
if
(
phoneAuth
&&
imgAuth
)
{
$nextBtn
.
removeClass
(
'disable'
);
}
else
{
$nextBtn
.
addClass
(
'disable'
);
}
});
$imgCaptchaInput
.
on
(
'blur'
,
function
()
{
validateImgCaptcha
();
});
$phoneNum
.
keyup
(
function
()
{
vaPn
(
$
.
trim
(
$
(
this
).
val
()));
}).
focus
(
function
()
{
$
(
this
).
removeClass
(
'error'
);
$nextBtn
.
on
(
'click'
,
function
()
{
// focus隐藏错误提示
$accErr
.
addClass
(
'hide'
);
});
var
urlPhone
=
'/passport/back/mobile'
,
urlEmail
=
'/passport/back/email'
;
// 验证码在鼠标移开后验证, keyup时不再验证
$ca
.
blur
(
function
()
{
var
errTxt
=
$
.
trim
(
$ca
.
val
())
===
''
?
'验证码不能为空'
:
'验证码不正确'
;
var
url
=
null
;
if
(
hasCa
)
{
$caErr
.
addClass
(
'hide'
);
$ca
.
removeClass
(
'error'
);
}
else
{
$caErr
.
removeClass
(
'hide'
).
find
(
'em'
).
text
(
errTxt
);
$ca
.
addClass
(
'error'
);
// 验证码错误则刷新验证码
if
(
$ca
.
val
()
<
caCount
)
{
if
(
/^
[
0-9
]
+$/
.
test
(
$
.
trim
(
$phoneNumInput
.
val
())))
{
url
=
urlPhone
;
}
else
{
url
=
urlEmail
;
}
// 防止重复刷新验证码
imgcode
();
if
(
$
(
this
).
hasClass
(
'disable'
))
{
return
;
}
}
}).
focus
(
function
()
{
$
(
this
).
removeClass
(
'error'
);
// focus隐藏错误提示
$caErr
.
addClass
(
'hide'
);
}).
keyup
(
function
()
{
vaCa
();
});
$nextBtn
.
addClass
(
'disable'
);
$
(
'#find-btn'
).
click
(
function
(
e
)
{
nextStep
(
url
);
});
if
(
/^
[
0-9
]
+$/
.
test
(
$
.
trim
(
$phoneNum
.
val
())))
{
$
(
'#back-form'
).
attr
(
'action'
,
'/passport/back/mobile'
);
}
if
(
$
(
this
).
hasClass
(
'disable'
))
{
return
;
}
if
(
!
hasCa
||
!
hasPh
)
{
e
.
preventDefault
();
return
true
;
}
});
$phoneNumInput
.
on
(
'blur'
,
function
()
{
validatePhoneNum
();
});
$
(
'.change-captcha, #captcha-img'
).
on
(
'click'
,
function
()
{
refreshImgCaptcha
();
});
$regionSelectCtrl
.
on
(
'change'
,
function
()
{
$regionCodeText
.
text
(
$regionSelectCtrl
.
val
());
validatePhoneNum
();
});
};
\ No newline at end of file
...
...
public/js/passport/back/reset.js
View file @
ed07cee
...
...
@@ -6,233 +6,99 @@
var
$
=
require
(
'yoho-jquery'
);
var
$pwd
=
$
(
'#pwd'
),
$repwd
=
$
(
'#re-input'
),
$next
=
$
(
'#reset-pwd-btn'
),
$pwdErr
=
$
(
'#pwd-err'
),
$repwdErr
=
$
(
'#repwd-err'
),
$pwdTips
=
$
(
'#pwd-tips'
);
var
$passwordInput
=
$
(
'#pwd'
),
$repasswordInput
=
$
(
'#re-input'
),
$next
=
$
(
'#reset-pwd-btn'
);
var
hasNoErrPw
=
false
;
var
EventProxy
=
require
(
'../common/eventproxy'
)
;
var
$pwdIntensity
=
$
(
'.pwd-intensity'
),
$pwdParent
=
$pwdIntensity
.
closest
(
'.pwd-intensity-container'
),
$pwdTip1
=
$
(
'#pwd-tip1'
);
var
ep
=
new
EventProxy
();
var
pwdRegx
=
require
(
'../common/mail-phone-regx'
).
pwdValidateRegx
;
require
(
'yoho-jquery-placeholder'
);
/*
* 计算密码复杂度
*/
function
gettype
(
str
,
i
)
{
if
(
str
.
charCodeAt
(
i
)
>=
48
&&
str
.
charCodeAt
(
i
)
<=
57
)
{
return
1
;
}
else
if
(
str
.
charCodeAt
(
i
)
>=
97
&&
str
.
charCodeAt
(
i
)
<=
122
)
{
return
2
;
}
else
if
(
str
.
charCodeAt
(
i
)
>=
65
&&
str
.
charCodeAt
(
i
)
<=
90
)
{
return
3
;
}
var
$errTip
=
$
(
'.tips'
),
$errMsg
=
$errTip
.
find
(
'.rectangle'
);
return
4
;
}
function
isregular
(
cur
,
pre
,
type
)
{
var
curCode
=
cur
.
charCodeAt
(
0
);
var
preCode
=
pre
.
charCodeAt
(
0
);
if
(
curCode
-
preCode
===
0
)
{
return
true
;
}
if
(
type
!==
4
&&
(
curCode
-
preCode
===
1
||
curCode
-
preCode
===
-
1
))
{
return
true
;
}
function
errTip
(
ele
,
msg
)
{
var
topLeft
=
ele
.
offset
();
return
false
;
$errMsg
.
text
(
msg
);
return
$errTip
.
css
({
top
:
topLeft
.
top
+
ele
.
height
()
-
2
,
left
:
topLeft
.
left
,
width
:
ele
.
width
()
+
2
,
height
:
ele
.
height
}).
removeClass
(
'hide'
);
}
function
getcomplex
(
curType
,
preType
)
{
if
(
preType
===
0
||
curType
===
preType
)
{
return
0
;
}
else
if
(
curType
===
4
||
preType
===
4
)
{
return
2
;
}
else
{
return
1
;
}
function
hideTip
()
{
return
$errTip
.
addClass
(
'hide'
);
}
function
computeComplex
(
password
)
{
var
complex
=
0
,
length
=
password
.
length
,
pre
=
''
,
preType
=
0
,
i
=
0
,
cur
,
curType
;
require
(
'yoho-jquery-placeholder'
);
for
(
i
=
0
;
i
<
length
;
i
++
)
{
cur
=
password
.
charAt
(
i
);
curType
=
gettype
(
password
,
i
);
if
(
preType
!==
curType
||
!
isregular
(
cur
,
pre
,
curType
))
{
complex
+=
curType
+
getcomplex
(
curType
,
preType
);
}
// IE8 placeholder
$
(
'input'
).
placeholder
();
pre
=
cur
;
preType
=
curType
;
ep
.
tail
(
'pwd'
,
'repwd'
,
function
(
pwd
,
repwd
)
{
if
(
pwd
&&
repwd
)
{
$next
.
removeClass
(
'disable'
);
}
else
{
$next
.
addClass
(
'disable'
);
}
});
return
complex
;
}
$passwordInput
.
on
(
'keyup blur'
,
function
()
{
var
length
=
$passwordInput
.
val
().
length
;
function
pwdKeyupEvt
()
{
var
pwd
=
$pwd
.
val
(),
pwdStrength
=
computeComplex
(
pwd
),
level
=
0
;
// TODO:自定义密码强度规则,需要修正
if
(
pwdStrength
===
0
)
{
level
=
0
;
}
else
if
(
pwdStrength
<=
10
)
{
level
=
1
;
}
else
if
(
pwdStrength
<=
20
)
{
level
=
2
;
}
else
{
level
=
3
;
}
switch
(
level
)
{
case
0
:
$pwdParent
.
removeClass
(
'red yellow green'
);
$pwdIntensity
.
removeClass
(
'color'
);
break
;
case
1
:
$pwdParent
.
addClass
(
'red'
).
removeClass
(
'yellow green'
);
$pwdIntensity
.
filter
(
'.low'
).
addClass
(
'color'
);
$pwdIntensity
.
filter
(
'.mid,.high'
).
removeClass
(
'color'
);
break
;
case
2
:
$pwdParent
.
addClass
(
'yellow'
).
removeClass
(
'red green'
);
$pwdIntensity
.
filter
(
'.low,.mid'
).
addClass
(
'color'
);
$pwdIntensity
.
filter
(
'.high'
).
removeClass
(
'color'
);
break
;
case
3
:
$pwdParent
.
addClass
(
'green'
).
removeClass
(
'yellow red'
);
$pwdIntensity
.
addClass
(
'color'
);
break
;
default
:
$pwdParent
.
removeClass
(
'red yellow green'
);
$pwdIntensity
.
removeClass
(
'color'
);
break
;
if
(
length
===
0
)
{
errTip
(
$passwordInput
,
'请输入密码'
);
ep
.
emit
(
'pwd'
,
false
);
return
;
}
// 提示框
if
(
pwd
===
''
)
{
$pwdTip1
.
removeClass
(
'red yes no'
).
addClass
(
'default'
);
}
else
if
(
pwd
.
length
<
6
||
pwd
.
length
>
20
)
{
$pwdTip1
.
removeClass
(
'default yes'
).
addClass
(
'no red'
);
}
else
{
$pwdTip1
.
removeClass
(
'default no red'
).
addClass
(
'yes'
);
if
(
length
<
6
||
length
>
20
)
{
errTip
(
$passwordInput
,
'密码只支持 6-20 位字符,建议字母+数字的组合'
);
ep
.
emit
(
'pwd'
,
false
);
return
;
}
if
(
pwdRegx
.
test
(
pwd
))
{
hasNoErrPw
=
true
;
}
else
{
hasNoErrPw
=
false
;
if
(
!
pwdRegx
.
test
(
$passwordInput
.
val
()))
{
errTip
(
$passwordInput
,
'密码只支持 6-20 位字符,建议字母+数字的组合'
);
ep
.
emit
(
'pwd'
,
false
);
return
;
}
}
// IE8 placeholder
$
(
'input'
).
placeholder
();
ep
.
emit
(
'pwd'
,
true
);
});
$
(
'.va'
).
keyup
(
function
()
{
var
pass
=
true
;
$repasswordInput
.
on
(
'keyup blur'
,
function
()
{
var
length
=
$repasswordInput
.
val
().
length
;
if
(
$
(
this
).
hasClass
(
'pwd'
))
{
pwdKeyupEvt
();
}
else
{
if
(
$
(
this
).
val
()
===
''
)
{
pass
=
false
;
}
}
if
(
pass
&&
hasNoErrPw
&&
$pwd
.
val
()
===
$repwd
.
val
())
{
pass
=
true
;
}
else
{
pass
=
false
;
}
if
(
pass
)
{
$next
.
removeClass
(
'disable'
).
prop
(
'disabled'
,
false
);
}
else
{
$next
.
addClass
(
'disable'
).
prop
(
'disabled'
,
true
);
}
}).
blur
(
function
()
{
var
$this
=
$
(
this
),
v
=
$this
.
val
();
if
(
$this
.
hasClass
(
'pwd'
))
{
if
(
v
===
''
)
{
$this
.
addClass
(
'error'
);
$pwdErr
.
removeClass
(
'hide'
).
find
(
'em'
).
text
(
'请输入密码'
);
}
else
if
(
v
.
length
<
6
||
v
.
length
>
20
)
{
$this
.
addClass
(
'error'
);
$pwdErr
.
removeClass
(
'hide'
).
find
(
'em'
).
text
(
'密码只支持6-20位'
);
}
else
if
(
!
pwdRegx
.
test
(
v
))
{
$this
.
addClass
(
'error'
);
$pwdErr
.
removeClass
(
'hide'
).
find
(
'em'
).
text
(
'密码须字母和数字组合'
);
}
else
{
$pwdErr
.
addClass
(
'hide'
);
if
(
$repwd
.
val
()
!==
''
)
{
if
(
v
!==
$repwd
.
val
())
{
$repwd
.
addClass
(
'error'
);
$repwdErr
.
removeClass
(
'hide'
).
find
(
'em'
).
text
(
'两次密码输入不一致,请重新输入'
);
}
else
{
$repwd
.
removeClass
(
'error'
);
$repwdErr
.
addClass
(
'hide'
);
}
}
}
}
else
{
if
(
v
===
''
)
{
$this
.
addClass
(
'error'
);
$repwdErr
.
removeClass
(
'hide'
).
find
(
'em'
).
text
(
'请输入密码确认'
);
}
else
{
if
(
$pwd
.
val
()
!==
''
&&
v
!==
$pwd
.
val
())
{
$this
.
addClass
(
'error'
);
$repwdErr
.
removeClass
(
'hide'
).
find
(
'em'
).
text
(
'两次密码输入不一致,请重新输入'
);
}
else
{
$this
.
removeClass
(
'error'
);
$repwdErr
.
addClass
(
'hide'
);
}
}
if
(
length
===
0
)
{
errTip
(
$repasswordInput
,
'请再次输入密码'
);
ep
.
emit
(
'repwd'
,
false
);
return
;
}
}).
focus
(
function
()
{
$
(
this
).
removeClass
(
'error'
);
// focus后错误提示隐藏
if
(
$
(
this
).
hasClass
(
'pwd'
))
{
$pwdErr
.
addClass
(
'hide'
);
}
else
{
$repwdErr
.
addClass
(
'hide'
);
if
(
$passwordInput
.
val
()
!==
$repasswordInput
.
val
())
{
errTip
(
$repasswordInput
,
'两次输入的密码不一致,请重新输入'
);
ep
.
emit
(
'repwd'
,
false
);
return
;
}
});
$pwd
.
focus
(
function
()
{
$pwdErr
.
addClass
(
'hide'
);
$pwdTips
.
removeClass
(
'hide'
);
}).
blur
(
function
()
{
$pwdTips
.
addClass
(
'hide'
);
ep
.
emit
(
'repwd'
,
true
);
});
$
(
'#pwd, #repwd'
).
keydown
(
function
(
e
)
{
var
code
=
e
.
keyCode
||
e
.
which
;
// 空格输入过滤
if
(
code
===
32
)
{
e
.
preventDefault
();
return
;
ep
.
on
(
'repwd'
,
function
(
repwdAuth
)
{
if
(
repwdAuth
)
{
hideTip
();
}
});
ep
.
on
(
'pwd'
,
function
(
pwdAuth
)
{
if
(
pwdAuth
)
{
hideTip
();
}
});
\ No newline at end of file
...
...
public/js/passport/back/verification.js
View file @
ed07cee
...
...
@@ -6,71 +6,65 @@
var
$
=
require
(
'yoho-jquery'
);
var
$sc
=
$
(
'#send-captcha'
),
$msgTip
=
$
(
'#captcha-tip'
),
$errTip
=
$
(
'#err-tip'
),
var
$smsCaptchaCtrl
=
$
(
'#send-captcha'
),
$next
=
$
(
'#next-step'
),
seconds
,
itime
;
$smsCaptchaInput
=
$
(
'#captcha'
);
$sc
.
click
(
function
()
{
$
.
post
(
'/passport/back/sendbackmobile'
,
{
mobile
:
$
(
'#mobile'
).
val
(),
area
:
$
(
'#area'
).
val
(),
verifyCode
:
$
(
'#captchaPic'
).
val
()
},
function
(
jsonData
)
{
if
(
jsonData
.
code
===
200
)
{
$errTip
.
hide
();
if
(
$
(
this
).
hasClass
(
'disable'
))
{
return
;
}
seconds
=
60
;
var
second
=
60
;
// $sc.addClass('disable').prop('disabled', true);
$sc
.
addClass
(
'disable'
).
attr
(
'disabled'
,
true
);
$msgTip
.
removeClass
(
'hide'
);
var
$errTip
=
$
(
'.tips'
),
$errMsg
=
$errTip
.
find
(
'.rectangle'
);
$sc
.
val
(
seconds
--
+
's后可重新操作'
);
itime
=
setInterval
(
function
()
{
if
(
seconds
===
0
)
{
clearInterval
(
itime
);
function
errTip
(
ele
,
msg
)
{
var
topLeft
=
ele
.
offset
();
// $sc.val('发送验证码').removeClass('disable').prop('disabled', false);
$sc
.
val
(
'获取短信验证码'
).
removeClass
(
'disable'
).
removeAttr
(
'disabled'
);
}
else
{
$sc
.
val
(
seconds
--
+
's后可重新操作'
);
}
},
1000
);
$errMsg
.
text
(
msg
);
return
$errTip
.
css
({
top
:
topLeft
.
top
+
ele
.
height
()
-
2
,
left
:
topLeft
.
left
,
width
:
ele
.
width
()
+
2
,
height
:
ele
.
height
}).
removeClass
(
'hide'
);
}
}
else
{
$
(
this
).
addClass
(
'error'
);
$errTip
.
removeClass
(
'hide'
).
text
(
'发送失败'
);
}
function
sendSMSCaptchaAsync
()
{
return
$
.
post
(
'/passport/back/sendbackmobile'
,
{
mobile
:
$
(
'#mobile'
).
val
(),
area
:
$
(
'#area'
).
val
(),
verifyCode
:
$
(
'#captchaPic'
).
val
()
});
});
seconds
=
60
;
}
function
disableSMSBtn
()
{
second
-=
1
;
if
(
second
<
0
)
{
second
=
60
;
$smsCaptchaCtrl
.
text
(
'获取短信验证码'
);
$smsCaptchaCtrl
.
removeClass
(
'disable'
);
}
else
{
$smsCaptchaCtrl
.
text
(
second
+
'秒后可重新操作'
);
window
.
setTimeout
(
disableSMSBtn
,
1000
);
}
}
// $sc.addClass('disable').prop('disabled', true);
$sc
.
addClass
(
'disable'
).
attr
(
'disabled'
,
true
);
$msgTip
.
removeClass
(
'hide'
);
$smsCaptchaCtrl
.
click
(
function
()
{
if
(
$smsCaptchaCtrl
.
hasClass
(
'disable'
))
{
return
;
}
$sc
.
val
(
seconds
--
+
's后可重新操作'
);
itime
=
setInterval
(
function
()
{
if
(
seconds
===
0
)
{
clearInterval
(
itime
);
$smsCaptchaCtrl
.
addClass
(
'disable'
);
// $sc.val('发送验证码').removeClass('disable').prop('disabled', false);
$sc
.
val
(
'获取短信验证码'
).
removeClass
(
'disable'
).
removeAttr
(
'disabled'
);
}
else
{
$sc
.
val
(
seconds
--
+
's后可重新操作'
);
}
},
1000
);
disableSMSBtn
();
sendSMSCaptchaAsync
();
});
$smsCaptchaInput
.
on
(
'blur'
,
function
()
{
var
v
=
$
.
trim
(
$
(
this
).
val
());
$
(
'#captcha'
).
keyup
(
function
()
{
var
v
=
$
.
trim
(
$
(
this
).
val
()),
that
=
this
;
if
(
v
===
''
)
{
errTip
(
$smsCaptchaInput
,
'请输入短信验证码'
);
return
;
}
if
(
v
.
length
===
4
)
{
$
.
ajax
({
...
...
@@ -87,27 +81,14 @@ $('#captcha').keyup(function() {
if
(
res
.
code
===
200
)
{
// 添加验证码正确验证
$next
.
removeClass
(
'disable'
).
attr
(
'href'
,
res
.
data
);
$errTip
.
addClass
(
'hide'
);
$
(
that
).
removeClass
(
'error'
);
}
else
{
$next
.
addClass
(
'disable'
);
$errTip
.
removeClass
(
'hide'
).
find
(
'em'
).
text
(
'验证码输入错误'
);
$
(
that
).
addClass
(
'error'
);
errTip
(
$smsCaptchaInput
,
'验证码不正确'
);
}
}
});
}
else
{
errTip
(
$smsCaptchaInput
,
'验证码不正确'
);
$next
.
addClass
(
'disable'
).
attr
(
'href'
,
'javascript:;'
);
}
}).
blur
(
function
()
{
var
v
=
$
.
trim
(
$
(
this
).
val
());
if
(
v
===
''
)
{
// 添加验证码正确验证
$
(
this
).
addClass
(
'error'
);
$errTip
.
removeClass
(
'hide'
).
text
(
'请输入验证码'
);
}
}).
focus
(
function
()
{
$
(
this
).
removeClass
(
'error'
);
});
...
...
public/js/passport/bind/third-login.js
View file @
ed07cee
...
...
@@ -7,33 +7,46 @@ var $ = require('yoho-jquery');
var
phoneRegx
=
require
(
'../common/mail-phone-regx'
).
phoneRegx
;
var
EventProxy
=
require
(
'../common/eventproxy'
);
var
$areaCodeText
=
$
(
'#region-code'
);
var
$phoneNumInput
=
$
(
'#phoneNum'
);
var
$imgCaptchaInput
=
$
(
'#verifyCode'
);
var
$imgCaptchaCtrl
=
$
(
'.img-captcha-refresh'
);
var
$smsCaptchaInput
=
$
(
'#sms-captcha-input'
);
var
$smsCaptchaCtrl
=
$
(
'.sms-captcha-send'
);
var
$next
=
$
(
'#validate-phone-next'
);
var
$regionCodeText
=
$
(
'#region-code'
),
$phoneNumInput
=
$
(
'#phone-num'
),
$imgCaptchaInput
=
$
(
'#verifyCode'
),
$imgCaptchaCtrl
=
$
(
'.img-captcha-refresh'
),
$smsCaptchaInput
=
$
(
'#sms-captcha-input'
),
$smsCaptchaCtrl
=
$
(
'.sms-captcha-send'
),
$phone
=
$
(
'#phone'
),
$nextBtn
=
$
(
'#validate-phone-next'
);
var
$openId
=
$
(
'#openId'
);
var
$sourceType
=
$
(
'#sourceType'
);
var
$refer
=
$
(
'#refer'
);
var
second
=
60
;
var
ep
=
new
EventProxy
();
var
second
=
60
,
ep
=
new
EventProxy
();
function
errTip
(
el
,
msg
)
{
console
.
log
(
el
,
msg
);
var
$errTip
=
$
(
'.tips'
),
$errMsg
=
$errTip
.
find
(
'.rectangle'
);
function
errTip
(
ele
,
msg
)
{
var
topLeft
=
ele
.
offset
();
$errMsg
.
text
(
msg
);
return
$errTip
.
css
({
top
:
topLeft
.
top
+
ele
.
height
()
-
2
,
left
:
topLeft
.
left
,
width
:
ele
.
width
()
+
2
,
height
:
ele
.
height
}).
removeClass
(
'hide'
);
}
function
updat
eSMSBtn
()
{
function
disabl
eSMSBtn
()
{
second
-=
1
;
if
(
second
<
0
)
{
second
=
60
;
$smsCaptchaCtrl
.
text
(
'获取短信验证码'
);
$smsCaptchaCtrl
.
removeClass
(
'disable'
);
}
else
{
$smsCaptchaCtrl
.
text
(
second
+
'秒后可重新操作'
);
window
.
setTimeout
(
updat
eSMSBtn
,
1000
);
window
.
setTimeout
(
disabl
eSMSBtn
,
1000
);
}
}
...
...
@@ -43,7 +56,7 @@ function sendSMSCaptcha() {
url
:
'/passport/autouserinfo/sendBindMsg'
,
data
:
{
mobile
:
$phoneNumInput
.
val
(),
area
:
$
area
CodeText
.
text
()
area
:
$
region
CodeText
.
text
()
}
});
}
...
...
@@ -73,7 +86,7 @@ function validateSMSCaptcha() {
data
:
{
code
:
$smsCaptchaInput
.
val
(),
mobile
:
$smsCaptchaInput
.
val
(),
area
:
$
area
CodeText
.
text
()
area
:
$
region
CodeText
.
text
()
}
});
}
...
...
@@ -81,9 +94,9 @@ function validateSMSCaptcha() {
ep
.
tail
(
'phoneNum'
,
'img-captcha'
,
'sms-captcha'
,
function
(
phoneAuth
,
imgAuth
,
smsAuth
)
{
if
(
phoneAuth
&&
imgAuth
&&
smsAuth
)
{
$next
.
removeClass
(
'disable'
);
$next
Btn
.
removeClass
(
'disable'
);
}
else
{
$next
.
addClass
(
'disable'
);
$next
Btn
.
addClass
(
'disable'
);
}
});
...
...
@@ -91,7 +104,7 @@ ep.tail('phoneNum', 'img-captcha', 'sms-captcha', function(phoneAuth, imgAuth, s
$
(
'#region'
).
change
(
function
()
{
var
$this
=
$
(
this
);
$
area
CodeText
.
text
(
$this
.
val
());
$
region
CodeText
.
text
(
$this
.
val
());
});
ep
.
on
(
'phoneNum'
,
function
(
isCheck
)
{
...
...
@@ -106,19 +119,19 @@ $phoneNumInput.on('blur', function() {
var
length
=
$phoneNumInput
.
val
().
length
;
if
(
length
===
0
)
{
errTip
(
$phone
NumInput
,
'请输入手机号码'
);
errTip
(
$phone
,
'请输入手机号码'
);
ep
.
emit
(
'phoneNum'
,
false
);
return
;
}
if
(
length
!==
11
)
{
errTip
(
$phone
NumInput
,
'手机号码格式不正确'
);
errTip
(
$phone
,
'手机号码格式不正确'
);
ep
.
emit
(
'phoneNum'
,
false
);
return
;
}
if
(
!
phoneRegx
[
$areaCodeText
.
text
()].
test
(
$phoneNumInput
.
val
()))
{
errTip
(
$phoneNumInput
,
'手机号码格式不正确'
);
if
(
!
phoneRegx
[
$regionCodeText
.
text
()].
test
(
$phoneNumInput
.
val
()))
{
errTip
(
$phone
,
'手机号码格式不正确'
);
ep
.
emit
(
'phoneNum'
,
false
);
return
;
}
...
...
@@ -165,13 +178,13 @@ $smsCaptchaInput.on('blur', function() {
case
4
:
break
;
case
0
:
errTip
(
$smsCaptcha
Ctrl
,
'请输入短信验证码'
);
errTip
(
$smsCaptcha
Input
,
'请输入短信验证码'
);
ep
.
emit
(
'sms-captcha'
,
false
);
break
;
return
;
default
:
errTip
(
$smsCaptchaInput
,
'验证码不正确'
);
ep
.
emit
(
'sms-captcha'
,
false
);
break
;
return
;
}
validateSMSCaptcha
().
then
(
function
(
result
)
{
...
...
@@ -179,7 +192,7 @@ $smsCaptchaInput.on('blur', function() {
ep
.
emit
(
'sms-captcha'
,
true
);
}
else
{
ep
.
emit
(
'sms-captcha'
,
false
);
errTip
(
$smsCaptcha
Ctrl
,
'验证码不正确'
);
errTip
(
$smsCaptcha
Input
,
'验证码不正确'
);
}
});
});
...
...
@@ -191,8 +204,8 @@ $smsCaptchaCtrl.on('click', function() {
$smsCaptchaCtrl
.
addClass
(
'disable'
);
disableSMSBtn
();
sendSMSCaptcha
();
updateSMSBtn
();
});
function
setPwdPage
(
thirdPart
)
{
...
...
@@ -228,7 +241,7 @@ function relateConfirmPage(thirdPart, user) {
function
nextPage
()
{
var
thirdPart
=
{
mobile
:
$phoneNumInput
.
val
(),
area
:
$
area
CodeText
.
text
(),
area
:
$
region
CodeText
.
text
(),
openId
:
$openId
.
val
(),
sourceType
:
$sourceType
.
val
(),
verifyCode
:
$imgCaptchaInput
.
val
(),
...
...
@@ -262,14 +275,14 @@ function nextPage() {
break
;
default
:
// 出错
errTip
(
$next
,
'输入错误,请重新输入!'
);
errTip
(
$next
Btn
,
'输入错误,请重新输入!'
);
break
;
}
});
}
$next
.
on
(
'click'
,
function
()
{
if
(
$next
.
hasClass
(
'disable'
))
{
$nextBtn
.
on
(
'click'
,
function
()
{
if
(
$nextBtn
.
hasClass
(
'disable'
))
{
return
;
}
...
...
public/js/passport/bind/third-pwd.js
View file @
ed07cee
...
...
@@ -7,8 +7,8 @@ var $ = require('yoho-jquery');
var
pwdRegx
=
require
(
'../common/mail-phone-regx'
).
pwdValidateRegx
;
var
$pwd
=
$
(
'#pwd'
);
var
$repwd
=
$
(
'#repwd'
);
var
$passwordInput
=
$
(
'#pwd'
),
$repasswordInput
=
$
(
'#repwd'
);
var
$sourceType
=
$
(
'#sourceType'
);
var
$openId
=
$
(
'#openId'
);
...
...
@@ -20,10 +20,25 @@ var EventProxy = require('../common/eventproxy');
var
ep
=
new
EventProxy
();
var
$errTip
=
$
(
'.tips'
),
$errMsg
=
$errTip
.
find
(
'.rectangle'
);
require
(
'yoho-jquery-placeholder'
);
function
errTip
(
$dom
,
info
)
{
console
.
log
(
$dom
,
info
);
function
errTip
(
ele
,
msg
)
{
var
topLeft
=
ele
.
offset
();
$errMsg
.
text
(
msg
);
return
$errTip
.
css
({
top
:
topLeft
.
top
+
ele
.
height
()
-
2
,
left
:
topLeft
.
left
,
width
:
ele
.
width
()
+
2
,
height
:
ele
.
height
}).
removeClass
(
'hide'
);
}
function
hideTip
()
{
return
$errTip
.
addClass
(
'hide'
);
}
ep
.
tail
(
'pwd'
,
'repwd'
,
function
(
pwd
,
repwd
)
{
...
...
@@ -34,23 +49,23 @@ ep.tail('pwd', 'repwd', function(pwd, repwd) {
}
});
$pwd
.
on
(
'keyup blur'
,
function
()
{
var
length
=
$pwd
.
val
().
length
;
$passwordInput
.
on
(
'keyup blur'
,
function
()
{
var
length
=
$passwordInput
.
val
().
length
;
if
(
length
===
0
)
{
errTip
(
$p
wd
,
'请输入密码'
);
errTip
(
$p
asswordInput
,
'请输入密码'
);
ep
.
emit
(
'pwd'
,
false
);
return
;
}
if
(
length
<
6
||
length
>
20
)
{
errTip
(
$p
wd
,
'密码只支持 6-20 位字符,建议字母+数字的组合'
);
errTip
(
$p
asswordInput
,
'密码只支持 6-20 位字符,建议字母+数字的组合'
);
ep
.
emit
(
'pwd'
,
false
);
return
;
}
if
(
!
pwdRegx
.
test
(
$pwd
.
val
()))
{
errTip
(
$pwd
,
'密码只支持 6-20 位字符,建议字母+数字的组合'
);
if
(
!
pwdRegx
.
test
(
$passwordInput
.
val
()))
{
errTip
(
$passwordInput
,
'密码只支持 6-20 位字符,建议字母+数字的组合'
);
ep
.
emit
(
'pwd'
,
false
);
return
;
}
...
...
@@ -58,21 +73,23 @@ $pwd.on('keyup blur', function() {
ep
.
emit
(
'pwd'
,
true
);
});
$repwd
.
on
(
'keyup blur'
,
function
()
{
var
length
=
$repwd
.
val
().
length
;
$repasswordInput
.
on
(
'keyup blur'
,
function
()
{
var
length
=
$repasswordInput
.
val
().
length
;
if
(
length
===
0
)
{
errTip
(
$rep
wd
,
'请再次输入密码'
);
errTip
(
$rep
asswordInput
,
'请再次输入密码'
);
ep
.
emit
(
'repwd'
,
false
);
return
;
}
if
(
$pwd
.
val
()
!==
$repwd
.
val
())
{
errTip
(
$repwd
,
'两次输入的密码不一致,请重新输入'
);
if
(
$passwordInput
.
val
()
!==
$repasswordInput
.
val
())
{
errTip
(
$repasswordInput
,
'两次输入的密码不一致,请重新输入'
);
ep
.
emit
(
'repwd'
,
false
);
return
;
}
console
.
log
(
$passwordInput
.
val
(),
$repasswordInput
.
val
());
ep
.
emit
(
'repwd'
,
true
);
});
...
...
@@ -85,7 +102,7 @@ function nextPage() {
sourceType
:
$sourceType
.
val
(),
mobile
:
$mobile
.
val
(),
area
:
$area
.
val
(),
password
:
$p
wd
.
val
()
password
:
$p
asswordInput
.
val
()
}
}).
then
(
function
(
result
)
{
if
(
result
.
code
===
200
)
{
...
...
@@ -103,9 +120,21 @@ $next.on('click', function() {
return
;
}
if
(
$pwd
.
val
()
!==
$repwd
.
val
())
{
errTip
(
$repwd
,
'两次输入的密码不一致,请重新输入'
);
if
(
$passwordInput
.
val
()
!==
$repasswordInput
.
val
())
{
errTip
(
$repasswordInput
,
'两次输入的密码不一致,请重新输入'
);
return
;
}
nextPage
();
});
ep
.
on
(
'repwd'
,
function
(
repwdAuth
)
{
if
(
repwdAuth
)
{
hideTip
();
}
});
ep
.
on
(
'pwd'
,
function
(
pwdAuth
)
{
if
(
pwdAuth
)
{
hideTip
();
}
});
\ No newline at end of file
...
...
public/js/passport/login/index.js
View file @
ed07cee
/**
* 登录
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/12/11
* @description 登录
* @author TaoHuang
* @time 2016/7/14
*/
var
$
=
require
(
'yoho-jquery'
);
var
EventProxy
=
require
(
'../common/eventproxy'
);
var
$account
=
$
(
'#account'
),
$password
=
$
(
'#password'
),
$captcha
=
$
(
'#captcha'
),
$login
=
$
(
'#login-btn'
),
var
$phoneNumInput
=
$
(
'#account'
),
$passwordInput
=
$
(
'#password'
),
$captchaInput
=
$
(
'#captcha'
),
$loginBtn
=
$
(
'#login-btn'
),
$phone
=
$
(
'#phone'
);
var
$loginTip
=
$login
.
siblings
(
'.login-fail-tip'
),
var
$loginTip
=
$login
Btn
.
siblings
(
'.login-fail-tip'
),
ep
=
new
EventProxy
();
var
$countryCodeEm
=
$
(
'#country-code'
),
$countryList
=
$
(
'#country-list'
);
var
$regionCodeText
=
$
(
'#country-code'
),
$regionSelectCtrl
=
$
(
'#country-list'
);
var
$emailAutoComplete
=
$
(
'#email-autocomplete'
);
...
...
@@ -41,9 +42,6 @@ var emailAcTime;
var
$errTip
=
$
(
'.tips'
);
var
$errMsg
=
$errTip
.
find
(
'.rectangle'
);
$captcha
=
$captchaWrap
.
find
(
'#captcha'
);
require
(
'../../plugins/tips'
);
require
(
'yoho-jquery-placeholder'
);
function
errTip
(
ele
,
msg
)
{
...
...
@@ -61,21 +59,21 @@ function errTip(ele, msg) {
// 验证账户名
function
validateAccountLocal
()
{
var
account
=
$
.
trim
(
$account
.
val
()),
countryCode
=
$countryCodeEm
.
val
();
var
phoneNum
=
$
.
trim
(
$phoneNumInput
.
val
()),
regionCode
=
$regionCodeText
.
val
();
if
(
account
!==
''
)
{
if
(
/^
[
0-9
]
+$/
.
test
(
account
))
{
if
(
phoneNum
!==
''
)
{
if
(
/^
[
0-9
]
+$/
.
test
(
phoneNum
))
{
// 不是11位
if
(
account
.
length
!==
11
)
{
if
(
phoneNum
.
length
!==
11
)
{
ep
.
emit
(
'phone'
,
false
);
errTip
(
$phone
,
'手机号码不正确,请重新输入'
);
return
false
;
}
// 如果是纯数字,则作为手机号码处理
if
(
countryCode
!==
'+86'
||
mailPhoneRegx
.
phoneRegx
[
countryCode
].
test
(
account
))
{
if
(
regionCode
!==
'+86'
||
mailPhoneRegx
.
phoneRegx
[
regionCode
].
test
(
phoneNum
))
{
ep
.
emit
(
'phone'
,
true
);
return
true
;
}
else
{
...
...
@@ -86,7 +84,7 @@ function validateAccountLocal() {
}
else
{
// 邮箱验证
if
(
mailPhoneRegx
.
emailRegx
.
test
(
account
))
{
if
(
mailPhoneRegx
.
emailRegx
.
test
(
phoneNum
))
{
ep
.
emit
(
'phone'
,
true
);
return
true
;
}
else
{
...
...
@@ -108,8 +106,8 @@ function validateAccountAsync() {
type
:
'POST'
,
url
:
'/passport/login/user'
,
data
:
{
phoneNum
:
$account
.
val
(),
area
:
$countryCodeEm
.
val
().
replace
(
'+'
,
''
)
phoneNum
:
$phoneNumInput
.
val
(),
area
:
$regionCodeText
.
val
().
replace
(
'+'
,
''
)
}
}).
then
(
function
(
data
)
{
if
(
data
.
code
&&
data
.
code
===
200
)
{
...
...
@@ -139,20 +137,20 @@ function validateAccount() {
// 验证密码
function
validatePasswordLocal
()
{
var
password
=
$
.
trim
(
$password
.
val
());
var
password
=
$
.
trim
(
$password
Input
.
val
());
var
length
=
password
.
length
;
if
(
length
!==
0
)
{
if
(
length
<
6
)
{
ep
.
emit
(
'password'
,
false
);
errTip
(
$password
,
'请输入长度为6-20字符的密码'
);
errTip
(
$password
Input
,
'请输入长度为6-20字符的密码'
);
return
false
;
}
else
{
ep
.
emit
(
'password'
,
true
);
return
true
;
}
}
else
{
errTip
(
$password
,
'请输入密码'
);
errTip
(
$password
Input
,
'请输入密码'
);
ep
.
emit
(
'password'
,
false
);
return
false
;
}
...
...
@@ -160,7 +158,7 @@ function validatePasswordLocal() {
// 验证验证码
function
validateCaptchaLocal
()
{
var
captcha
=
$
.
trim
(
$captcha
.
val
());
var
captcha
=
$
.
trim
(
$captcha
Input
.
val
());
var
length
=
captcha
.
length
;
if
(
$captchaWrap
.
hasClass
(
'hide'
))
{
...
...
@@ -170,14 +168,14 @@ function validateCaptchaLocal() {
switch
(
length
)
{
case
0
:
errTip
(
$captcha
,
'请输入验证码'
);
errTip
(
$captcha
Input
,
'请输入验证码'
);
ep
.
emit
(
'captcha'
,
false
);
break
;
case
4
:
ep
.
emit
(
'captcha'
,
true
);
break
;
default
:
errTip
(
$captcha
,
'请输入长度为4字符的验证码'
);
errTip
(
$captcha
Input
,
'请输入长度为4字符的验证码'
);
ep
.
emit
(
'captcha'
,
false
);
break
;
}
...
...
@@ -187,7 +185,7 @@ function validateCaptchaLocal() {
function
showAccountErrTimes
()
{
$captchaWrap
.
removeClass
(
'hide'
);
$captchaImg
.
attr
(
'src'
,
captchaUrl
+
$
.
now
());
$captcha
.
val
(
''
);
$captcha
Input
.
val
(
''
);
}
// 登录
...
...
@@ -196,10 +194,10 @@ function login() {
url
:
'/passport/login/auth'
,
type
:
'POST'
,
data
:
{
areaCode
:
$countryCodeEm
.
val
().
replace
(
'+'
,
''
),
account
:
$
.
trim
(
$account
.
val
()),
password
:
$
.
trim
(
$password
.
val
()),
captcha
:
$
.
trim
(
$captcha
.
val
()),
areaCode
:
$regionCodeText
.
val
().
replace
(
'+'
,
''
),
account
:
$
.
trim
(
$phoneNumInput
.
val
()),
password
:
$
.
trim
(
$passwordInput
.
val
()),
captcha
:
$
.
trim
(
$captchaInput
.
val
()),
isRemember
:
$remember
.
hasClass
(
'checked'
)
?
true
:
false
},
success
:
function
(
res
)
{
...
...
@@ -211,10 +209,10 @@ function login() {
}
}
else
{
if
(
res
.
data
.
errorType
===
'captcha'
)
{
$captcha
.
val
(
''
);
$captcha
Input
.
val
(
''
);
}
else
{
$loginTip
.
removeClass
(
'hide'
).
children
(
'em'
).
html
(
res
.
message
);
$password
.
val
(
''
);
$password
Input
.
val
(
''
);
}
// 验证错误次数
...
...
@@ -226,22 +224,22 @@ function login() {
});
}
mailAc
(
$
accoun
t
,
function
()
{
mailAc
(
$
phoneNumInpu
t
,
function
()
{
function
validateUser
()
{
return
$
.
ajax
({
url
:
'/passport/login/account'
,
type
:
'GET'
,
data
:
{
account
:
$
.
trim
(
$
accoun
t
.
val
())
account
:
$
.
trim
(
$
phoneNumInpu
t
.
val
())
}
});
}
$
.
when
(
validateAccount
()
).
then
(
function
(
result
)
{
validateAccount
(
).
then
(
function
(
result
)
{
if
(
result
)
{
return
$
.
when
(
validateUser
()
);
return
validateUser
(
);
}
else
{
return
$
.
when
(
false
)
;
return
false
;
}
}).
then
(
function
(
res
)
{
if
(
!
res
)
{
...
...
@@ -254,7 +252,7 @@ mailAc($account, function() {
});
});
$
accoun
t
.
on
(
'focus'
,
function
()
{
$
phoneNumInpu
t
.
on
(
'focus'
,
function
()
{
$phone
.
addClass
(
'focus'
);
}).
on
(
'blur'
,
function
()
{
$phone
.
removeClass
(
'focus'
);
...
...
@@ -262,33 +260,33 @@ $account.on('focus', function() {
$
(
'[placeholder]'
).
placeholder
();
$
countryList
.
change
(
function
()
{
$
regionSelectCtrl
.
change
(
function
()
{
var
$this
=
$
(
this
);
$
countryCodeEm
.
text
(
$this
.
val
());
$
regionCodeText
.
text
(
$this
.
val
());
});
// 密码
$password
.
on
(
'blur'
,
function
()
{
$password
.
removeClass
(
'focus'
);
$passwordInput
.
on
(
'blur'
,
function
()
{
$passwordInput
.
removeClass
(
'focus'
);
validatePasswordLocal
();
$captcha
.
trigger
(
'blur'
);
$captcha
Input
.
trigger
(
'blur'
);
}).
on
(
'focus'
,
function
()
{
$password
.
addClass
(
'focus'
);
$password
Input
.
addClass
(
'focus'
);
});
// 验证码
$captcha
.
on
(
'blur'
,
function
()
{
$captcha
.
removeClass
(
'focus'
);
$captchaInput
.
on
(
'blur'
,
function
()
{
$captchaInput
.
removeClass
(
'focus'
);
validateCaptchaLocal
();
}).
on
(
'focus'
,
function
()
{
$captcha
.
addClass
(
'focus'
);
$captcha
Input
.
addClass
(
'focus'
);
});
// 邮箱自动完成列表项点击
$emailAutoComplete
.
on
(
'click'
,
'li'
,
function
()
{
clearTimeout
(
emailAcTime
);
// 清空默认关闭
$
accoun
t
.
val
(
$
(
this
).
text
()).
focus
();
$
phoneNumInpu
t
.
val
(
$
(
this
).
text
()).
focus
();
$emailAutoComplete
.
addClass
(
'hide'
);
});
...
...
@@ -318,16 +316,16 @@ $captchaWrap.on('click', '.change-captcha, .captcha-img', function() {
});
// 初始:只带账户名的页面,密码输入获得焦点
if
((
$account
.
val
()
!==
''
||
$account
.
val
()
===
$account
.
attr
(
'placeholder'
))
&&
$password
.
val
()
===
''
)
{
$password
.
focus
();
if
((
$phoneNumInput
.
val
()
!==
''
||
$phoneNumInput
.
val
()
===
$phoneNumInput
.
attr
(
'placeholder'
))
&&
$passwordInput
.
val
()
===
''
)
{
$passwordInput
.
focus
();
}
ep
.
tail
(
'phone'
,
'password'
,
'captcha'
,
function
(
phoneAuth
,
passwordAuth
,
captchaAuth
)
{
if
(
phoneAuth
&&
passwordAuth
&&
captchaAuth
)
{
$login
.
removeClass
(
'auth_ok'
);
$login
Btn
.
removeClass
(
'auth_ok'
);
}
else
{
$login
.
addClass
(
'auth_ok'
);
$login
Btn
.
addClass
(
'auth_ok'
);
}
});
...
...
@@ -350,8 +348,8 @@ ep.on('captcha', function(auth) {
});
// 登录
$login
.
on
(
'click'
,
function
()
{
if
(
$login
.
hasClass
(
'auth_ok'
))
{
$loginBtn
.
on
(
'click'
,
function
()
{
if
(
$loginBtn
.
hasClass
(
'auth_ok'
))
{
return
;
}
...
...
public/js/passport/reg/reg.js
View file @
ed07cee
/*
* @description 注册页js
* @time 2015/12/14
* @description 注册
* @author TaoHuang
* @time 2016/7/14
*/
var
$
=
require
(
'yoho-jquery'
),
regValidate
=
require
(
'../common/mail-phone-regx'
),
computeComplex
=
require
(
'../common/pwd-strength'
);
computeComplex
=
require
(
'../common/pwd-strength'
),
EventProxy
=
require
(
'../common/eventproxy'
);
var
$registerPage
=
$
(
'.register-page'
),
$pwdTips
=
$
(
'#pwd-tips'
),
$pwdTip1
=
$pwdTips
.
find
(
'#pwd-tip1'
),
$errTip
=
$
(
'.tips'
),
$phone
=
$
(
'#phone'
);
var
$phoneNumInput
=
$
(
'#phone-num'
),
$smsCaptchaInput
=
$
(
'#msg-captcha'
),
$smsCaptchaCtrl
=
$
(
'#send-captcha'
),
$passwordInput
=
$
(
'#pwd'
),
$imgCaptchaInput
=
$
(
'#captcha'
),
$agreeTermsInput
=
$
(
'.agree-terms'
),
$regionSelectCtrl
=
$
(
'#region'
),
$regionCodeText
=
$
(
'#country-code'
),
$registerBtn
=
$
(
'#register-btn'
);
// $countDown = $('#count-down'),
// $successBtn = $('.success-btn'),
// countDown = 5,
// clearT;
var
second
=
60
;
var
ep
=
new
EventProxy
();
var
$sendCaptcha
=
$
(
'#send-captcha'
),
caCount
=
4
,
validateResult
=
[];
var
$pn
=
$
(
'#phone-num'
),
$mc
=
$
(
'#msg-captcha'
),
$pwd
=
$
(
'#pwd'
),
$ca
=
$
(
'#captcha'
),
timeResidue
=
0
;
// 密码强度验证
var
$pwdIntensity
=
$
(
'.pwd-intensity'
),
$pwdParent
=
$pwdIntensity
.
closest
(
'.pwd-intensity-container'
);
// signup验证
var
$region
=
$
(
'#country-code'
),
$regionSelect
=
$
(
'#region'
);
var
$agreeTerms
=
$
(
'.agree-terms'
);
var
pwdReg
=
regValidate
.
pwdValidateRegx
;
var
$curErrContainer
;
var
oldPhone
=
''
;
// 如果手机号改变时刷新验证码
// checkbox status unicode
var
checkbox
=
{
var
checkboxIcon
=
{
checked
:
''
,
unchecked
:
''
};
require
(
'yoho-jquery-placeholder'
);
setTimeout
(
function
()
{
$pn
.
val
(
''
);
$mc
.
val
(
''
);
$pwd
.
val
(
''
);
$ca
.
val
(
''
);
},
0
);
// 验证码位数
$ca
.
attr
(
'maxlength'
,
caCount
);
// 密码规则提示
$pwd
.
focus
(
function
()
{
$pwdTips
.
removeClass
(
'hide'
);
var
$errTip
=
$
(
'.tips'
),
$errMsg
=
$errTip
.
find
(
'.rectangle'
);
// isPwd = true;
// pwdVal = $(this).val();
}).
blur
(
function
()
{
$pwdTips
.
addClass
(
'hide'
);
// isPwd = false;
});
// 同意服务条款
$agreeTerms
.
on
(
'click'
,
function
()
{
var
$this
=
$
(
this
);
var
i
,
passI
=
0
;
$this
.
toggleClass
(
'checked'
);
require
(
'yoho-jquery-placeholder'
);
if
(
$this
.
hasClass
(
'checked'
))
{
$this
.
children
(
'span'
).
html
(
checkbox
.
checked
);
function
errTip
(
ele
,
msg
)
{
var
topLeft
=
ele
.
offset
();
// 勾选
for
(
i
=
0
;
i
<
validateResult
.
length
;
i
++
)
{
if
(
validateResult
[
i
].
status
)
{
passI
++
;
}
}
if
(
passI
===
4
)
{
$registerBtn
.
removeClass
(
'disable'
).
removeAttr
(
'disabled'
);
}
}
else
{
$this
.
children
(
'span'
).
html
(
checkbox
.
unchecked
);
$errMsg
.
text
(
msg
);
return
$errTip
.
css
({
top
:
topLeft
.
top
+
ele
.
height
()
-
2
,
left
:
topLeft
.
left
,
width
:
ele
.
width
()
+
2
,
height
:
ele
.
height
}).
removeClass
(
'hide'
);
}
// 取消勾选
$registerBtn
.
addClass
(
'disable'
).
attr
(
'disabled'
,
'disabled'
);
}
});
function
hideTip
()
{
return
$errTip
.
addClass
(
'hide'
);
}
setTimeout
(
function
()
{
$phoneNumInput
.
val
(
''
);
$smsCaptchaInput
.
val
(
''
);
$passwordInput
.
val
(
''
);
$imgCaptchaInput
.
val
(
''
);
},
0
);
// IE8 placeholder
$
(
'[placeholder]'
).
placeholder
();
// 存储校验信息
validateResult
=
[
{
id
:
'phone'
,
message
:
''
,
// 错误信息
status
:
false
// 当前的状态
},
{
id
:
'captcha'
,
message
:
''
,
status
:
false
},
{
id
:
'msg-captcha'
,
message
:
''
,
status
:
false
},
{
id
:
'pwd'
,
message
:
''
,
status
:
false
}
];
// 刷新图形验证码
function
refresh
Pic
()
{
function
refresh
ImgCaptcha
()
{
var
time
=
new
Date
(),
$captchaImg
=
$
(
'.captcha-img'
),
captchaImgSrc
=
$captchaImg
.
attr
(
'src'
).
split
(
'?'
)[
0
];
...
...
@@ -141,293 +76,254 @@ function refreshPic() {
}
// 手机号ajax校验
function
phoneAjaxFn
(
page
,
callback
)
{
var
url
,
data
;
if
(
page
===
'reg'
)
{
url
=
'/passport/reg/checkmobile'
;
data
=
{
mobile
:
$pn
.
val
(),
area
:
$region
.
text
().
split
(
'+'
)[
1
]
};
}
else
if
(
page
===
'third'
)
{
url
=
'/passport/autouserinfo/bindCheck'
;
data
=
{
mobile
:
$pn
.
val
(),
area
:
$region
.
text
().
split
(
'+'
)[
1
],
openId
:
$
(
'#open-id'
).
val
(),
sourceType
:
$
(
'#source-type'
).
val
()
};
}
validateResult
[
0
].
message
=
'err'
;
validateResult
[
0
].
status
=
false
;
$
.
ajax
({
url
:
url
,
function
validatePhoneNumAsync
()
{
return
$
.
ajax
({
url
:
'/passport/reg/checkmobile'
,
type
:
'POST'
,
data
:
data
}).
then
(
function
(
res
)
{
if
(
!
res
)
{
return
;
data
:
{
mobile
:
$phoneNumInput
.
val
(),
area
:
$regionCodeText
.
text
().
split
(
'+'
)[
1
]
}
}).
then
(
function
(
result
)
{
if
(
!
result
)
{
return
false
;
}
switch
(
res
.
code
)
{
switch
(
res
ult
.
code
)
{
case
200
:
if
(
$pn
.
val
()
!==
oldPhone
&&
oldPhone
!==
''
)
{
// 如果手机号发生改变则刷新验证码并且更新状态
refreshPic
();
$sendCaptcha
.
addClass
(
'disable'
).
attr
(
'disabled'
,
'disabled'
);
validateResult
[
1
].
message
=
'图形验证码错误'
;
validateResult
[
1
].
status
=
false
;
}
oldPhone
=
$pn
.
val
();
validateResult
[
0
].
message
=
''
;
validateResult
[
0
].
status
=
true
;
break
;
return
true
;
case
400
:
refreshPic
();
validateResult
[
0
].
message
=
res
.
message
;
validateResult
[
0
].
status
=
false
;
break
;
refreshImgCaptcha
();
errTip
(
$phone
,
result
.
message
);
return
false
;
default
:
break
;
return
false
;
}
callback
();
});
}
// 图形验证码ajax校验
function
picCaptchaAjaxFn
(
page
,
callback
)
{
var
url
;
function
validateImgCaptchaLocal
()
{
var
length
=
$imgCaptchaInput
.
val
().
length
;
if
(
page
===
'reg'
)
{
url
=
'/passport/reg/piccaptcha'
;
}
else
if
(
page
===
'third'
)
{
url
=
'/passport/autouserinfo/checkPicCode'
;
if
(
length
===
0
)
{
errTip
(
$imgCaptchaInput
,
'请输入验证码'
);
return
false
;
}
else
if
(
length
!==
4
)
{
errTip
(
$imgCaptchaInput
,
'验证码不正确'
);
return
false
;
}
else
{
return
true
;
}
$
.
ajax
({
}
// 图形验证码ajax校验
function
validateImgCaptchaAsync
()
{
return
$
.
ajax
({
type
:
'POST'
,
url
:
url
,
url
:
'/passport/reg/piccaptcha'
,
data
:
{
verifyCode
:
$ca
.
val
()
// mobile: $pn.val(),
// area: $region.text().split('+')[1]
verifyCode
:
$imgCaptchaInput
.
val
()
}
}).
then
(
function
(
data
)
{
if
(
!
data
)
{
return
;
return
false
;
}
switch
(
data
.
code
)
{
case
200
:
validateResult
[
1
].
message
=
''
;
validateResult
[
1
].
status
=
true
;
break
;
return
true
;
case
400
:
refreshPic
();
validateResult
[
1
].
message
=
'图形验证码错误'
;
validateResult
[
1
].
status
=
false
;
break
;
refreshImgCaptcha
();
errTip
(
$imgCaptchaInput
,
'图形验证码错误'
);
return
false
;
default
:
break
;
return
false
;
}
callback
();
});
}
// 短信验证码ajax校验
function
msgCaptchaAjaxFn
(
page
,
callback
)
{
var
url
;
function
validateImgCaptcha
()
{
function
validate
()
{
var
defer
=
$
.
Deferred
();
// eslint-disable-line
if
(
validateImgCaptchaLocal
())
{
validateImgCaptchaAsync
().
then
(
function
(
result
)
{
if
(
result
)
{
defer
.
resolve
(
true
);
}
else
{
defer
.
reject
(
false
);
}
});
}
else
{
defer
.
reject
(
false
);
}
if
(
page
===
'reg'
)
{
url
=
'/passport/reg/msgcaptcha'
;
}
else
if
(
page
===
'third'
)
{
url
=
'/passport/autouserinfo/checkBindMsg'
;
return
defer
.
promise
();
}
$
.
ajax
({
return
validate
().
then
(
function
()
{
hideTip
();
ep
.
emit
(
'captcha-img'
,
true
);
}).
fail
(
function
()
{
ep
.
emit
(
'captcha-img'
,
false
);
});
}
function
validateSMSCaptchaLocal
()
{
var
length
=
$smsCaptchaInput
.
val
().
length
;
if
(
length
===
0
)
{
errTip
(
$smsCaptchaInput
,
'请输入短信验证码'
);
return
false
;
}
else
if
(
length
!==
4
)
{
errTip
(
$smsCaptchaInput
,
'短信验证码不正确'
);
return
false
;
}
else
{
return
true
;
}
}
// 短信验证码ajax验证
function
validateSMSCaptchaAsync
()
{
return
$
.
ajax
({
type
:
'POST'
,
url
:
url
,
url
:
'/passport/reg/msgcaptcha'
,
data
:
{
code
:
$mc
.
val
(),
mobile
:
$pn
.
val
(),
area
:
$region
.
text
().
split
(
'+'
)[
1
]
code
:
$smsCaptchaInput
.
val
(),
mobile
:
$phoneNumInput
.
val
(),
area
:
$regionCodeText
.
text
().
split
(
'+'
)[
1
]
}
}).
then
(
function
(
data
)
{
if
(
!
data
)
{
return
;
return
false
;
}
switch
(
data
.
code
)
{
case
200
:
validateResult
[
2
].
message
=
''
;
validateResult
[
2
].
status
=
true
;
break
;
return
true
;
case
400
:
validateResult
[
2
].
message
=
'短信验证码错误'
;
validateResult
[
2
].
status
=
false
;
break
;
errTip
(
$smsCaptchaInput
,
'短信验证码错误'
);
return
false
;
default
:
break
;
return
false
;
}
callback
();
});
}
// 验证
function
validateRule
(
page
,
$element
,
callback
)
{
var
val
=
$
.
trim
(
$element
.
val
()),
regionCode
;
// 根据需求http://redmine.yoho.cn/issues/3117改成上边的正则
// 对应的错误提示语也改了,感觉要不了多久就会改回来
// pwdReg = /^([a-zA-Z0-9\-\+_!@\#$%\^&\*\(\)\:\;\.=\[\]\\\',\?]){6,20}$/gi;
// 手机号校验
if
(
$element
.
hasClass
(
'phone-num'
))
{
regionCode
=
$region
.
text
();
if
(
val
===
''
)
{
validateResult
[
0
].
message
=
'请输入手机号码'
;
validateResult
[
0
].
status
=
false
;
return
callback
();
function
validateSMSCaptcha
()
{
function
validate
()
{
var
defer
=
$
.
Deferred
();
// eslint-disable-line
if
(
validateSMSCaptchaLocal
())
{
validateSMSCaptchaAsync
().
then
(
function
(
result
)
{
if
(
result
)
{
defer
.
resolve
(
true
);
}
else
{
defer
.
reject
(
false
);
}
});
}
else
{
if
(
!
/^
[
0-9
]
+$/
.
test
(
val
)
||
(
regionCode
===
'+86'
&&
!
regValidate
.
phoneRegx
[
regionCode
].
test
(
val
)))
{
validateResult
[
0
].
message
=
'手机号码格式不正确,请重新输入'
;
validateResult
[
0
].
status
=
false
;
return
callback
();
}
else
{
phoneAjaxFn
(
page
,
callback
);
}
defer
.
reject
(
false
);
}
// 图形验证码校验
}
else
if
(
$element
.
hasClass
(
'captcha'
))
{
if
(
val
===
''
)
{
validateResult
[
1
].
message
=
'请输入图形验证码'
;
validateResult
[
1
].
status
=
false
;
return
callback
();
}
else
if
(
val
.
length
<=
3
)
{
validateResult
[
1
].
message
=
'图形验证码为4位'
;
validateResult
[
1
].
status
=
false
;
return
callback
();
}
else
{
// 并且手机号正确
if
(
validateResult
[
0
].
status
)
{
picCaptchaAjaxFn
(
page
,
callback
);
}
else
{
validateResult
[
1
].
message
=
'图形验证码错误'
;
validateResult
[
1
].
status
=
false
;
return
callback
();
}
}
// 短信验证码校验
}
else
if
(
$element
.
hasClass
(
'msg-captcha'
))
{
if
(
val
===
''
)
{
validateResult
[
2
].
message
=
'请输入短信验证码'
;
validateResult
[
2
].
status
=
false
;
return
callback
();
}
else
if
(
val
.
length
<=
3
)
{
validateResult
[
2
].
message
=
'短信验证码错误'
;
validateResult
[
2
].
status
=
false
;
return
callback
();
}
else
{
// 并且图形验证码正确
if
(
validateResult
[
1
].
status
)
{
msgCaptchaAjaxFn
(
page
,
callback
);
}
else
{
validateResult
[
2
].
message
=
'短信验证码错误'
;
validateResult
[
2
].
status
=
false
;
return
callback
();
}
}
return
defer
.
promise
();
}
// 密码校验
}
else
if
(
$element
.
hasClass
(
'pwd'
))
{
if
(
val
===
''
)
{
validateResult
[
3
].
message
=
'请输入密码'
;
validateResult
[
3
].
status
=
false
;
return
validate
().
then
(
function
()
{
hideTip
();
ep
.
emit
(
'captcha-sms'
,
true
);
}).
fail
(
function
()
{
ep
.
emit
(
'captcha-sms'
,
false
);
});
}
}
else
if
(
val
.
length
<
6
||
val
.
length
>
20
)
{
validateResult
[
3
].
message
=
'密码只支持6-20位字符'
;
validateResult
[
3
].
status
=
false
;
function
validatePhoneNumLocal
()
{
var
phoneNum
=
$phoneNumInput
.
val
(),
length
=
phoneNum
.
length
,
regionCode
=
$regionCodeText
.
text
();
if
(
length
===
0
)
{
errTip
(
$phone
,
'请输入手机号码'
);
return
false
;
}
else
if
(
length
!==
11
)
{
errTip
(
$phone
,
'手机号码格式不正确,请重新输入'
);
return
false
;
}
else
if
(
!
/^
[
0-9
]
+$/
.
test
(
phoneNum
)
||
(
regionCode
===
'+86'
&&
!
regValidate
.
phoneRegx
[
regionCode
].
test
(
phoneNum
)))
{
errTip
(
$phone
,
'手机号码格式不正确,请重新输入'
);
return
false
;
}
else
{
return
true
;
}
}
}
else
if
(
!
pwdReg
.
test
(
$element
.
val
()))
{
validateResult
[
3
].
message
=
'密码须字母和数字组合'
;
validateResult
[
3
].
status
=
false
;
function
validatePhoneNum
()
{
function
validate
()
{
var
defer
=
$
.
Deferred
();
// eslint-disable-line
if
(
validatePhoneNumLocal
())
{
validatePhoneNumAsync
().
then
(
function
(
result
)
{
if
(
result
)
{
defer
.
resolve
(
true
);
}
else
{
defer
.
reject
(
false
);
}
});
}
else
{
validateResult
[
3
].
message
=
''
;
validateResult
[
3
].
status
=
true
;
defer
.
reject
(
false
);
}
return
callback
();
return
defer
.
promise
();
}
}
function
posErrTip
()
{
var
tipPos
=
$curErrContainer
.
offset
();
return
$errTip
.
css
({
top
:
tipPos
.
top
+
$curErrContainer
.
height
()
-
2
,
left
:
tipPos
.
left
,
width
:
$curErrContainer
.
width
()
+
2
,
height
:
$curErrContainer
.
height
()
return
validate
().
then
(
function
()
{
hideTip
();
ep
.
emit
(
'phone-num'
,
true
);
}).
fail
(
function
()
{
ep
.
emit
(
'phone-num'
,
false
);
});
}
// 显示提示信息
function
showErrTip
()
{
var
show
=
false
,
i
,
validateResultLen
=
validateResult
.
length
;
for
(
i
=
0
;
i
<
validateResultLen
;
i
++
)
{
if
(
!
show
)
{
// 不可以通过status判断
if
(
!!
validateResult
[
i
].
message
&&
validateResult
[
i
].
message
!==
'err'
)
{
function
validatePasswordLocal
()
{
var
val
=
$passwordInput
.
val
(),
length
=
val
.
length
;
if
(
length
===
0
)
{
errTip
(
$passwordInput
,
'请输入密码'
);
return
false
;
}
else
if
(
length
<
6
||
val
.
length
>
20
)
{
errTip
(
$passwordInput
,
'密码只支持6-20位字符'
);
return
false
;
}
else
if
(
!
pwdReg
.
test
(
val
))
{
errTip
(
$passwordInput
,
'密码只支持 6-20 位字符,建议字母+数字的组合'
);
return
false
;
}
else
{
return
true
;
}
}
// 显示错误提示
$errTip
.
find
(
'.rectangle'
).
text
(
validateResult
[
i
].
message
);
$curErrContainer
=
$
(
'#'
+
validateResult
[
i
].
id
);
posErrTip
().
removeClass
(
'hide'
);
function
validatePassword
()
{
function
validate
()
{
var
defer
=
$
.
Deferred
();
// eslint-disable-line
show
=
true
;
// 停止判断
}
else
{
$errTip
.
addClass
(
'hide'
);
}
if
(
validatePasswordLocal
())
{
defer
.
resolve
(
true
);
}
else
{
defer
.
reject
(
false
);
}
return
defer
.
promise
();
}
return
validate
().
then
(
function
()
{
hideTip
();
ep
.
emit
(
'password'
,
true
);
}).
fail
(
function
()
{
ep
.
emit
(
'password'
,
false
);
});
}
// 密码强度验证
function
pwdFn
(
$obj
)
{
function
validatePasswordComplexLocal
(
$obj
)
{
var
pwd
=
$obj
.
val
(),
pwdStrength
=
computeComplex
(
pwd
),
level
=
0
;
...
...
@@ -464,253 +360,187 @@ function pwdFn($obj) {
default
:
break
;
}
// 提示框
if
(
pwd
===
''
)
{
$pwdTip1
.
removeClass
(
'red yes no'
).
addClass
(
'default'
);
}
else
if
(
pwd
.
length
<
6
||
pwd
.
length
>
20
)
{
$pwdTip1
.
removeClass
(
'default yes'
).
addClass
(
'no red'
);
}
else
{
$pwdTip1
.
removeClass
(
'default no red'
).
addClass
(
'yes'
);
}
}
// 重新定位错误提示
$
(
window
).
resize
(
function
()
{
if
(
$errTip
.
hasClass
(
'hide'
))
{
return
;
}
posErrTip
();
});
// 失去焦点时开始校验
// Tips: 不可以在获得焦点的时候验证,获得焦点和失去焦点的间隔太小,如果中间存在ajax校验的话会出现问题
// ( ▼-▼ )注册页和信息完善页面接口不同
exports
.
init
=
function
(
page
)
{
// $('#agree-terms').click(function() {
//
// var $this = $(this),
// i,
// passI = 0;
//
// if ($this.('notchecked') {
//
// $this.removeAttr('notchecked');
//
// // 勾选
// for (i = 0; i < validateResult.length; i++) {
// if (validateResult[i].status) {
// passI++;
// }
// }
// if (passI === 4) {
// $registerBtn.removeClass('disable').removeAttr('disabled');
// }
// } else {
//
// // 取消勾选
// $registerBtn.addClass('disable').attr('disabled', 'disabled');
// $this.attr('notchecked', 'notchecked');
// }
// });
// 按回车键提交
$registerPage
.
on
(
'keydown'
,
function
(
e
)
{
var
key
=
e
.
which
;
if
(
key
===
13
)
{
$registerBtn
.
click
();
function
register
()
{
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/reg/mobileregister'
,
data
:
{
area
:
$regionCodeText
.
text
().
split
(
'+'
)[
1
],
mobile
:
$phoneNumInput
.
val
(),
verifyCode
:
$imgCaptchaInput
.
val
(),
code
:
$smsCaptchaInput
.
val
(),
password
:
$passwordInput
.
val
()
}
})
;
})
.
then
(
function
(
data
)
{
$registerPage
.
find
(
'.va'
).
keyup
(
function
()
{
var
time
=
0
,
t
,
refer
;
var
j
,
statusLen
=
0
,
vLen
=
validateResult
.
length
,
$that
=
$
(
this
);
if
(
data
.
code
===
200
)
{
validateRule
(
page
,
$
(
this
),
function
()
{
showErrTip
();
// 显示错误提示
refer
=
data
.
data
.
href
;
// 如果validateResult中有4个status为true表示验证通过
for
(
j
=
0
;
j
<
vLen
;
j
++
)
{
t
=
setTimeout
(
function
()
{
time
++
;
},
1000
);
if
(
validateResult
[
j
].
status
)
{
$
.
ajax
({
type
:
'GET'
,
url
:
data
.
data
.
session
}).
then
(
function
(
res
)
{
statusLen
++
;
if
(
res
.
code
===
200
&&
t
<
3
)
{
clearInterval
(
t
);
location
.
href
=
refer
;
}
});
if
(
t
>=
3
)
{
clearInterval
(
t
);
location
.
href
=
refer
;
}
if
(
statusLen
===
4
&&
!
$
(
'#agree-terms'
).
attr
(
'notchecked'
))
{
$registerBtn
.
removeClass
(
'disable'
).
removeAttr
(
'disabled'
);
}
else
{
$registerBtn
.
addClass
(
'disable'
).
attr
(
'disabled'
,
'disabled'
);
}
// 图形验证通过时,发送短信按钮可点击
if
(
validateResult
[
1
].
status
&&
timeResidue
<=
0
)
{
$sendCaptcha
.
removeClass
(
'disable'
).
removeAttr
(
'disabled'
);
}
else
{
$sendCaptcha
.
addClass
(
'disable'
).
attr
(
'disabled'
,
'disabled'
);
}
// 图形验证通过时,发送短信按钮可点击 end
});
// 如果是密码则校验强度
if
((
$that
).
hasClass
(
'pwd'
))
{
pwdFn
(
$that
);
}
else
{
console
.
log
(
'网络超时~'
);
}
}).
blur
(
function
()
{
});
}
/* validateRule($(this), function() {
showErrTip();
showBorder(); // 显示红色边框
});*/
function
sendSMSCaptcha
()
{
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/reg/sendBindMsg'
,
data
:
{
area
:
$regionCodeText
.
text
().
split
(
'+'
)[
1
],
mobile
:
$phoneNumInput
.
val
(),
verifyCode
:
$imgCaptchaInput
.
val
()
}
});
}
$regionSelect
.
change
(
function
()
{
function
disableSMSBtn
()
{
second
-=
1
;
if
(
second
<
0
)
{
second
=
60
;
$smsCaptchaCtrl
.
text
(
'获取短信验证码'
);
$smsCaptchaCtrl
.
removeClass
(
'disable'
);
}
else
{
$smsCaptchaCtrl
.
text
(
second
+
'秒后可重新操作'
);
window
.
setTimeout
(
disableSMSBtn
,
1000
);
}
}
$region
.
text
(
$
(
'#region'
).
val
());
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'
);
}
});
validateRule
(
page
,
$pn
,
showErrTip
);
// 验证
// 验证手机输入
$phoneNumInput
.
on
(
'keyup'
,
function
()
{
validatePhoneNum
();
});
// 点击发送验证码
$sendCaptcha
.
click
(
function
()
{
var
t
,
url
;
// 验证图形输入
$imgCaptchaInput
.
on
(
'keyup'
,
function
()
{
validateImgCaptcha
();
});
if
(
$
(
this
).
hasClass
(
'disable'
))
{
return
;
// 图形验证通过时,发送短信按钮可点击
ep
.
on
(
'captcha-img'
,
function
(
auth
)
{
if
(
auth
)
{
$smsCaptchaCtrl
.
removeClass
(
'disable'
);
}
else
{
$smsCaptchaCtrl
.
addClass
(
'disable'
);
}
});
timeResidue
=
60
;
$
(
'#msg-tip'
).
removeClass
(
'hide'
);
$sendCaptcha
.
addClass
(
'disable'
).
attr
(
'disabled'
,
'disabled'
);
$sendCaptcha
.
val
(
'60秒可重新操作'
);
t
=
setInterval
(
function
()
{
if
(
timeResidue
<=
0
)
{
$sendCaptcha
.
removeClass
(
'disable'
).
removeAttr
(
'disabled'
).
val
(
'获取短信验证码'
);
clearInterval
(
t
);
return
;
}
$sendCaptcha
.
val
(
timeResidue
--
+
'秒可重新操作'
);
},
1000
);
// 验证短信输入
$smsCaptchaInput
.
on
(
'keyup'
,
function
()
{
validateSMSCaptcha
();
});
if
(
page
===
'reg'
)
{
url
=
'/passport/reg/sendBindMsg'
;
}
else
if
(
page
===
'third'
)
{
url
=
'/passport/autouserinfo/sendBindMsg'
;
}
// 验证密码输入
$passwordInput
.
on
(
'keyup'
,
function
()
{
var
$this
=
$
(
this
);
// todo ajax 发送验证码
$
.
ajax
({
type
:
'POST'
,
url
:
url
,
data
:
{
area
:
$region
.
text
().
split
(
'+'
)[
1
],
mobile
:
$pn
.
val
(),
verifyCode
:
$ca
.
val
()
}
validatePassword
().
always
(
function
()
{
validatePasswordComplexLocal
(
$this
);
});
});
// 防止粘贴密码
if
(
$
(
'.success-box'
).
length
<=
0
)
{
$pwd
[
0
].
onpaste
=
function
()
{
return
false
;
};
}
// 服务条款
$agreeTermsInput
.
on
(
'click'
,
function
()
{
var
$this
=
$
(
this
);
// ajax表单提交
$registerBtn
.
click
(
function
()
{
var
url
;
$this
.
toggleClass
(
'checked'
);
if
(
page
===
'reg'
)
{
url
=
'/passport/reg/mobileregister'
;
}
else
if
(
page
===
'third'
)
{
url
=
'/passport/autouserinfo/bindMobile'
;
if
(
$this
.
hasClass
(
'checked'
))
{
// 勾选
$this
.
children
(
'span'
).
html
(
checkboxIcon
.
checked
);
ep
.
emit
(
'agree'
,
true
);
}
else
{
// 取消勾选
$this
.
children
(
'span'
).
html
(
checkboxIcon
.
unchecked
);
ep
.
emit
(
'agree'
,
false
);
}
});
// 选择区域代码,验证手机号
$regionSelectCtrl
.
on
(
'change'
,
function
()
{
$regionCodeText
.
text
(
$
(
'#region'
).
val
());
validatePhoneNum
();
});
// 点击发送验证码
$smsCaptchaCtrl
.
on
(
'click'
,
function
()
{
if
(
$
(
this
).
hasClass
(
'disable'
))
{
return
;
}
else
{
// ajax提交
$
.
ajax
({
type
:
'POST'
,
url
:
url
,
data
:
{
area
:
$region
.
text
().
split
(
'+'
)[
1
],
mobile
:
$pn
.
val
(),
verifyCode
:
$ca
.
val
(),
code
:
$mc
.
val
(),
password
:
$pwd
.
val
()
}
}).
then
(
function
(
data
)
{
var
time
=
0
,
t
,
refer
;
if
(
data
.
code
===
200
)
{
refer
=
data
.
data
.
href
;
}
t
=
setTimeout
(
function
()
{
time
++
;
},
1000
);
$smsCaptchaCtrl
.
addClass
(
'disable'
);
$
.
ajax
({
type
:
'GET'
,
url
:
data
.
data
.
session
}).
then
(
function
(
res
)
{
disableSMSBtn
();
sendSMSCaptcha
();
});
if
(
res
.
code
===
200
&&
t
<
3
)
{
clearInterval
(
t
);
location
.
href
=
refer
;
}
});
// 点击注册提交
$registerBtn
.
on
(
'click'
,
function
()
{
if
(
$registerBtn
.
hasClass
(
'disable'
))
{
return
;
}
if
(
t
>=
3
)
{
clearInterval
(
t
);
location
.
href
=
refer
;
}
}
else
{
$registerBtn
.
addClass
(
'disable'
);
register
();
});
// todo
console
.
log
(
'网络超时~'
);
}
// 按回车键提交
$registerPage
.
on
(
'keypress'
,
function
(
e
)
{
var
key
=
e
.
which
;
});
if
(
key
===
13
)
{
$registerBtn
.
trigger
(
'click'
);
}
});
// 换图形验证码
$
(
'.change-captcha'
).
click
(
function
()
{
refresh
Pic
();
refresh
ImgCaptcha
();
});
// 注册成功页面5秒后跳转
// if ($('.success-box').length > 0) {
// clearT = setInterval(function() {
//
// if (countDown === 0) {
//
// window.location.href = $successBtn.attr('data-url');
//
// clearInterval(clearT);
// }
// $countDown.text(countDown--);
// }, 1000);
// }
// 初始化,同意服务条款
ep
.
emit
(
'agree'
,
true
);
};
...
...
public/scss/passport/_back.css
View file @
ed07cee
...
...
@@ -151,11 +151,13 @@
.send-captcha
{
width
:
$
input-button
;
height
:
$
item-height
;
font-size
:
12px
;
letter-spacing
:
0
;
background
:
$
theme-color
;
margin-left
:
20px
;
color
:
white
;
line-height
:
@
height
;
&.disable
{
background-color
:
$
inactive-color
;
...
...
Please
register
or
login
to post a comment