Authored by 毕凯

Merge branch 'feature/passport' of git.yoho.cn:fe/yohobuy-node into feature/passport

... ... @@ -77,8 +77,6 @@ const sendCodePage = (req, res, next) => {
service.sendCodeToUserAsync(inputInfo.type, inputInfo.phone, inputInfo.area)
.then(result => {
console.log(result);
if (!(result.code && result.code === 200)) {
return res.redirect(helpers.urlFormat('/passport/back/index'));
}
... ...
... ... @@ -4,10 +4,13 @@
'use strict';
const Captchapng = require('captchapng');
const _ = require('lodash');
const helpers = global.yoho.helpers;
const requiredAPI = (req, res, next) => {
let captchaToken = (req.body.verifyCode || '').toLowerCase();
let captchaToken = +(req.body.verifyCode || '').toLowerCase();
if (captchaToken === req.session.captcha) {
return next();
... ... @@ -20,16 +23,48 @@ const requiredAPI = (req, res, next) => {
};
const requiredPage = (req, res, next) => {
let captchaToken = (req.body.verifyCode || '').toLowerCase();
let captchaToken = +(req.body.verifyCode || '').toLowerCase();
if (captchaToken === req.session.captcha) {
return next();
} else {
return res.redirect(helpers.urlFormat('/passport/back/index.html'));
return res.redirect(helpers.urlFormat('/passport/back/index'));
}
};
const _generateCaptcha = (width, height, length) => {
let min = Math.pow(10, (length - 1 || 1));
let max = Math.pow(10, (length - 1 || 1)) * 9;
let token = '' + _.random(min, max);
let png = new Captchapng(width, height, token);//
png.color(0, 0, 0, 0); // First color: background (red, green, blue, alpha)
png.color(80, 80, 80, 255); // Second color: paint (red, green, blue, alpha)
return {
image: new Buffer(png.getBase64(), 'base64'),
text: token
};
};
const generate = (req, res) => {
let width = req.query.w || 150;
let height = req.query.h || 50;
let length = +(req.query.l || 4);
let captcha = _generateCaptcha(width, height, length);
req.session.captcha = captcha.text;
res.writeHead(200, {
'Content-Type': 'image/png'
});
res.end(captcha.image);
};
module.exports = {
requiredAPI,
requiredPage
requiredPage,
generate
};
... ...
... ... @@ -10,7 +10,7 @@ const express = require('express');
const cRoot = './controllers';
const login = require(cRoot + '/login');
// const captcha = require(cRoot + '/captcha');
const captcha = require(cRoot + '/captcha');
const back = require(cRoot + '/back');
const reg = require(cRoot + '/reg');
const bind = require(cRoot + '/bind');
... ... @@ -70,23 +70,20 @@ router.get('/back/index', back.index);
// 实时验证输入是否正确
router.post('/back/authcode',
// captcha.requiredAPI,
captcha.requiredAPI,
back.validateInputAPI,
back.getUserInfoAPI);
// 提交按钮邮件API
router.post('/back/email',
// captcha.requiredPage,
captcha.requiredPage,
back.validateUserPage,
back.sendCodePage,
back.saveInSession);
// 提交按钮手机API
router.post('/back/mobile',
// captcha.requiredPage,
captcha.requiredPage,
back.validateUserPage,
back.sendCodePage,
back.saveInSession);
... ... @@ -104,29 +101,26 @@ router.get('/back/sendEmail',
*/
// 验证手机短信页面
router.get('/back/verification',
captcha.requiredPage,
back.validateMobileInSession,
// captcha.requiredPage,
back.verifyCodeByMobilePage);
// 重新发送短信接口
router.post('/back/sendBackMobile',
// captcha.requiredAPI,
captcha.requiredAPI,
back.validateMobileAPI,
back.sendBackMobileAPI);
// 验证手机验证码接口
router.post('/back/backMobile',
// captcha.requiredAPI,
captcha.requiredAPI,
back.verifyCodeByMobileAPI);
/**
* 重置密码
*/
// 重置密码页面
// 重置密码页面
router.get('/back/backcode',
back.validateExistCodePage,
back.validateCodeByMobilePage,
... ... @@ -145,4 +139,6 @@ router.get('/back/resetSuccess',
back.validateSuccessStatusPage,
back.resetPwdSuccessPage);
router.get('/images', captcha.generate);
module.exports = router;
... ...
const seoMap = {
/* eslint-disable */
'/': {
title: 'YOHO!有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证',
title: 'YOHO!BUY有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证',
keywords: 'Yoho! 有货官网,潮流志,潮流男装,潮牌,美国潮牌,日本潮牌,香港潮牌,潮牌店,新品首发,欧美潮流,全球购,代购,时尚,流行,特卖,B2C,正品,购物网站,网上购物,货到付款',
description: 'YOHO! 有货,年轻人潮流购物中心,中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。作为YOHO!旗下的购物平台,汇集了全球潮流时尚商品和中国最流行的商品,也是国内最大的原创文化商品平台,也是香港,台湾地区流行商品的集中地。同时包含日本、韩国等众多国外潮流品牌,带给您全新潮流购物体验。'
description: 'YOHO!BUY 有货,年轻人潮流购物中心,中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。作为YOHO!旗下的购物平台,汇集了全球潮流时尚商品和中国最流行的商品,也是国内最大的原创文化商品平台,也是香港,台湾地区流行商品的集中地。同时包含日本、韩国等众多国外潮流品牌,带给您全新潮流购物体验。'
},
'/woman': {
title: '女生|时尚潮流女装,日韩女装,潮牌女装全球购|YOHO!BUY有货 100%正品保证',
... ... @@ -17,7 +17,7 @@ const seoMap = {
},
'/lifestyle': {
title: '创意生活|创意生活馆,潮流创意家居,家居生活用品|YOHO!BUY有货 100%正品保证',
keywords: '创意生活,创意生活馆,潮流家居,潮流创意家居,家居生活用品,YOHO!有货',
keywords: '创意生活,创意生活馆,潮流家居,潮流创意家居,家居生活用品,YOHO!BUY有货',
description: 'YOHO!BUY有货官网创意生活频道汇集了创意生活馆,潮流创意家居,家居生活用品等正品网购,给您的生活带来更多创意。YOHO!BUY有货购物100%正品保证,支持货到付款。'
}
/* eslint-enable */
... ...
... ... @@ -30,6 +30,8 @@ var thirdLineNum = 9,
var logoAngle = 0,
loopTime = 500;
var dataLayer = [];
// handlebars模板
centerFn = handlebars.compile($('#simple-account-info-tpl').html() || '');
loginFn = handlebars.compile($('#header-login-info-tpl').html() || '');
... ... @@ -44,6 +46,22 @@ handlebars.registerHelper('notzero', function(v1, options) {
}
});
function getSource(column, postition, event) {
try {
dataLayer.push({
louceng: column,
weizhi: postition,
event: event
});
} catch (e) {}
}
function closeCover() {
var $cover = $('#cover');
$cover.remove();
}
// 格式化三级菜单
function formatThirdMenu() {
$subNav.each(function() {
... ...