Authored by 陈轩

Merge branch 'feature/phone-login' into release/4.9.2

... ... @@ -9,6 +9,7 @@ const AuthHelper = require('../models/auth-helper');
// constrant
const CODE_REQUIRED = '请输入校验码';
const PASSWORD_REQUIRED = '请输入密码';
const PASSWORD_LENGTH_ERROR = '密码6-20位,请重新输入';
const BAD_PASSWORD = '密码格式不正确';
const TOO_MANY = '请求太频繁';
const LOGIN_SUCCSS = '登录成功';
... ... @@ -28,6 +29,7 @@ const _step1 = (req, res, next) => {
let viewData = {
module: 'passport',
page: 'sms-login',
backUrl: '/passport/login',
isPassportPage: true,
headerText: '手机号码快捷登录',
areaCode: '+86', // 默认的区号
... ... @@ -270,6 +272,11 @@ exports.password = (req, res, next) => {
return res.json(data);
}
if (password.length < 6 || password.length > 20) {
data.message = PASSWORD_LENGTH_ERROR;
return res.json(data);
}
if (!helpers.verifyPassword(password)) {
return res.json(data);
}
... ...
<div class="sms-login passport-page yoho-page">
<div class="sms-login sms-login-check passport-page yoho-page">
{{> passport/header}}
<div class="content">
<p class="sms-login-msg">验证码已发至&nbsp;<span class="tel">+{{area}} {{mobile}}</span></p>
<div class="input-container input-group sms-input row">
<input id="sms-code" class="input" type="text" placeholder="验证码">
<span class="input-addon">
<div class="input-addon">
<button type="button" id="resend-sms">重发验证码</button>
</span>
</div>
<button class="clear-input" type="button"></button>
</div>
<button id="btn-next" class="btn btn-next disable row" type="button">登录</button>
</div>
... ...
... ... @@ -3,8 +3,8 @@
<div class="content">
<p class="sms-login-msg small">你以后还可以使用手机号码 + 密码的形式登录有货哦!</p>
<div class="input-container row has-eye">
<input id="pwd" class="pwd input" type="password" placeholder="密码">
<div class="eye close" id="eye"></div>
<input id="pwd" class="pwd input" type="text" placeholder="密码">
<div class="eye" id="eye"></div>
</div>
<span id="btn-next" class="btn btn-next disable row">确定</span>
</div>
... ...
... ... @@ -3,6 +3,7 @@ var tip = require('plugin/tip');
var $resendBtn,
$nextBtn,
$smsCode,
$resetBtn,
mobile, area;
var page = {
... ... @@ -23,6 +24,7 @@ var page = {
domInit: function() {
$resendBtn = $('#resend-sms');
$nextBtn = $('#btn-next');
$resetBtn = $('.clear-input');
$smsCode = $('#sms-code');
mobile = $('#mobile').val();
area = $('#area').val();
... ... @@ -40,11 +42,18 @@ var page = {
var hasVal = Boolean($.trim(this.value));
$nextBtn.toggleClass('disable', !hasVal);
$nextBtn.prop('disabled', !hasVal);
$resetBtn.toggle(hasVal);
});
$nextBtn.on('click', function() {
!self.disableAjax && self.submit();
});
$resetBtn.on('click', function() {
$smsCode.val('');
$resetBtn.hide();
});
},
... ... @@ -104,13 +113,14 @@ var page = {
var self = this;
var code = $.trim($smsCode.val());
this.disableAjax = true;
$nextBtn.prop('disabled', this.disableAjax = true);
$.get('/passport/sms_login/check.json', {
code: code
})
.done(function(res) {
if (res.code === 200) {
location.href = res.redirect;
self.disableAjax = true; // 成功后 disabled, 执行跳转
return;
}
... ... @@ -118,9 +128,10 @@ var page = {
})
.fail(function() {
tip.show('出错了, 请重试');
self.disableAjax = false; // 失败后 允许再次 请求
})
.always(function() {
self.disableAjax = false;
$nextBtn.prop('disabled', self.disableAjax);
});
}
};
... ...
... ... @@ -10,4 +10,9 @@
display: table-cell;
vertical-align: middle;
}
.input-addon {
width: 1%;
overflow: hidden;
}
}
... ...
... ... @@ -138,7 +138,7 @@ body.passport-body {
background-color: #36a74c;
border-radius: 5PX;
color: #fff;
&.disable {
&.disable, &[disabled] {
background-color: #a2a2a2;
}
}
... ...
... ... @@ -4,14 +4,13 @@
}
#resend-sms {
display: block;
background-color: transparent;
width: 190px;
margin-right: 15px;
border: 1px solid #36a74c;
border-radius: 26px;
font-size: 20px;
line-height: 30px;
width: 148PX;
margin: 0 15PX 0 28PX;
border: 1PX solid #36a74c;
padding: 5PX 0;
border-radius: 20PX;
font-size: 16PX;
color: #36a74c;
}
... ... @@ -20,6 +19,12 @@
}
}
.sms-login-check {
.clear-input {
right: 175PX;
}
}
.sms-login-msg {
font-size: 28px;
color: #fff;
... ...