Authored by 姜枫

handle merge

... ... @@ -35,7 +35,7 @@ passport.use(new LocalStrategy({
passReqToCallback: true
}, (req, username, password, done) => {
let area = req.body.area || '86';
let area = req.body.areaCode || '86';
if (isNaN(_.parseInt(area)) || _.isEmpty(username) || _.isEmpty(password)) {
logger.info(`【Passport Loginbad params, area:${area} account:${username} password:${password}`);
... ... @@ -43,7 +43,7 @@ passport.use(new LocalStrategy({
}
let verifyEmail = helpers.verifyEmail(username);
let verifyMobile = helpers.verifyAreaMobile(area + '-' + username, area);
let verifyMobile = area === '86' ? helpers.verifyAreaMobile(area + '-' + username) : true;
if (!verifyEmail && !verifyMobile) {
logger.info(`【Passport Loginbad account, email:${verifyEmail} mobile:${verifyMobile}`);
... ...
... ... @@ -90,23 +90,23 @@ const sendCodePage = (req, res, next) => {
const saveInSession = (req, res) => {
switch (req.inputInfo.type) {
case 'email':
{
req.session.email = req.inputInfo.phone;
res.redirect(helpers.urlFormat('/passport/back/sendEmail'));
break;
}
{
req.session.email = req.inputInfo.phone;
res.redirect(helpers.urlFormat('/passport/back/sendEmail'));
break;
}
case 'mobile':
{
req.session.mobile = req.inputInfo.phone;
req.session.area = req.inputInfo.area;
req.session.verifyCode = req.session.captcha;
res.redirect(helpers.urlFormat('/passport/back/verification'));
break;
}
{
req.session.mobile = req.inputInfo.phone;
req.session.area = req.inputInfo.area;
req.session.verifyCode = req.session.captcha;
res.redirect(helpers.urlFormat('/passport/back/verification'));
break;
}
default:
{
res.redirect(helpers.urlFormat('/passport/back/index'));
}
{
res.redirect(helpers.urlFormat('/passport/back/index'));
}
}
};
... ...
... ... @@ -30,22 +30,6 @@ let checkCode = (req, res, next) => {
};
/**
* 检查手机格式
*/
let checkMobileMiddleware = (req, res, next) => {
let mobile = +req.body.mobile;
let area = +req.body.area;
if (!_.isNumber(mobile) || !_.isNumber(area)) {
return res.json({
code: 400,
message: '手机号码格式不正确'
});
}
next();
};
/**
* 检查密码格式
*/
let checkPassword = (req, res, next) => {
... ... @@ -96,8 +80,8 @@ let checkMobile = (req, res, next) => {
let data = {
code: 400
};
let mobile = +req.body.mobile;
let area = +req.body.area;
let mobile = req.body.mobile;
let area = req.body.area;
// 判断手机号是否检查超过指定次数
let regCheckKey = 'regCheckMobileNum_' + passportHelper.makeAreaMobile(area, mobile);
... ... @@ -149,8 +133,8 @@ let sendBindMsg = (req, res, next) => {
data: ''
};
let mobile = +req.body.mobile;
let area = +req.body.area;
let mobile = req.body.mobile;
let area = req.body.area;
// 检查是否检查过
let checkNum = yield cache.get(`regCheckMobileNum_${passportHelper.makeAreaMobile(area, mobile)}`);
... ... @@ -193,9 +177,9 @@ let msgCaptcha = (req, res, next) => {
message: '',
data: ''
};
let area = +req.body.area;
let mobile = +req.body.mobile;
let code = +req.body.code; // 短信验证码
let area = req.body.area;
let mobile = req.body.mobile;
let code = req.body.code; // 短信验证码
regService.validMobileCode(area, mobile, code).then((result) => {
if (result.code) {
... ... @@ -243,9 +227,9 @@ let mobileRegister = (req, res, next) => {
yield cache.set(ipKey, ipTimes + 1, 3600);
let area = +req.body.area;
let mobile = +req.body.mobile;
let code = +req.body.code; // 短信验证码
let area = req.body.area;
let mobile = req.body.mobile;
let code = req.body.code; // 短信验证码
let password = req.body.password;
let result = yield regService.validMobileCode(area, mobile, code); // 验证注册的标识码是否有效
... ... @@ -295,7 +279,6 @@ let success = (req, res) => {
module.exports = {
checkCode,
checkMobileMiddleware,
checkPassword,
index,
success,
... ...
... ... @@ -64,11 +64,11 @@ router.post('/autouserinfo/relateMobile', bind.relateMobile);
* 注册页面路由
*/
router.get('/reg', reg.index);
router.post('/reg/checkmobile', reg.checkMobileMiddleware, reg.checkMobile);
router.post('/reg/checkmobile', reg.checkMobile);
router.post('/reg/piccaptcha', reg.checkCode, reg.picCaptcha);
router.post('/reg/msgcaptcha', reg.checkMobileMiddleware, reg.msgCaptcha);
router.post('/reg/sendBindMsg', reg.checkMobileMiddleware, reg.checkCode, reg.sendBindMsg);
router.post('/reg/mobileregister', reg.checkMobileMiddleware, reg.checkPassword, reg.checkCode, reg.mobileRegister);
router.post('/reg/msgcaptcha', reg.msgCaptcha);
router.post('/reg/sendBindMsg', reg.checkCode, reg.sendBindMsg);
router.post('/reg/mobileregister', reg.checkPassword, reg.checkCode, reg.mobileRegister);
router.get('/reg/success', reg.success);
/**
... ...
... ... @@ -10,7 +10,11 @@
</li>
<li>
<div id="name" class="title center">
<span>咸鸭蛋</span>
{{#if name}}
<span>{{name}}</span>
{{^}}
<span>咸鸭蛋</span>
{{/if}}
</div>
</li>
... ...
... ... @@ -93,6 +93,28 @@
<span>限购码已抢光</span>
{{/if}}
{{/ fashionTopGoods}}
{{#if soldOut}}
<span>
点击
<i class="arr-notice blue">到货通知</i>
,到货第一时间通知您
</span>
<script type="text/html" id="arrival-notice-tpl">
<h1>到货通知</h1>
<p>商品一旦在30日内到货,我们将会第一时间通知您,请及时关注哦!</p>
<div class="phone-num">手机号<input type="text" class="notice-phone"></div>
<p>
<span class="iconfont add-fav checked">&#xe602;</span>
添加到收藏夹
</p>
</script>
<script type="text/html" id="arrival-notice-success-tpl">
<h1>到货通知</h1>
<p>商品订阅到货通知成功!</p>
</script>
{{/if}}
</div>
<p class="btns">
{{#unless soldOut}}
... ...
... ... @@ -20,7 +20,7 @@
</div>
<div class="goods-list hide">
{{#each goodsList}}
<i data-url="{{url}}">{{image imagesUrl 265 344}}</i>
<i data-url="{{url}}">{{image imagesUrl 256 343}}</i>
{{/each}}
</div>
</div>
... ...
... ... @@ -39,6 +39,7 @@ var $errTip = $('.tips'),
$errMsg = $errTip.find('.rectangle');
require('yoho-jquery-placeholder');
require('../../plugins/tips');
function errTip(ele, msg) {
var topLeft = ele.offset();
... ...
... ... @@ -7,7 +7,7 @@ var jQuery = require('yoho-jquery'),
((function($) {
var tpl = '<div class="tips">' +
var tpl = '<div class="tips hide">' +
'<div class="triangle"></div>' +
'<div class="rectangle"> {{content}}</div>' +
'</div>';
... ... @@ -19,6 +19,8 @@ var jQuery = require('yoho-jquery'),
var methods = {
show: function() {
var topLeft = this.offset();
if (_that.isInit) {
$tips = this.find('.tips');
this.find('.rectangle').text(arguments[0]);
... ... @@ -26,14 +28,23 @@ var jQuery = require('yoho-jquery'),
_that.isInit = true;
this.append(tplFn({content: arguments[0]}));
$tips = this.find('.tips');
$tips.css('top', this.height() - 2);
$tips.css({
top: topLeft.top + this.height() - 2,
left: topLeft.left,
width: this.width() + 2,
height: this.height
});
}
return this.removeClass('hide');
},
hide: function() {
if (_that.isInit) {
this.find('.tips').remove();
this.find('.tips').addClass('hide');
_that.isInit = false;
}
return this;
},
status: function() {
return _that.isInit;
... ...
... ... @@ -4,7 +4,10 @@
* @date: 2016/7/15
*/
var $ = require('yoho-jquery'),
lazyload = require('yoho-jquery-lazyload');
handlebars = require('yoho-handlebars'),
lazyload = require('yoho-jquery-lazyload'),
Dialog = require('../plugins/dialog').Dialog,
regx = require('../passport/common/mail-phone-regx').phoneRegx;
var $main = $('.product-main'),
$mainThumb = $('#main-thumb'),
... ... @@ -26,6 +29,9 @@ var $thumbCur = $('.thumb-wrap .cur'); // 当前选中展示图片
var SLIDETIME = 200;
var noticeFn = handlebars.compile($('#arrival-notice-tpl').html() || ''),
noticeSuccFn = handlebars.compile($('#arrival-notice-success-tpl').html() || '');
var thumbsLoaded = [],
id = $main.data('id');
... ... @@ -94,6 +100,34 @@ function chooseColor(index) {
$sizeText.text('');
}
function arrivalNotice() {
// $.ajax({
// type: 'POST',
// url: '/shopping/cart/add',
// data: {
// productSku: sku,
// buyNumber: 1
// }
// }).then(function(data) {
// if (data.code === 200) {
// }
// });
var tip = new Dialog({
className: 'arr-notice-dialog',
content: noticeSuccFn(),
btns: [
{
id: 'sure',
btnClass: ['sure'],
name: '确定',
cb: function() {
tip.close();
}
}
]
}).show();
}
// 缩略图垂直居中
$thumbWrap.each(function() {
var $this = $(this),
... ... @@ -161,6 +195,40 @@ $('.size-list').on('click', 'li', function() {
}
});
// 到货通知
$('.arr-notice').click(function() {
var tip = new Dialog({
className: 'arr-notice-dialog',
content: noticeFn({}),
btns: [
{
id: 'apply',
btnClass: ['apply'],
name: '订阅',
cb: function() {
var dom = tip.$el.find('.notice-phone'),
num = dom.val ? dom.val() : '';
if (regx['+86'].test(num)) {
arrivalNotice(num);
tip.close();
} else {
dom.addClass('err');
}
}
},
{
id: 'cancel',
btnClass: ['cancel'],
name: '取消',
cb: function() {
tip.close();
}
}
]
}).show();
});
// 加入购物袋
$addToBag.click(function() {
var sku = getBuyProduct();
... ...
... ... @@ -443,4 +443,52 @@
}
}
}
+ .arr-notice-dialog {
.content {
width: 260px;
text-align: center;
margin: 0 auto;
}
}
}
.arr-notice-dialog {
.content {
width: 280px;
text-align: center;
margin: 0 auto;
line-height: 1.5;
font-size: 14px;
h1 {
font-size: 20px;
font-weight: bold;
padding-bottom: 30px;
}
}
.phone-num {
text-align: left;
padding: 12px 0;
input {
width: 210px;
height: 30px;
border: 1px solid #eee;
margin-left: 20px;
padding: 0 20px;
}
.err {
border-color: #f00;
}
}
.add-fav {
font-size: 14px;
cursor: pointer;
margin-right: 4px;
}
}
... ...