Authored by 徐祁xuqi

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

... ... @@ -48,7 +48,7 @@
{{/each}}
</div>
</div>
<div class="brands-list" >
<div class="brands-list" data-ishover="{{@root.pc.brands.disBrandNameHover}}">
{{> brand-list}}
</div>
{{/ brands}}
... ...
... ... @@ -26,13 +26,15 @@ exports.index = (req, res, next) => {
let uid = req.user.uid;
let udid = ghelper.getUdid(req, res);
let gender = ghelper.getGenderByCookie(req);
let isHotDegrade = _.get(req.app.locals.pc, 'guang.removeHotTag', false);
let isAdDegrade = _.get(req.app.locals.pc, 'guang.removeAd', false);
Promise.all([
guangModel.getBanner(channel),
guangModel.getCategory(type, channel),
guangModel.getArticleList(gender, type, uid, udid, page, '', '', pageSize, channel, true),
guangModel.getHotTags(page, pageSize, channel),
guangModel.getAds(channel),
guangModel.getHotTags(page, pageSize, channel, isHotDegrade),
guangModel.getAds(channel, isAdDegrade),
guangModel.getRecoArticles(gender, 1, 10, channel),
headerModel.requestHeaderData(channel)
]).then(ret => {
... ... @@ -77,13 +79,15 @@ exports.tags = (req, res, next) => {
let gender = ghelper.getGenderByCookie(req);
let channel = req.yoho.channel;
let pathNav = guangModel.getPathNav(channel, query);
let isHotDegrade = _.get(req.app.locals.pc, 'guang.removeHotTag', false);
let isAdDegrade = _.get(req.app.locals.pc, 'guang.removeAd', false);
Promise.all([
guangModel.getBanner(channel),
guangModel.getArticleList(gender, 0, uid, udid, page, query, '', pageSize, channel, true),
guangModel.getHotTags(1, 20, channel),
guangModel.getAds(channel),
guangModel.getHotTags(1, 20, channel, isHotDegrade),
guangModel.getAds(channel, isAdDegrade),
guangModel.getRecoArticles(gender, 1, 10, channel),
headerModel.requestHeaderData(channel)
]).then(ret => {
... ... @@ -121,6 +125,8 @@ exports.editor = (req, res, next) => {
let authorId = req.query.author_id;
let channel = req.yoho.channel;
let gender = ghelper.getGenderByCookie(req);
let isHotDegrade = _.get(req.app.locals.pc, 'guang.removeHotTag', false);
let isAdDegrade = _.get(req.app.locals.pc, 'guang.removeAd', false);
let uid = req.user.uid;
let udid = ghelper.getUdid(req, res);
... ... @@ -133,8 +139,8 @@ exports.editor = (req, res, next) => {
Promise.all([
guangModel.getAuthor(authorId),
guangModel.getArticleList(gender, null, uid, udid, page, '', authorId, pageSize, channel, true),
guangModel.getHotTags(1, 20, channel),
guangModel.getAds(channel),
guangModel.getHotTags(1, 20, channel, isHotDegrade),
guangModel.getAds(channel, isAdDegrade),
guangModel.getRecoArticles(gender, 1, 10, channel),
headerModel.requestHeaderData(channel)
]).then(ret => {
... ... @@ -175,6 +181,8 @@ exports.detail = (req, res, next) => {
let udid = ghelper.getUdid(req, res);
let gender = ghelper.getGenderByCookie(req);
let channel = req.yoho.channel;
let isHotDegrade = _.get(req.app.locals.pc, 'guang.removeHotTag', false);
let isAdDegrade = _.get(req.app.locals.pc, 'guang.removeAd', false);
if (!_.isNumber(id)) {
id = parseInt(id);
... ... @@ -212,12 +220,12 @@ exports.detail = (req, res, next) => {
let promises = [
headerModel.requestHeaderData(channel),
guangModel.getArticleContent(id),
guangModel.getHotTags(1, 20, channel),
guangModel.getHotTags(1, 20, channel, isHotDegrade),
guangModel.getArticleComments(id, page, pageSize),
guangModel.getArticleBaseInfo(id, uid, udid),
guangModel.getArticleRelateBrand(id),
guangModel.getRecoArticles(gender, 1, 10, channel),
guangModel.getAds(channel)
guangModel.getAds(channel, isAdDegrade)
];
if (info.authorId) {
... ...
... ... @@ -305,7 +305,7 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, c
* @param {String} type 传入频道页类型,值可以是: boys, girls, kids, lifestyle
* @return {Object}
*/
const getHotTags = (page, limit, channel) => {
const getHotTags = (page, limit, channel, isDegrade) => {
let data = {
client_type: 'web',
... ... @@ -313,6 +313,10 @@ const getHotTags = (page, limit, channel) => {
limit: limit || 10
};
if (isDegrade) {
return null;
}
return serviceApi.get('guang/api/v2/article/getTagTop', data, {
cache: true
}).then(res => {
... ... @@ -338,10 +342,14 @@ const getHotTags = (page, limit, channel) => {
* @param {String} channelType 传入频道页类型,值可以是: boys, girls, kids, lifestyle
* @return {Object}
*/
const getAds = channelType => {
const getAds = (channelType, isDegrade) => {
let contentCode = ADS_CODE[channelType] || ADS_CODE.boys;
if (isDegrade) {
return null;
}
return serviceApi.get(URL_OPERATIONS_RESOURCE_GET, {
content_code: contentCode
}, {cache: true}).then(res => {
... ...
... ... @@ -130,6 +130,7 @@
</div>
{{/if}}
{{#unless @root.pc.guang.removeItemComment}}
<div id="comment-area" class="comment-area">
<div class="comment-textarea">
<textarea id="comment-info" placeholder="我有话要说。。。">{{commentInfo}}</textarea>
... ... @@ -142,6 +143,7 @@
{{> comment}}
</div>
</div>
{{/unless}}
</div>
<div class="right-side detail-side">
{{> right-side}}
... ...
... ... @@ -14,7 +14,8 @@
</div>
</div>
<div class="hot">
{{#unless @root.pc.guang.removeHotTag}}
<div class="hot">
<h1 class="hot-title">热门标签</h1>
<div class="hot-tag-list">
{{#hotTags}}
... ... @@ -23,7 +24,8 @@
</a>
{{/hotTags}}
</div>
</div>
</div>
{{/unless}}
<div class="ads">
{{# ads}}
... ...
... ... @@ -658,6 +658,7 @@
<div class="service"></div>
{{#unless @root.pc.product.removeRecentView}}
{{#if latestWalk}}
<div class="info-block latest-walk">
<input id="latest-walk-count" type="hidden" value="{{latestWalk}}">
... ... @@ -668,6 +669,7 @@
{{> product/latest-walk-tpl}}
</div>
{{/if}}
{{/unless}}
</div>
</div>
{{/ detail}}
... ...
... ... @@ -26,7 +26,9 @@
<span class="tag-seprate"></span>
<a href="//www.yohobuy.com/home?t=1453340799.4986">MY有货</a>
<span class="icon-bottomarrow"></span>
{{#unless @root.pc.common.disMyYohoHover}}
<div class="simple-user-center"></div>
{{/unless}}
</li>
<li class="myorder">
<span class="tag-seprate"></span>
... ... @@ -66,7 +68,8 @@
<div class="main-logo"><a href="//www.yohobuy.com/" class="main-link"></a></div>
<ul class="main-nav-list">
{{# navbars}}
<li class="{{type}}"{{#if ico}} style="background: url({{image ico 54 32}}) no-repeat center center"{{/if}}>
<li class="{{type}}"{{#if ico}}
style="background: url({{image ico 54 32}}) no-repeat center center"{{/if}}>
{{#if ico}}
<a href="{{link}}"{{#if isNewPage}} target="_blank"{{/if}} class="menu-ico"></a>
{{^}}
... ... @@ -81,19 +84,28 @@
{{/ navbars}}
</ul>
<div class="func-area hide">
{{#unless @root.pc.common.disSearchAssociation}}
<ul class="search-suggest"></ul>
{{/unless}}
<div class="search-2016">
<form action="//search.yohobuy.com" method="get" id="search-form">
<input type="hidden" id="defaultsearch">
<input class="search-key" type="text" name="query" id="query-key" autocomplete="off" x-webkit-speech="" lang="zh-CN" x-webkit-grammar="builtin:translate" value="" onfocus="if(this.value==this.defaultValue){this.value='';this.style.color='#333'}" onblur="if(this.value==''){this.value=this.defaultValue;this.style.color='#999'}" maxlength="30">
<input class="search-key" type="text" name="query" id="query-key" autocomplete="off"
x-webkit-speech="" lang="zh-CN" x-webkit-grammar="builtin:translate" value=""
onfocus="if(this.value==this.defaultValue){this.value='';this.style.color='#333'}"
onblur="if(this.value==''){this.value=this.defaultValue;this.style.color='#999'}"
maxlength="30">
<a class="search-btn" href="javascript:submitSearch();"></a>
</form>
</div>
<div class="go-cart">
<a href="//www.yohobuy.com/shopping/cart">
<span class="iconfont ">&#xe600;</span>
{{#unless @root.pc.common.removeCartCount}}
<span class="goods-num-tip">0</span>
{{/unless}}
</a>
{{#unless @root.pc.common.disCartHover}}
<div class="mini-cart-wrapper">
<div class="loading-cart">
<h3>加载中,请稍后</h3>
... ... @@ -102,6 +114,7 @@
<h3>您的购物车暂无商品</h3>
</div>
</div>
{{/unless}}
</div>
</div>
</div>
... ... @@ -123,11 +136,12 @@
<dl class="hide-list hide">
{{# thirdNav}}
<dt>
<h1 class=""><a href="{{link}}">{{title}}</a> </h1>
<h1 class=""><a href="{{link}}">{{title}}</a></h1>
</dt>
{{#brandItems}}
<dd>
<a href="{{link}}"{{#if hot}} class="hot"{{/if}}>{{brandName}}</a>
<a href="{{link}}"{{#if hot}}
class="hot"{{/if}}>{{brandName}}</a>
</dd>
{{/brandItems}}
{{/thirdNav}}
... ... @@ -153,7 +167,7 @@
</script>
<script type="text/html" id="simple-account-info-tpl">
<div class="account-info-header">
<div class="user-img" >
<div class="user-img">
<img src="\{{headIco}}">
</div>
<div class="user-name">
... ... @@ -224,7 +238,9 @@
<div class="goods-price">
<p>\{{show_price}} x \{{buy_number}}</p>
<p>
<a href="javascript:void(0)" class="cart-goods-del" data-id="\{{goods_incart_id}}" data-cheapest="\{{is_cheapest_free}}" data-sku="\{{product_sku}}" data-proid="\{{promotion_id}}" data-num="\{{buy_number}}">删除</a>
<a href="javascript:void(0)" class="cart-goods-del" data-id="\{{goods_incart_id}}"
data-cheapest="\{{is_cheapest_free}}" data-sku="\{{product_sku}}"
data-proid="\{{promotion_id}}" data-num="\{{buy_number}}">删除</a>
</p>
</div>
</div>
... ... @@ -238,7 +254,7 @@
购outlet商品,满¥1999再享9折
\{{/if}}
\{{#if has_other_promotion}}
<span class="mycart_i_down" title="更多" ></span>
<span class="mycart_i_down" title="更多"></span>
\{{/if}}
\{{#if has_first_promotion}}
\{{first_promotions.promotion_title}}
... ... @@ -264,8 +280,9 @@
<script type="text/html" id="search-suggest-tml">
\{{#data}}
<li>
<a style="display: block;" href="\{{href}}" class="clearfix clear search-item" title="\{{keyword}}" act="\{{href}}">
<span class="searchvalue" >\{{keyword}}</span>
<a style="display: block;" href="\{{href}}" class="clearfix clear search-item" title="\{{keyword}}"
act="\{{href}}">
<span class="searchvalue">\{{keyword}}</span>
<span class="valuenum">约\{{count}}个商品</span>
</a>
</li>
... ...
{{#if latestWalk}}
{{#unless @root.pc.product.removeRecentView}}
{{#if latestWalk}}
<input id="latest-walk-count" type="hidden" value="{{latestWalk}}">
<div class="latest-walk">
<h2>最近浏览的商品</h2>
... ... @@ -6,4 +7,5 @@
</div>
{{> product/latest-walk-tpl}}
{{/if}}
{{/if}}
{{/unless}}
... ...
... ... @@ -175,6 +175,9 @@ function bindTemplete($select, data, tmp) {
// 鼠标悬浮品牌,请求数据,并且展示
function bindHoverEvent() {
if (String($list.data('ishover')) === 'true') {
return;
}
$brand.unbind('mouseenter').unbind('mouseleave').hover(function() {
var $this = $(this);
var key = $this.attr('data-key');
... ...
... ... @@ -38,6 +38,8 @@ var logoAngle = 0,
var dataLayer = [];
var cartTimer;
// banner和地址的映射
var bannerMap = {
listboys: '4f78b0f418fc42314d8b6e791cfb7fa8',
... ... @@ -75,11 +77,13 @@ var bannerMap = {
},
cookieMap = {};
var $signinBtn = $('#signin-url');
var $regBtn = $('#reg-url');
// 降级处理
var __DEGRADATION_CONFIG = {
hungMyYoho: $myYohoBox.data('hung')
};
$signinBtn.attr('href', '//www.yohobuy.com/signin.html?refer=' + window.location.href);
$regBtn.attr('href', '//www.yohobuy.com/reg.html?refer=' + window.location.href);
$('#signin-url').attr('href', '//www.yohobuy.com/signin.html?refer=' + window.location.href);
$('#reg-url').attr('href', '//www.yohobuy.com/reg.html?refer=' + window.location.href);
// handlebars模板
centerFn = handlebars.compile($('#simple-account-info-tpl').html() || '');
... ... @@ -305,6 +309,11 @@ function syncCratInfo(strG) {
domain: '.yohobuy.com'
});
}
if (!$goodsNum || !$goodsNum.length) {
return cartTimer ? clearInterval(cartTimer) : false;
}
if (window.cookie('_g')) {
info = $.parseJSON(window.cookie('_g'));
total = parseInt(info._nac, 10) + parseInt(info._ac, 10);
... ... @@ -522,7 +531,8 @@ if (isSupportCss3Animation()) {
syncPageChannel();
getBannerAndNotice(); // 获取头部banner
formatThirdMenu(); // 格式化三级菜单
setInterval(syncCratInfo, 2000); // 定时同步购物车数量
cartTimer = setInterval(syncCratInfo, 2000); // 定时同步购物车数量
// 获取头部登陆信息
(function() {
... ... @@ -542,7 +552,12 @@ setInterval(syncCratInfo, 2000); // 定时同步购物车数量
$loginBox.show();
}());
fetchUserInfoEvent.add(syncLoginInfo);
fetchUserInfoEvent.add(function() {
if ($('.simple-user-center').length === 0) {
return;
}
syncLoginInfo();
});
$myYohoBox.hover(function() {
var uid = getUid(); // eslint-disable-line
... ... @@ -594,22 +609,25 @@ $searchForm.on('keyup', '.search-key', function(e) {
$focus.addClass('action');
$(this).val($focus.find('.searchvalue').text());
} else if (e.which === 13) {
val = val.replace(new RegExp('\'', 'gm'), '');
if (val !== '') {
$(this).val(val);
$searchForm.submit();
}
} else {
if ($searchSug && $searchSug.length) {
val = val.replace(new RegExp('\'', 'gm'), ''); // 去掉特殊字符
$(this).val(val);
searchSuggest(val);
}
}
}).on('blur', '.search-key', function() {
setTimeout(function() {
$searchSug.hide();
}, 200);
});
$goCart.hover(function() {
if ($miniCart && $miniCart.length) {
$goCart.hover(function() {
var data, _html = '';
if ($goCart.hasClass('on-hover')) {
... ... @@ -625,11 +643,11 @@ $goCart.hover(function() {
}
$miniCart.html(_html);
$goCart.addClass('on-hover');
}, function() {
}, function() {
$goCart.removeClass('on-hover');
});
});
$goCart.on('click', '.cart-goods-del', function() {
$goCart.on('click', '.cart-goods-del', function() {
var $dom = $(this),
data = $dom.data(),
callback;
... ... @@ -641,7 +659,8 @@ $goCart.on('click', '.cart-goods-del', function() {
data.key = $goCart.data().key;
delCartGoods(data, callback);
}
});
});
}
$subNav.on({
mouseenter: function() {
... ...