Authored by biao

Merge branch 'develop' into feature/index

/**
* index controller
* 专题活动 controller
* @author: bikai<kai.bi@yoho.cn>
* @date: 2016/05/16
*/
... ...
... ... @@ -15,7 +15,7 @@ var api = new ServiceAPI();
const getstaticFile = (id) => {
return api.get('staticFileManage/queryById', sign.apiSign({
id: id
})).then(result => {
}), true).then(result => {
if (result && result.code === 200) {
return result.data;
} else {
... ...
... ... @@ -15,7 +15,7 @@
<ul class="two-dim clearfix">
<li class="left">
{{#if devEnv}}
<img class="dim-img lazy" data-original="http://localhost:3000/img/layout/qr-app.png">
<img class="dim-img lazy" data-original="http://localhost:5002/img/layout/qr-app.png">
{{^}}
<img class="dim-img lazy" data-original="http://cdn.yoho.cn/yohobuy-node/assets/img/layout/qr-app.png">
{{/if}}
... ... @@ -23,7 +23,7 @@
</li>
<li class="left">
{{#if devEnv}}
<img class="dim-img lazy" data-original="http://localhost:3000/img/layout/qr-weixin.png">
<img class="dim-img lazy" data-original="http://localhost:5002/img/layout/qr-weixin.png">
{{^}}
<img class="dim-img lazy" data-original="http://cdn.yoho.cn/yohobuy-node/assets/img/layout/qr-weibo.png">
{{/if}}
... ... @@ -31,7 +31,7 @@
</li>
<li class="left">
{{#if devEnv}}
<img class="dim-img lazy" data-original="http://localhost:3000/img/layout/qr-weibo.png">
<img class="dim-img lazy" data-original="http://localhost:5002/img/layout/qr-weibo.png">
{{^}}
<img class="dim-img lazy" data-original="http://cdn.yoho.cn/yohobuy-node/assets/img/layout/qr-weixin.png">
{{/if}}
... ... @@ -139,7 +139,7 @@
<li>
<a href="http://www.yohomars.com/" target="_blank">
{{#if devEnv}}
<img class="lazy" data-original="http://localhost:3000/img/layout/mars.png">
<img class="lazy" data-original="http://localhost:5002/img/layout/mars.png">
{{^}}
<img class="lazy" data-original="http://cdn.yoho.cn/yohobuy-node/assets/img/layout/mars.png">
{{/if}}
... ... @@ -148,7 +148,7 @@
<li>
<a href="http://app.yohoshow.com/" target="_blank">
{{#if devEnv}}
<img class="lazy" data-original="http://localhost:3000/img/layout/show.png">
<img class="lazy" data-original="http://localhost:5002/img/layout/show.png">
{{^}}
<img class="lazy" data-original="http://cdn.yoho.cn/yohobuy-node/assets/img/layout/show.png">
{{/if}}
... ... @@ -157,7 +157,7 @@
<li>
<a href="http://www.yoho.cn/product#yoho" target="_blank">
{{#if devEnv}}
<img class="lazy" data-original="http://localhost:3000/img/layout/yoho.png">
<img class="lazy" data-original="http://localhost:5002/img/layout/yoho.png">
{{^}}
<img class="lazy" data-original="http://cdn.yoho.cn/yohobuy-node/assets/img/layout/yoho.png">
{{/if}}
... ... @@ -362,6 +362,6 @@
</div>
</div>
<div class="return-top hide">
<span class="iconfont">&#xe610;</span>
<span class="iconfont">&#xe607;</span>
</div>
</div>
... ...
... ... @@ -5,7 +5,6 @@
*/
'use strict';
const rp = require('request-promise');
const qs = require('querystring');
const md5 = require('md5');
... ... @@ -36,13 +35,13 @@ class Http {
* 调用接口
*/
_requestFromAPI(options, cacheOption, reqId) {
let timer = new Timer();
let method = options.method || 'get';
const timer = new Timer();
const method = options.method || 'get';
log.info(`${method} api: ${options.url}?${qs.stringify(options.qs)}`);
timer.put('getApi');// 统计时间开始
return rp(options).then((result) => {
let duration = timer.put('getApi');// 统计时间结束
const duration = timer.put('getApi');// 统计时间结束
// 数据校验
if (!result || !result.code) {
... ... @@ -55,7 +54,7 @@ class Http {
// 写缓存, 否则返回 Slave 缓存服务器的数据
if (config.useCache && cacheOption) {
let cacheTime = _.isNumber(cacheOption) ? cacheOption : 60;
const cacheTime = _.isNumber(cacheOption) ? cacheOption : 60;
reqId = reqId || this._getReqId(options);
cache.set(`apiCache:${reqId}`, result, cacheTime);
... ... @@ -65,7 +64,7 @@ class Http {
log.info(`get api success: use: ${duration}ms`);
return result;
}).catch((err)=> {
let duration = timer.put('getApi');// 统计时间结束
const duration = timer.put('getApi');// 统计时间结束
log.error(`${method} api fail: use: ${duration}ms, code:${err.statusCode}, error: ${err.message}`);
log.error(`API: ${options.url}?${qs.stringify(options.qs)}`);
... ... @@ -88,8 +87,8 @@ class Http {
* @return {[type]}
*/
_requestFromCache(options, slave) {
let reqId = this._getReqId(options);
let getCache = slave ? cache.getFromSlave : cache.get;
const reqId = this._getReqId(options);
const getCache = slave ? cache.getFromSlave : cache.get;
log.info(`get cache: ${reqId}, url: ${options.url}?${qs.stringify(options.qs)}`);
return getCache(`apiCache:${reqId}`).then((result) => {
... ... @@ -129,7 +128,7 @@ class Http {
* @return {[type]}
*/
get(url, data, cacheOption) {
let options = {
const options = {
url: `${this.ApiUrl}${url}`,
qs: data,
json: true,
... ... @@ -150,7 +149,7 @@ class Http {
* @param data Obejct
*/
post(url, data) {
let options = {
const options = {
url: `${this.ApiUrl}${url}`,
form: data,
method: 'post',
... ...
... ... @@ -4,7 +4,6 @@
* @author bikai kai.bi@yoho.cn
* @date 2016/05/16
*/
'use strict';
const Promise = require('bluebird');
const Memcached = require('memcached');
... ...
... ... @@ -4,9 +4,9 @@
* @return {[string]}
*/
exports.getUid = (req) => {
var _uid = 0,
cookie = req.cookies._UID,
cookieList;
const cookie = req.cookies._UID;
let _uid = 0;
let cookieList;
if (req.isApp) {
return req.query.uid || 0;
... ...
... ... @@ -49,10 +49,10 @@ exports.urlFormat = (uri, qs, module) => {
const subDomain = '.yohobuy.com';
const subName = {
default: config.siteUrl,
guang: '//guang' + subDomain,
list: '//list' + subDomain,
search: '//search' + subDomain,
huodong: '//huodong' + subDomain,
guang: `//guang${subDomain}`,
list: `//list${subDomain}`,
search: `//search${subDomain}`,
huodong: `//huodong${subDomain}`,
activity: '//activity.yohobuy.com',
index: config.siteUrl
};
... ... @@ -62,12 +62,12 @@ exports.urlFormat = (uri, qs, module) => {
if (subName[module]) {
url = subName[module];
} else {
url = '//' + module + subDomain; // 规则没匹配到就把模块当作子域名
url = `//${module}${subDomain}`; // 规则没匹配到就把模块当作子域名
}
url += uri;
if (qs) {
url += '?' + querystring.stringify(qs);
url += `?${querystring.stringify(qs)}`;
}
return url;
... ... @@ -106,7 +106,7 @@ exports.dateFormat = (format, date) => {
if (date instanceof Date) {
return moment(date).format(format);
} else {
let d = moment.unix(date);
const d = moment.unix(date);
return moment(d).utc().format(format);
}
... ... @@ -141,7 +141,7 @@ exports.dateDiffFormat = (format, diff, type) => {
return '';
} else {
type = type || 'ms';
let m = moment.duration(diff, type);
const m = moment.duration(diff, type);
format.match(/(\{.*?\})/g).forEach((s) => {
format = format.replace(s, m.get(s.substring(1, s.length - 1)));
... ...
/**
* 日志工具类
* @author: hbomb<qiqi.zhou@yoho.cn>
* @date: 2016/05/06
*/
'use strict';
'use strict';
let winston = require('winston'),
config = require('../config/common'),
FileTransport = require('winston-daily-rotate-file');
const winston = require('winston');
const config = require('../config/common');
const FileTransport = require('winston-daily-rotate-file');
require('influxdb-winston');
require('influxdb-winston');
let logger = new (winston.Logger)({
transports: [
new (FileTransport)(config.loggers.infoFile),
new (FileTransport)(config.loggers.errorFile),
new (winston.transports.UdpTransport)(config.loggers.udp),
new (winston.transports.Console)(config.loggers.console)
]
});
const logger = new (winston.Logger)({
transports: [
new (FileTransport)(config.loggers.infoFile),
new (FileTransport)(config.loggers.errorFile),
new (winston.transports.UdpTransport)(config.loggers.udp),
new (winston.transports.Console)(config.loggers.console)
]
});
module.exports = logger;
module.exports = logger;
... ...
... ... @@ -23,9 +23,9 @@ const privateKey = {
* @return {Object} 排序之后的参数对象
*/
const packageSort = argument => {
let newObj = {};
const newObj = {};
for (let k of Object.keys(argument).sort()) {
for (const k of Object.keys(argument).sort()) {
newObj[k] = argument[k];
}
... ... @@ -38,10 +38,10 @@ const packageSort = argument => {
* @return {string} 生成的签名字符串
*/
const makeSign = argument => {
let qs = [];
const qs = [];
_.forEach(argument, function(value, key) {
qs.push(key + '=' + _.trim(value));
_.forEach(argument, (value, key) => {
qs.push(`${key}=${_.trim(value)}`);
});
return md5(qs.join('&')).toLowerCase();
... ... @@ -71,8 +71,10 @@ exports.apiSign = (params) => {
// 检查签名,APP 访问 H5 页面的时候需要检查
exports.checkSign = (params) => {
let clientSecret = params.client_secret, // eslint-disable-line camelcase
sortedParams;
const // eslint-disable-line camelcase
clientSecret = params.client_secret;
let sortedParams;
// 忽略部分参数
delete params.client_secret;
... ...
'use strict';
/**
* 计时类
* @example
... ... @@ -10,7 +8,7 @@
* @author: hbomb<qiqi.zhou@yoho.cn>
* @date: 2016/05/07
*/
'use strict';
class Timer {
constructor() {
this.timers = {};
... ... @@ -20,10 +18,10 @@ class Timer {
* 打点计时
*/
put(label) {
let labelTime = this.timers[label];
const labelTime = this.timers[label];
if (labelTime) {
let duration = process.hrtime(labelTime);
const duration = process.hrtime(labelTime);
return this._round(duration[0], duration[1]);
} else {
... ...
No preview for this file type
... ... @@ -2,7 +2,7 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>
Created by FontForge 20120731 at Wed May 11 14:40:20 2016
Created by FontForge 20120731 at Mon May 23 22:22:36 2016
By admin
</metadata>
<defs>
... ... @@ -19,7 +19,7 @@ Created by FontForge 20120731 at Wed May 11 14:40:20 2016
bbox="0 -212 1158 896"
underline-thickness="50"
underline-position="-100"
unicode-range="U+0078-E606"
unicode-range="U+0078-E607"
/>
<missing-glyph horiz-adv-x="374"
d="M34 0v682h272v-682h-272zM68 34h204v614h-204v-614z" />
... ... @@ -54,5 +54,7 @@ t-22 15.5zM751 552v83h-473v-83h206v-298h-72v237h-87v-237h-66v-84h506v84h-193v119
d="M903 577l-68 69l-388 -388l-231 230l-68 -68l299 -298l65 65z" />
<glyph glyph-name="uniE606" unicode="&#xe606;"
d="M512 599q47 0 88 -18t72 -49t49 -72t18 -89q0 -46 -18 -87t-49 -72t-72 -49t-88 -18t-88 18t-72 49t-49 72t-18 87q0 48 18 89t49 72t72 49t88 18v0zM512 599z" />
<glyph glyph-name="uniE607" unicode="&#xe607;"
d="M797 219.5q0 -7.5 -5 -13.5l-29 -28q-6 -6 -13.5 -6t-12.5 6l-225 224l-224 -224q-6 -6 -13.5 -6t-13.5 6l-28 28q-6 6 -6 13.5t6 13.5l266 266q6 6 13.5 6t12.5 -6l267 -266q5 -6 5 -13.5z" />
</font>
</defs></svg>
... ...
No preview for this file type
No preview for this file type
... ... @@ -12,6 +12,7 @@ var $tool = $('.tool-wrapper'),
var $head = $('.head-wrapper'),
$searchForm = $('#search-form'),
$logotrans = $head.find('.main-logo'),
$searchSug = $head.find('.search-suggest'),
$goCart = $head.find('.go-cart'),
$goodsNum = $goCart.find('.goods-num-tip'),
... ... @@ -23,7 +24,11 @@ var thirdLineNum = 9,
delayer,
centerFn,
loginFn,
cartFn;
cartFn,
requestFrame;
var logoAngle = 0,
loopTime = 500;
// handlebars模板
centerFn = handlebars.compile($('#simple-account-info-tpl').html());
... ... @@ -185,6 +190,112 @@ function delCartGoods(data, callback) {
});
}
/**
* css3动画
* @return {[type]} [description]
*/
function requestFrameAct() {
var prefixList = ['webkit', 'moz', 'ms'];
var func1 = prefixList[0] + 'RequestAnimationFrame';
var func2 = prefixList[1] + 'RequestAnimationFrame';
var func3 = prefixList[2] + 'RequestAnimationFrame';
if (window[func1]) {
return function(callback) {
requestAnimationFrame(callback);
};
}
if (window[func2]) {
return function(callback) {
window[func2](callback);
};
}
if (window[func3]) {
return function(callback) {
window[func3](callback);
};
}
return function(callback) {
window.setTimeout(callback, 67);
};
}
/**
* css3动画
* @return {[type]} [description]
*/
function tsAnimate() {
logoAngle += 10;
$logotrans.css({
transform: 'rotateX(' + logoAngle + 'deg)',
'-webkit-transform': 'rotateX(' + logoAngle + 'deg)',
'-moz-transform': 'rotateX(' + logoAngle + 'deg)'
});
if (logoAngle / 90 % 2 === 1) {
$logotrans.toggleClass('logo-cn');
}
if (logoAngle / 90 % 2 === 0 && logoAngle % 360 !== 0) {
window.setTimeout(tsAnimate, 3000);
} else {
if (logoAngle % 360 === 0) {
window.setTimeout(tsAnimate, 1 * 60 * 1000);
} else {
requestFrame(function() {
tsAnimate();
});
}
}
}
/**
* 淡出
* @return {[type]} [description]
*/
function fadeAnimate() {
var cycle = 3000;
if ($logotrans.hasClass('logo-cn')) {
cycle = 1 * 60 * 1000;
}
$logotrans.fadeOut(loopTime, function() {
$logotrans.toggleClass('logo-cn');
$logotrans.fadeIn(loopTime, function() {
window.setTimeout(fadeAnimate, cycle);
});
});
}
/**
* 检测是否支持css3的动画
* @return {Boolean} [description]
*/
function isSupportCss3Animation() {
var thisFunc,
prefixList = ['webkit', 'moz', 'ms'],
i;
for (i = 0; i < prefixList.length; i++) {
thisFunc = prefixList[i] + 'RequestAnimationFrame';
if (window[thisFunc]) {
return true;
} else {
return false;
}
}
}
if (isSupportCss3Animation()) {
requestFrame = requestFrameAct();
window.setTimeout(tsAnimate, 3000);
} else {
window.setTimeout(fadeAnimate, 3000);
}
syncLoginInfo();
formatThirdMenu();
setInterval(syncCratInfo, 2000);
... ...
... ... @@ -323,6 +323,10 @@
}
}
.main-logo.logo-cn {
background: resolve('layout/logo-cn.png') no-repeat center center;
}
.func-area {
float: right;
width: 378px;
... ...
... ... @@ -20,7 +20,7 @@ test('uri format', t => {
let uri = '/test';
let qs = { name: 'yoho' };
let mod = 'list';
let expected = '//list.m.yohobuy.com/test?name=yoho';
let expected = '//list.yohobuy.com/test?name=yoho';
t.is(helpers.urlFormat(uri, qs, mod), expected);
});
... ...