Toggle navigation
Toggle navigation
This project
Loading...
Sign in
wangshusheng
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to dashboard
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
lore-w
9 years ago
Commit
94b7301a2be1d7318942e4dae057e1085ea71588
1 parent
1a88f8ee
完善信息页面逻辑 code review by liuyue
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
182 additions
and
112 deletions
template/www.yohobuy.com/partials/layout/use.phtml
web-static/js/passport/reg.js
yohobuy/www.yohobuy.com/application/modules/Passport/controllers/Autouserinfo.php
template/www.yohobuy.com/partials/layout/use.phtml
View file @
94b7301
...
...
@@ -78,10 +78,21 @@
{{!-- 注册页--}}
{{#if registerPage}}
<script>
seajs.use('js/passport/reg');
seajs.use('js/passport/reg', function (reg) {
reg.init('reg');
});
</script>
{{/if}}
{{!-- 第三方登录完善信息页--}}
{{#if thirdPage}}
<script>
seajs.use('js/passport/reg', function (reg) {
reg.init('third');
});
</script>
{{/if}}
{{!-- 找回密码--}}
{{#if backPage}}
<script>
...
...
web-static/js/passport/reg.js
View file @
94b7301
...
...
@@ -83,14 +83,30 @@ validateResult = [
];
//手机号ajax校验
function
phoneAjaxFn
(
callback
)
{
$
.
ajax
({
url
:
'/passport/register/checkmobile'
,
type
:
'POST'
,
data
:
{
function
phoneAjaxFn
(
page
,
callback
)
{
var
url
,
data
;
if
(
page
===
'reg'
)
{
url
=
'/passport/register/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
:
1
,
sourceType
:
'QQ'
};
}
$
.
ajax
({
url
:
url
,
type
:
'POST'
,
data
:
data
}).
then
(
function
(
data
)
{
switch
(
data
.
code
)
{
case
200
:
...
...
@@ -108,10 +124,17 @@ function phoneAjaxFn(callback) {
}
//图形验证码ajax校验
function
picCaptchaAjaxFn
(
callback
)
{
function
picCaptchaAjaxFn
(
page
,
callback
)
{
var
url
;
if
(
page
===
'reg'
)
{
url
=
'/passport/register/piccaptcha'
;
}
else
if
(
page
===
'third'
)
{
url
=
'/passport/autouserinfo/checkPicCode'
;
}
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/register/piccaptcha'
,
url
:
url
,
data
:
{
code
:
$ca
.
val
(),
mobile
:
$pn
.
val
(),
...
...
@@ -123,7 +146,7 @@ function picCaptchaAjaxFn(callback) {
validateResult
[
1
].
message
=
''
;
validateResult
[
1
].
status
=
true
;
break
;
case
40
4
:
case
40
0
:
validateResult
[
1
].
message
=
'图形验证码错误'
;
validateResult
[
1
].
status
=
false
;
break
;
...
...
@@ -133,10 +156,17 @@ function picCaptchaAjaxFn(callback) {
}
//短信验证码ajax校验
function
msgCaptchaAjaxFn
(
callback
)
{
function
msgCaptchaAjaxFn
(
page
,
callback
)
{
var
url
;
if
(
page
===
'reg'
)
{
url
=
'/passport/register/msgcaptcha'
;
}
else
if
(
page
===
'third'
)
{
url
=
'/passport/autouserinfo/checkBindMsg'
;
}
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/register/msgcaptcha'
,
url
:
url
,
data
:
{
code
:
$ca
.
val
(),
mobile
:
$pn
.
val
(),
...
...
@@ -148,7 +178,7 @@ function msgCaptchaAjaxFn(callback) {
validateResult
[
2
].
message
=
''
;
validateResult
[
2
].
status
=
true
;
break
;
case
40
4
:
case
40
0
:
validateResult
[
2
].
message
=
'短信验证码错误'
;
validateResult
[
2
].
status
=
false
;
break
;
...
...
@@ -159,7 +189,7 @@ function msgCaptchaAjaxFn(callback) {
}
// 验证
function
validateRule
(
$element
,
callback
)
{
function
validateRule
(
page
,
$element
,
callback
)
{
var
val
=
$
.
trim
(
$element
.
val
()),
regionCode
;
...
...
@@ -181,7 +211,7 @@ function validateRule($element, callback) {
callback
();
}
else
{
phoneAjaxFn
(
callback
);
phoneAjaxFn
(
page
,
callback
);
}
//图形验证码校验
...
...
@@ -200,7 +230,7 @@ function validateRule($element, callback) {
// 并且手机号正确
if
(
validateResult
[
0
].
status
)
{
picCaptchaAjaxFn
(
callback
);
picCaptchaAjaxFn
(
page
,
callback
);
}
else
{
validateResult
[
1
].
message
=
'图形验证码错误'
;
validateResult
[
1
].
status
=
false
;
...
...
@@ -226,7 +256,7 @@ function validateRule($element, callback) {
// 并且图形验证码正确
if
(
validateResult
[
1
].
status
)
{
msgCaptchaAjaxFn
(
callback
);
msgCaptchaAjaxFn
(
page
,
callback
);
}
else
{
validateResult
[
2
].
message
=
'短信验证码错误'
;
validateResult
[
2
].
status
=
false
;
...
...
@@ -379,140 +409,169 @@ function pwdFn($obj) {
// 失去焦点时开始校验
// Tips: 不可以在获得焦点的时候验证,获得焦点和失去焦点的间隔太小,如果中间存在ajax校验的话会出现问题
$registerPage
.
find
(
'.va'
).
keyup
(
function
()
{
// ( ▼-▼ )注册页和信息完善页面接口不同
exports
.
init
=
function
(
page
)
{
$registerPage
.
find
(
'.va'
).
keyup
(
function
()
{
var
j
,
statusLen
=
0
,
vLen
=
validateResult
.
length
,
$that
=
$
(
this
);
var
j
,
statusLen
=
0
,
vLen
=
validateResult
.
length
,
$that
=
$
(
this
);
validateRule
(
$
(
this
),
function
()
{
showErrTip
();
// 显示错误提示
showBorder
();
// 显示红色边框
validateRule
(
page
,
$
(
this
),
function
()
{
showErrTip
();
// 显示错误提示
showBorder
();
// 显示红色边框
// 如果validateResult中有4个status为true表示验证通过
for
(
j
=
0
;
j
<
vLen
;
j
++
)
{
// 如果validateResult中有4个status为true表示验证通过
for
(
j
=
0
;
j
<
vLen
;
j
++
)
{
if
(
validateResult
[
j
].
status
)
{
if
(
validateResult
[
j
].
status
)
{
statusLen
++
;
}
}
statusLen
++
;
}
if
(
statusLen
===
4
&&
$
(
'#agree-terms'
).
is
(
':checked'
))
{
$registerBtn
.
removeClass
(
'disable'
).
removeAttr
(
'disabled'
);
}
else
{
$registerBtn
.
addClass
(
'disable'
).
attr
(
'disabled'
,
'true'
);
}
}
// 图形验证通过时,发送短信按钮可点击
if
(
validateResult
[
1
].
status
)
{
$sendCaptcha
.
removeClass
(
'disable'
);
}
else
{
$sendCaptcha
.
addClass
(
'disable'
);
}
if
(
statusLen
===
4
&&
$
(
'#agree-terms'
).
is
(
':checked'
))
{
$registerBtn
.
removeClass
(
'disable'
).
removeAttr
(
'disabled'
);
}
else
{
$registerBtn
.
addClass
(
'disable'
).
attr
(
'disabled'
,
'true'
);
}
//图形验证通过时,发送短信按钮可点击 end
// 图形验证通过时,发送短信按钮可点击
if
(
validateResult
[
1
].
status
)
{
$sendCaptcha
.
removeClass
(
'disable'
);
}
else
{
$sendCaptcha
.
addClass
(
'disable'
);
}
});
//图形验证通过时,发送短信按钮可点击 end
// 如果是密码则校验强度
if
((
$that
).
hasClass
(
'pwd'
))
{
pwdFn
(
$that
);
}
}).
blur
(
function
()
{
});
/*validateRule($(this), function() {
showErrTip();
showBorder(); // 显示红色边框
});*/
});
// 如果是密码则校验强度
if
((
$that
).
hasClass
(
'pwd'
))
{
pwdFn
(
$that
);
}
$regionSelect
.
change
(
function
()
{
}).
blur
(
function
()
{
$region
.
text
(
'+'
+
$
(
'#region'
).
val
());
/*validateRule($(this), function() {
showErrTip();
showBorder(); // 显示红色边框
});*/
});
validateRule
(
$pn
,
showErrTip
);
//验证
});
$regionSelect
.
change
(
function
()
{
// 点击发送验证码
$sendCaptcha
.
click
(
function
()
{
var
timeResidue
=
10
,
t
;
$region
.
text
(
'+'
+
$
(
'#region'
).
val
());
if
(
$
(
this
).
hasClass
(
'disable'
))
{
return
;
}
validateRule
(
page
,
$pn
,
showErrTip
);
//验证
});
//todo ajax
// 点击发送验证码
$sendCaptcha
.
click
(
function
()
{
var
timeResidue
=
20
,
t
,
url
;
t
=
setInterval
(
function
()
{
if
(
timeResidue
<=
0
)
{
$sendCaptcha
.
removeClass
(
'disable'
).
val
(
'获取短信验证码'
);
clearInterval
(
t
);
if
(
$
(
this
).
hasClass
(
'disable'
))
{
return
;
}
$sendCaptcha
.
addClass
(
'disable'
).
val
(
timeResidue
--
+
'秒可重新发送'
);
},
1000
);
});
//form表单提交
$registerBtn
.
click
(
function
()
{
if
(
$
(
this
).
hasClass
(
'disable'
))
{
return
;
}
else
{
if
(
page
===
'reg'
)
{
url
=
'/passport/register/sendBindMsg'
;
}
else
if
(
page
===
'third'
)
{
url
=
'/passport/autouserinfo/sendBindMsg'
;
}
//
ajax提交
//
todo ajax 发送验证码
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/register/mobileregister'
,
url
:
url
,
data
:
{
area
:
$region
.
text
().
split
(
'+'
)[
1
],
mobile
:
$pn
.
val
(),
captcha
:
$ca
.
val
(),
code
:
$mc
.
val
(),
password
:
$pwd
.
val
()
code
:
$ca
.
val
()
}
}).
then
(
function
(
data
)
{
if
(
data
.
code
===
200
)
{
t
=
setInterval
(
function
()
{
if
(
timeResidue
<=
0
)
{
$sendCaptcha
.
removeClass
(
'disable'
).
val
(
'获取短信验证码'
);
clearInterval
(
t
);
return
;
}
$sendCaptcha
.
addClass
(
'disable'
).
val
(
timeResidue
--
+
'秒可重新发送'
);
},
1000
);
}
});
});
var
time
=
0
,
t
,
refer
=
data
.
href
;
//ajax表单提交
$registerBtn
.
click
(
function
()
{
t
=
setTimeout
(
function
()
{
time
++
;
},
1000
);
var
url
;
if
(
page
===
'reg'
)
{
url
=
'/passport/register/mobileregister'
;
}
else
if
(
page
===
'third'
)
{
url
=
'/passport/autouserinfo/bindMobile'
;
}
if
(
$
(
this
).
hasClass
(
'disable'
))
{
return
;
}
else
{
//ajax提交
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/register/mobileregister'
,
url
:
url
,
data
:
{
session
:
data
.
session
area
:
$region
.
text
().
split
(
'+'
)[
1
],
mobile
:
$pn
.
val
(),
captcha
:
$ca
.
val
(),
code
:
$mc
.
val
(),
password
:
$pwd
.
val
()
}
}).
then
(
function
(
data
)
{
if
(
data
.
code
===
200
&&
t
<
3
)
{
var
time
=
0
,
t
,
refer
=
data
.
href
;
t
=
setTimeout
(
function
()
{
time
++
;
},
1000
);
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/register/mobileregister'
,
data
:
{
session
:
data
.
session
}
}).
then
(
function
(
data
)
{
if
(
data
.
code
===
200
&&
t
<
3
)
{
clearInterval
(
t
);
location
.
href
=
refer
;
}
});
if
(
t
>=
3
)
{
clearInterval
(
t
);
location
.
href
=
refer
;
}
});
if
(
t
>=
3
)
{
clearInterval
(
t
);
location
.
href
=
refer
;
}
});
}
});
});
}
});
$
(
'.change-captcha'
).
click
(
function
()
{
var
time
=
new
Date
(),
$captchaImg
=
$
(
'.captcha-img'
),
captchaImgSrc
=
$captchaImg
.
attr
(
'src'
).
split
(
'?'
)[
0
];
$
(
'.change-captcha'
).
click
(
function
()
{
var
time
=
new
Date
(),
$captchaImg
=
$
(
'.captcha-img'
),
captchaImgSrc
=
$captchaImg
.
attr
(
'src'
).
split
(
'?'
)[
0
];
$captchaImg
.
attr
(
'src'
,
captchaImgSrc
+
'?t='
+
time
.
getTime
());
});
\ No newline at end of file
$captchaImg
.
attr
(
'src'
,
captchaImgSrc
+
'?t='
+
time
.
getTime
());
});
};
\ No newline at end of file
...
...
yohobuy/www.yohobuy.com/application/modules/Passport/controllers/Autouserinfo.php
View file @
94b7301
...
...
@@ -44,13 +44,13 @@ class AutouserinfoController extends AbstractAction
//整合
$data
=
array
(
'
register
Page'
=>
true
,
'
third
Page'
=>
true
,
'simpleHeader'
=>
$simpleHeader
,
'passport'
=>
array
(
'actionUrl'
=>
Helpers
::
url
(
'/autouserinfo/bind'
),
'region'
=>
RegData
::
getAreasData
(),
'location'
=>
'+86'
,
'captchaUrl'
=>
Helpers
::
url
(
'/passport/images?t='
.
time
())
,
'captchaUrl'
=>
'/passport/images?t=1449799445'
,
'itemUrl'
=>
Helpers
::
url
(
'/help/?category_id=9'
),
'referUrl'
=>
$refer
,
'skipUrl'
=>
SITE_MAIN
,
...
...
Please
register
or
login
to post a comment