Authored by 陈峰

merge feature/demote

... ... @@ -74,7 +74,7 @@ app.use(session({
app.use((req, res, next) => {
req.user = {}; // 全局的用户数据
req.yoho = {}; // req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等
req.app.locals.wap = app.locals.wap; //zookeper对象赋值
if (!req.session.id) {
req.session.id = uuid.v4();
}
... ...
... ... @@ -91,7 +91,7 @@ let switchChannel = (req, res, next) => {
}
// 设置浏览器缓存5分钟 300000ms
res.set('Expires', (new Date(_.now() + 300000)).toGMTString());
// res.set('Expires', (new Date(_.now() + 300000)).toGMTString());
next();
};
... ...
... ... @@ -6,9 +6,11 @@
<div class="header-content clearfix">
<p class="name-islike-container">
<span class="name">{{brand_name}}</span>
{{#unless @root.wap.plustar.removeCollect}}
<a id="brand-like" class="brand-islike iconfont" href="{{likeUrl}}">
&#xe605;
</a>
{{/unless}}
</p>
<div id="more-intro-click-range" class="clearfix">
<div id="intro" class="intro">
... ... @@ -100,7 +102,9 @@
<input id="jump-to-app" type="hidden" value="{{jumpToApp}}">
<input id="brandId" type="hidden" value="{{brand_id}}">
<input id="clientType" type="hidden" value="{{clientType}}">
{{#unless @root.wap.plustar.removeRelatedPost}}
<input id="related-infos-demote" type="hidden" value="1">
{{/unless}}
{{!-- wx-share --}}
<input id="shareLink" type="hidden" value="{{shareLink}}">
<input id="shareImg" type="hidden" value="{{shareImg}}">
... ...
... ... @@ -127,8 +127,9 @@
<span class="iconfont num">&#xe604;</span>
</a>
</div>
{{> common/recommend-for-you}}
{{#unless @root.wap.ucenter.removePrefer}}
{{> common/recommend-for-you}}
{{/unless}}
{{> common/suspend-cart}}
</div>
... ...
... ... @@ -33,7 +33,9 @@ exports.cart = (req, res, next) => {
uid = req.user.uid || 0,
yhChannel = req.query.yh_channel || '1',
limit = 30;
if (req.app.locals.wap.cart.removePrefer) {
return res.send('');
}
recommendForYouModel.getPreference({
yh_channel: yhChannel,
udid: udid,
... ... @@ -52,4 +54,5 @@ exports.cart = (req, res, next) => {
page: 'recommend'
});
}).catch(next);
};
... ...
... ... @@ -132,8 +132,16 @@ const list = (req, res, next) => {
*/
const index = (req, res, next) => {
let title = '搜索';
searchModel.getSearchIndex().then((result) => {
((render) => {
if (req.app.locals.wap.search.removeHotSearch) {
render([]);
} else {
searchModel.getSearchIndex().then((result) => {
render(result);
}).catch(next);
}
})((result) => {
res.render('search/index', {
module: 'product',
page: 'search-index',
... ... @@ -148,7 +156,8 @@ const index = (req, res, next) => {
}
});
}).catch(next);
})
};
/**
... ...
... ... @@ -124,6 +124,9 @@
<div class="chose-panel"></div>
<div class="cart-bar data-bind">
{{#unless @root.wap.common.removeCartCount}}
<input type="hidden" id="remove-cart-count" value="1">
{{/unless}}
<a href="" class="num-incart iconfont"><span class="num-tag hide"></span>&#xe62c;</a>
<a id="addtoCart" href="javascript:;" class="addto-cart add-to-cart-url data-bind"></a>
<a id="soldOut" href="javascript:;" class="sold-out data-bind">已售罄</a>
... ...
... ... @@ -78,7 +78,7 @@ module.exports = {
appSecret: 'ce21ae4a3f93852279175a167e54509b'
}
},
zookeeperServer: false // '10.66.1.97:2181'
zookeeperServer: '192.168.102.168:2188'
};
if (isProduction) {
... ... @@ -103,7 +103,8 @@ if (isProduction) {
interfaceShunt: {
open: false,
url: 'http://123.206.2.55/strategy'
}
},
zookeeperServer: '10.66.1.97:2181'
});
} else if (isTest) {
Object.assign(module.exports, {
... ...
... ... @@ -4,5 +4,6 @@
</a>
{{#unless @root.wap.common.removeCartCount}}
<span class="cart-count hide">0</span>
<input type="hidden" id="remove-cart-count" value="1">
{{/unless}}
</div>
... ...
... ... @@ -7,22 +7,24 @@
var $ = require('yoho-jquery');
var $cart = $('#suspend-cart');
if ($('#remove-cart-count').length) {
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if (data.code === 200) {
count = data.data.cart_goods_count;
if (count > 99) {
count = '99+';
}
if (count === 0) {
$('.cart-count').remove();
if (data.code === 200) {
count = data.data.cart_goods_count;
if (count > 99) {
count = '99+';
}
if (count === 0) {
$('.cart-count').remove();
}
$cart.find('.cart-count').html(count).removeClass('hide');
}
$cart.find('.cart-count').html(count).removeClass('hide');
}
}
});
});
}
... ...
... ... @@ -7,7 +7,7 @@ var $ = require('yoho-jquery'),
module.exports = function(callback) {
var brandId = $('#brandId').val();
var clientType = $('#clientType').val();
if (brandId) {
if (brandId && $('#related-infos-demote').length) {
$.ajax({
type: 'POST',
url: '/guang/plustar/brandinfoAsync',
... ...
... ... @@ -88,54 +88,54 @@ moreHammer.on('tap', function(e) {
e.preventDefault(); // 防止收缩后误点到商品产生跳转
});
// 品牌收藏
likeHammer = new Hammer(document.getElementById('brand-like'));
likeHammer.on('tap', function(e) {
var opt = 'ok',
$this = $(e.target);
// jumpToApp = 1表示APP未登录的情况,此时不发送ajax请求而由a链接直接跳转APP
// if (jumpToApp === '1') {
// return true;
// }
e.preventDefault();
if ($this.hasClass('like')) {
opt = 'cancel';
}
$.ajax({
type: 'POST',
url: '/guang/opt/favoriteBrand',
data: {
id: brandId,
opt: opt,
uid: uid,
isBrand: 'brand'
},
success: function(data) {
if (data.code === 200) {
$this.toggleClass('like');
tip.show(data.message);
} else if (data.code === 400 || data.code === 412) {
if (jumpToApp === '1') {
var url = location.href + '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":'
+ window.queryString.id + '}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"' + $('#brand-info').data('id') + '"}},"priority":"Y"}}';
$('body').append('<a href=' + url + ' style="display:none;"><span class="jump-login">&nbsp;</span></a>');
$('.jump-login').click();
if ($('#brand-like').length) {
// 品牌收藏
likeHammer = new Hammer(document.getElementById('brand-like'));
likeHammer.on('tap', function(e) {
var opt = 'ok',
$this = $(e.target);
// jumpToApp = 1表示APP未登录的情况,此时不发送ajax请求而由a链接直接跳转APP
// if (jumpToApp === '1') {
// return true;
// }
e.preventDefault();
if ($this.hasClass('like')) {
opt = 'cancel';
}
$.ajax({
type: 'POST',
url: '/guang/opt/favoriteBrand',
data: {
id: brandId,
opt: opt,
uid: uid,
isBrand: 'brand'
},
success: function(data) {
if (data.code === 200) {
$this.toggleClass('like');
tip.show(data.message);
} else if (data.code === 400 || data.code === 412) {
if (jumpToApp === '1') {
var url = location.href + '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":'
+ window.queryString.id + '}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"' + $('#brand-info').data('id') + '"}},"priority":"Y"}}';
$('body').append('<a href=' + url + ' style="display:none;"><span class="jump-login">&nbsp;</span></a>');
$('.jump-login').click();
} else {
location.href = data.data; // 未登录跳转登录页面
}
} else {
location.href = data.data; // 未登录跳转登录页面
tip.show(data.message);
}
} else {
tip.show(data.message);
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
return false;
});
return false;
});
}
// console.log($('.logo').attr('src'))
... ...
... ... @@ -13,8 +13,10 @@ var myImage = new Image(),
avatar;
require('../common');
require('./recommend-for-you-user-center');
require('../product/suspend-cart.js');
if ($('.recommend-for-you').length) {
require('./recommend-for-you-user-center');
}
require('../common/suspend-cart');
require('../common/footer');
// 部分老用户没有头像,显示默认头像
... ...
... ... @@ -126,25 +126,27 @@ require('./detail/page-render')(function() {
require('./detail/consultform');
require('./detail/recommend-for-you-product-desc');
// 购物车商品数量
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if (data.code === 200) {
count = data.data.cart_goods_count || 0;
if (count === 0) {
return false;
}
if (count > 99) {
count = '99+';
if ($('#remove-cart-count').length) {
// 购物车商品数量
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if (data.code === 200) {
count = data.data.cart_goods_count || 0;
if (count === 0) {
return false;
}
if (count > 99) {
count = '99+';
}
$cart.find('.num-tag').html(count).removeClass('hide');
}
$cart.find('.num-tag').html(count).removeClass('hide');
}
}
});
});
}
if ($('.good-detail-page').length > 0) {
$('#yoho-footer').css('border-top', '1px solid #e0e0e0');
... ...
... ... @@ -128,25 +128,27 @@ require('./detail/page-render')(function() {
require('./detail/consultform');
require('./detail/recommend-for-you-product-desc');
// 购物车商品数量
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if (data.code === 200) {
count = data.data.cart_goods_count || 0;
if (count === 0) {
return false;
}
if (count > 99) {
count = '99+';
if ($('#remove-cart-count').length) {
// 购物车商品数量
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if (data.code === 200) {
count = data.data.cart_goods_count || 0;
if (count === 0) {
return false;
}
if (count > 99) {
count = '99+';
}
$cart.find('.num-tag').html(count).removeClass('hide');
}
$cart.find('.num-tag').html(count).removeClass('hide');
}
}
});
});
}
if ($('.good-detail-page').length > 0) {
$('#yoho-footer').css('border-top', '1px solid #e0e0e0');
... ...
... ... @@ -8,21 +8,23 @@ var $ = require('yoho-jquery');
var $cart = $('#suspend-cart');
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if ($('#remove-cart-count').length) {
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
var count;
if (data.code === 200) {
count = data.data.cart_goods_count;
if (count > 99) {
count = '99+';
if (data.code === 200) {
count = data.data.cart_goods_count;
if (count > 99) {
count = '99+';
}
if (count === 0) {
$('.cart-count').remove();
}
$cart.find('.cart-count').html(count).removeClass('hide');
}
if (count === 0) {
$('.cart-count').remove();
}
$cart.find('.cart-count').html(count).removeClass('hide');
}
}
});
});
}
\ No newline at end of file
... ...