Authored by lore-w

注册逻辑修改

... ... @@ -35,8 +35,8 @@
<span class="pwd-intensity high">高</span>
</div>
<div id="pwd-tips" class="hide pwd-tips">
<div class="default" id="pwd-tip1">密码只支持6-20位字符</div>
<div class="default" id="pwd-tip2">建议由字母、 数字、 符号两种以上组合</div>
<div class="default" id="pwd-tip1"><i></i>密码只支持6-20位字符</div>
<div class="default" id="pwd-tip2"><i></i>建议由字母、 数字、 符号两种以上组合</div>
</div>
</li>
... ...
... ... @@ -4,11 +4,13 @@
*/
var $ = require('yoho.jquery'),
regValidate = require('./mail-phone-regx');
regValidate = require('./mail-phone-regx'),
computeComplex = require('./pwd-strength');
var $registerPage = $('.register-page'),
$pwdTips = $('#pwd-tips'),
$errTip = $('#err-tip');
$errTip = $('#err-tip'),
$registerBtn = $('#register-btn');
var $sendCaptcha = $('#send-captcha'),
caCount = 4,
... ... @@ -20,6 +22,10 @@ var $pn = $('#phone-num'),
$repwd = $('#repwd'),
$ca = $('#captcha');
// 密码强度验证
var $pwdIntensity = $('.pwd-intensity'),
$pwdParent = $pwdIntensity.closest('.pwd-intensity-container');
//signup验证
var $region = $('#country-code'),
$regionSelect = $('#region');
... ... @@ -293,20 +299,43 @@ function showBorder() {
$errInput = $('#' + validateResult[i].id);
$errInput.addClass('error');
} else {
//去掉红色边框
$errInput = $('#' + validateResult[i].id);
$errInput.removeClass('error');
}
}
}
// 失去焦点时开始校验
$registerPage.find('.va').focus(function() {
// Tips: 不可以在获得焦点的时候验证,获得焦点和失去焦点的间隔太小,如果中间存在ajax校验的话会出现问题
$registerPage.find('.va').keyup(function() {
// 去掉错误提示,当获得焦点的时候重置message信息
var index = $(this).parents('li').attr('data-index');
var j,
statusLen = 0,
vLen = validateResult.length;
validateRule($(this), function() {
showErrTip();
showBorder(); // 显示红色边框
validateResult[index].message = '';
for (j = 0; j < vLen; j++) {
showErrTip(); // 显示错误提示
if (validateResult[j].status) {
statusLen++;
}
}
if (statusLen === 4 && $('#agree-terms').is(':checked')) {
$registerBtn.removeClass('disable');
} else {
$registerBtn.addClass('disable');
}
});
}).blur(function() {
... ... @@ -338,4 +367,53 @@ $ca.keyup(function() {
} else {
$sendCaptcha.addClass('disable');
}
});
$pwd.keyup(function() {
var pwd = $(this).val(),
pwdStrength = computeComplex(pwd),
level = 0;
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;
}
//提示框
/*if (pwd === '') {
} else {
if (pwd.length < 6 || pwd.length > 20) {
} else {
}
}*/
});
\ No newline at end of file
... ...
... ... @@ -139,6 +139,8 @@
width: 270px;
text-align: right;
margin-top: 5px;
height: auto;
overflow: hidden;
.pwd-intensity {
height: 15px;
... ... @@ -166,7 +168,7 @@
&.green {
.color {
background: #0f0;
background: #3ee392;
color: #fff;
}
}
... ... @@ -184,6 +186,7 @@
width: 270px;
font-size: 20px;
font-weight: bold;
background: #ff1901;
&.disable {
background: #555;
... ... @@ -208,6 +211,18 @@
background-color: #ffebeb;
border: 1px solid #ffbdbe;
padding: 0 10px;
b {
display: block;
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 8px solid #ffebeb;
position: absolute;
top: 30px;
left: 20px;
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -55,7 +55,7 @@ class RegisterController extends AbstractAction
public function checkmobileAction()
{
$data = array(
'code' => 404
'code' => 200
);
$this -> echoJson($data);
... ... @@ -65,7 +65,7 @@ class RegisterController extends AbstractAction
public function piccaptchaAction()
{
$data = array(
'code' => 404
'code' => 200
);
$this -> echoJson($data);
... ... @@ -75,7 +75,7 @@ class RegisterController extends AbstractAction
public function msgcaptchaAction()
{
$data = array(
'code' => 404
'code' => 200
);
$this -> echoJson($data);
... ...