Authored by zhangxiaoru

merge

... ... @@ -14,7 +14,9 @@
{{/announcement}} --}}
{{! 中间banner}}
{{#if singleImage}}
<div data-id="{{template_id}}">
{{> resources/banner}}
</div>
{{/if}}
{{! 两个小图}}
{{#if smallPic}}
... ...
... ... @@ -222,7 +222,8 @@ const category = (req, res) => {
}),
goodList: params,
showDownloadApp: true,
pageFooter: true
pageFooter: true,
category: true
});
};
... ...
... ... @@ -45,10 +45,15 @@ const selectNewSale = (req, res, next) => {
let params = _.assign({}, req.query);
newModel.getSearchData(params).then((result) => {
res.render('search/page', {
layout: false,
new: result
});
if (result.list.length > 0) {
res.render('search/page', {
layout: false,
new: result.list,
total: result.total
});
} else {
res.json(result);
}
}).catch(next);
};
... ...
... ... @@ -182,10 +182,16 @@ const search = (req, res, next) => {
params.isApp = req.yoho.isApp;
searchModel.getSearchData(params).then((result) => {
res.render('search/page', {
layout: false,
new: result
});
if (result.list.length > 0) {
res.render('search/page', {
layout: false,
new: result.list,
total: result.total
});
} else {
res.json(result);
}
}).catch(next);
};
... ...
... ... @@ -71,7 +71,15 @@ const getNewFocus = (channel) => {
const getSearchData = (params) => {
return _searchGoods(params).then((result) => {
if (result && result.code === 200) {
return productProcess.processProductList(result.data.product_list || [], {showTags: false});
let newList = {};
newList.list = productProcess.processProductList(result.data.product_list || [], {showTags: false});
if (parseInt(params.page) === 1) {
newList.total = result.data.total;
}
return newList;
} else {
logger.error('get product search api return code is not 200');
return [];
... ...
... ... @@ -147,10 +147,18 @@ const _searchGoods = (params) => {
const getSearchData = (params) => {
return _searchGoods(params).then((result) => {
if (result && result.code === 200) {
return productProcess.processProductList(result.data.product_list || [], {
let newList = {};
newList.list = productProcess.processProductList(result.data.product_list || [], {
isApp: params.isApp || (params.appVersion && params.appVersion !== 'false'),
gender: _coverChannel[params.coverChannel]
});
if (parseInt(params.page) === 1) {
newList.total = result.data.total;
}
return newList;
} else {
logger.error('get product search api return code is not 200');
return [];
... ...
<div class="good-list-page yoho-page">
{{> search/list}}
{{#if category}}
<input type="text" id="category-point" style="display:none" value="{{category}}">
{{/if}}
</div>
... ...
<div class="total" data-id="{{total}}"></div>
{{# new}}
{{> common/goods}}
{{/ new}}
... ...
... ... @@ -84,7 +84,7 @@ module.exports = {
port: '4444' // influxdb port
},
console: {
level: 'error',
level: 'debug',
colorize: 'all',
prettyPrint: true
}
... ...
{
"name": "m-yohobuy-node",
"version": "5.1.7",
"version": "5.1.8",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -155,7 +155,7 @@ var page = {
// 埋点
tracking: function() {
var C_ID = this.getChannel(),
UDID = window.queryString.udid || '',
UDID = window.queryString.udid || window.queryString.anbiudid || '',
SID = window.queryString.session_id || '';
// 刚进页面埋点
... ...
... ... @@ -22,7 +22,7 @@ var getChannel = function() {
// 抽奖埋点
var tracking = function() {
var C_ID = getChannel(),
UDID = window.queryString.udid || '',
UDID = window.queryString.udid || window.queryString.anbiudid || '',
SID = window.queryString.session_id || '';
setTimeout(function() {
... ...
... ... @@ -18,6 +18,9 @@ var $mobileWrap = $('.mobile-wrap'),
swiperClass,
isen = true;
var getChannel,
C_ID;
require('../common');
fastclick.attach(document.body);
... ... @@ -228,3 +231,27 @@ window.setCookie('_Channel', $mobileWrap.data('channel'), {
});
require('./maybe-like')();
getChannel = function functionName() {
var name = window.cookie('_Channel');
return {
boys: 1,
girls: 2,
kids: 3,
lifestyle: 4
}[name] || 1;
};
C_ID = getChannel();
$('.search-btn').click(function() {
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_HOME_SEARCH_C',
param: JSON.stringify({
C_ID: C_ID,
})
}, true);
}
});
... ...
... ... @@ -409,6 +409,8 @@ function givePoint(parameter) {
}
break;
}
} else {
header.removeClass('girls', 'life-style', 'kids');
}
switch (channel) {
... ...
... ... @@ -299,7 +299,7 @@ $(function() {
if (isApp) {
speckParamApp = {
udid: window.queryString.udid || '',
udid: window.queryString.udid || window.queryString.anbiudid || '',
apt: window.queryString.client_type || '',
sid: window.queryString.session_id || '',
};
... ...
... ... @@ -14,18 +14,58 @@ var productId = $('#productId').val();
var skn = $('#productSkn').val(),
productCode = $('#limitProductCode').val();
var getChannel,
C_ID,
PRD_ID;
getChannel = function functionName() {
var name = window.cookie('_Channel');
return {
boys: 1,
girls: 2,
kids: 3,
lifestyle: 4
}[name] || 1;
};
$('#likeBtn').on('touchstart', function() {
var opt,
favorite;
var $this = $(this);
PRD_ID = productId;
C_ID = getChannel();
if ($this.hasClass('liked')) {
opt = 'cancel';
favorite = 0;
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_COLLECTION_C',
param: JSON.stringify({
C_ID: C_ID,
PRD_ID: PRD_ID,
COL_TYPE: 2
})
}, true);
}
} else {
opt = 'ok';
favorite = 1;
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_COLLECTION_C',
param: JSON.stringify({
C_ID: C_ID,
PRD_ID: PRD_ID,
COL_TYPE: 1
})
}, true);
}
}
$.ajax({
... ...
... ... @@ -33,6 +33,8 @@ var now = new Date(),
month = now.getMonth() + 1,
date = now.getDate();
var getChannel, C_ID, argument;
require('../../common/footer');
var $listNav = $('#list-nav'),
... ... @@ -77,6 +79,19 @@ if ($('.swiper-container .swiper-slide').length > 1) {
});
}
getChannel = function functionName() {
var name = window.cookie('_Channel');
return {
boys: 1,
girls: 2,
kids: 3,
lifestyle: 4
}[name] || 1;
};
C_ID = getChannel();
/**
* 筛选注册的回调,筛选子项点击后逻辑
* 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载
... ... @@ -201,13 +216,18 @@ function search(opt) {
searching = true;
loading.showLoadingMask();
argument = setting;
$.ajax({
type: 'GET',
url: '/product/new/selectNewSale',
data: setting,
success: function(data) {
var $container,
num;
num,
yasparm,
goodid,
goodIds = [];
switch (navType) {
case 'today':
... ... @@ -223,21 +243,68 @@ function search(opt) {
break;
}
if (data === ' ' || data === '') {
if (data === ' ' || data === '' || data.list) {
nav.end = true;
if (nav.reload) {
$container.html(noResult);
}
} else {
yasparm = {
C_ID: C_ID,
PAGE_NUM: setting.page,
FILTER_VALUE: JSON.stringify(setting).replace(/\{|\}|\"/g, ''),
SORT_TYPE: setting.dayLimit
};
if (nav.reload) {
$container.html(data);
lazyLoad($container.find('.lazy'));
$container.find('.good-info').each(function() {
goodid = $(this).data('good-id');
if (goodid) {
goodIds.push(goodid);
}
});
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_NEW_GOODS_LIST_L',
param: JSON.stringify(Object.assign(yasparm, {
RES_QTY: $container.find('.total').data('id'),
PRD_LIST: goodIds
}))
}, true);
}
} else {
num = $container.find('.good-info').length;
$container.append(data);
if ($container.find('.total')[1]) {
$container.find('.total')[1].remove();
}
// lazy good-infos who append in
lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy'));
$container.find('.good-info:gt(' + (num - 1) + ')').each(function() {
goodid = $(this).data('good-id');
if (goodid) {
goodIds.push(goodid);
}
});
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_NEW_GOODS_LIST_L',
param: JSON.stringify(Object.assign(yasparm, {
RES_QTY: $container.find('.total').data('id'),
PRD_LIST: goodIds
}))
}, true);
}
}
}
... ... @@ -404,3 +471,27 @@ $listNav.on('touchstart', 'li', function() {
}).on('touchend touchcancel', function() {
$listNav.find('li').removeClass('bytouch');
});
$('#goods-container').on('click', '.good-info', function() {
var PRD_ID = $(this).data('good-id'),
PRD_NUM = $(this).index(),
FILTER_VALUE = JSON.stringify(argument).replace(/\{|\}|\"/g, '');
// event.preventDefault();
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_NEW_GOODS_LIST_C',
param: JSON.stringify({
C_ID: C_ID,
PRD_ID: PRD_ID,
PRD_NUM: PRD_NUM,
PAGE_NUM: argument.page,
FILTER_VALUE: FILTER_VALUE || '',
SORT_TYPE: argument.dayLimit
})
}, true);
}
// return false;
});
... ...
... ... @@ -31,6 +31,8 @@ var historyval = writeSearch.getHistoryval();
var chHammer, cHammer;
var getChannel, C_ID, POS_ID, FLR_INDEX;
require('../../common');
chHammer = new Hammer($clearHistory[0]);
... ... @@ -123,6 +125,19 @@ function inputAction() {
});
}
getChannel = function functionName() {
var name = window.cookie('_Channel');
return {
boys: 1,
girls: 2,
kids: 3,
lifestyle: 4
}[name] || 1;
};
C_ID = getChannel();
// 热门搜索、最近搜索事件
$('.search-items .search-group').on('click', 'li', function(event) {
var query = '';
... ... @@ -135,6 +150,26 @@ $('.search-items .search-group').on('click', 'li', function(event) {
query = $(event.target).find('a').html();
}
if ($(this).parents('.search-group').hasClass('history-search')) {
POS_ID = 1;
FLR_INDEX = 1;
} else {
POS_ID = 2;
FLR_INDEX = 2;
}
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_KEYWORD_SEARCH_C',
param: JSON.stringify({
C_ID: C_ID,
KEYWORD: query,
POS_ID: POS_ID,
FLR_INDEX: FLR_INDEX
})
}, true);
}
goSearch(query);
});
... ... @@ -159,6 +194,18 @@ $search.on('touchend', function() {
return false;
}
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_KEYWORD_SEARCH_C',
param: JSON.stringify({
C_ID: C_ID,
KEYWORD: $buriedpoint.val(),
POS_ID: 0,
FLR_INDEX: 0
})
}, true);
}
$(this).closest('form').submit();
return false;
});
... ...
... ... @@ -84,6 +84,10 @@ var $listNav = $('#list-nav'),
introHammer,
brandColHammer;
var getChannel, C_ID, RES_QTY, argument, optype;
var category = $('#category-point').val();
require('../../common');
ellipsis.init();
... ... @@ -229,6 +233,19 @@ specialoffer = getQueryString('specialoffer');
specialsale_id = getQueryString('specialsale_id');
promotion = getQueryString('promotion');
getChannel = function functionName() {
var name = window.cookie('_Channel');
return {
boys: 1,
girls: 2,
kids: 3,
lifestyle: 4
}[name] || 1;
};
C_ID = getChannel();
/**
* 筛选注册的回调,筛选子项点击后逻辑
* 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载
... ... @@ -445,6 +462,8 @@ function search(opt) {
searching = true;
loading.showLoadingMask();
argument = setting;
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/search/search',
... ... @@ -452,7 +471,11 @@ function search(opt) {
success: function(data) {
var noResult = '<p class="no-result">未找到相关搜索结果</p>',
num,
$container;
$container,
goodIds = [],
FILTER_VALUE,
yasparm,
PRD_LIST;
switch (navType) {
case 'new':
... ... @@ -474,24 +497,106 @@ function search(opt) {
break;
}
if (data === '') {
// console.log(data)
if (data === '' || data.list) {
nav.end = true;
if (nav.reload) {
$container.html(noResult);
}
} else {
yasparm = {
C_ID: C_ID,
PAGE_NUM: setting.page,
FILTER_VALUE: FILTER_VALUE,
SORT_TYPE: setting.type
};
if (category) {
optype = 'YB_CATEGORY_GOODS_LIST_L',
yasparm = Object.assign(yasparm, {
CATEGORY_ID: window.queryString.title || '',
});
} else if ($brandHeader.length > 0) {
optype = 'YB_BRAND_GOODS_LIST_L',
yasparm = Object.assign(yasparm, {
BRAND_ID: $brandHeader.data('id')
});
} else {
optype = 'YB_KEYWORD_GOOS_LIST_L',
yasparm = Object.assign(yasparm, {
KEYWORD: setting.query || ''
});
}
if (nav.reload) {
$container.html(data);
lazyLoad($container.find('.lazy'));
RES_QTY = $container.find('.total').data('id');
FILTER_VALUE = JSON.stringify(setting).replace(/\{|\}|\"/g, '');
$container.find('.good-info').each(function() {
var goodid = $(this).data('good-id');
if (goodid) {
goodIds.push(goodid);
}
});
PRD_LIST = JSON.stringify(goodIds).replace(/\[|\]/g, '');
yasparm = Object.assign(yasparm, {
PRD_LIST: PRD_LIST,
RES_QTY: RES_QTY,
FILTER_VALUE: FILTER_VALUE
});
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: optype,
param: JSON.stringify(yasparm)
}, true);
}
} else {
num = $container.find('.good-info').length;
$container.append(data);
if ($container.find('.total')[1]) {
$container.find('.total')[1].remove();
}
RES_QTY = $container.find('.total').data('id');
FILTER_VALUE = JSON.stringify(setting).replace(/\{|\}|\"/g, '');
$container.find('.good-info:gt(' + (num - 1) + ')').each(function() {
var goodid = $(this).data('good-id');
if (goodid) {
goodIds.push(goodid);
}
});
PRD_LIST = JSON.stringify(goodIds).replace(/\[|\]/g, '');
yasparm = Object.assign(yasparm, {
PRD_LIST: PRD_LIST,
RES_QTY: RES_QTY,
FILTER_VALUE: FILTER_VALUE
});
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: optype,
param: JSON.stringify(yasparm)
}, true);
}
// lazy good-infos who append in
lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy'));
}
}
nav.reload = false;
... ... @@ -536,9 +641,10 @@ function search(opt) {
break;
}
}
}
});
}
require('../../common/suspend-cart'); // 悬浮购物车
... ... @@ -954,3 +1060,47 @@ $listNav.on('touchstart', 'li', function() {
}).on('touchend touchcancel', 'li', function() {
$listNav.find('li').removeClass('bytouch');
});
$('#goods-container').on('click', '.good-info', function(event) {
var PRD_ID = $(this).data('good-id'),
PRD_NUM = $(this).index(),
FILTER_VALUE = JSON.stringify(argument).replace(/\{|\}|\"/g, ''),
yasparms;
// event.preventDefault();
yasparms = {
C_ID: C_ID,
PRD_ID: PRD_ID,
PRD_NUM: PRD_NUM,
PAGE_NUM: argument.page,
FILTER_VALUE: FILTER_VALUE,
SORT_TYPE: argument.type
};
if (category) {
optype = 'YB_CATEGORY_GOODS_LIST_C',
yasparms = Object.assign(yasparms, {
CATEGORY_ID: window.queryString.title || '',
});
} else if ($brandHeader.length > 0) {
optype = 'YB_BRAND_GOODS_LIST_C',
yasparms = Object.assign(yasparms, {
BRAND_ID: $brandHeader.data('id')
});
} else {
optype = 'YB_KEYWORD_GOOS_LIST_C',
yasparms = Object.assign(yasparms, {
KEYWORD: argument.query || ''
});
}
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: optype,
param: JSON.stringify(yasparms)
}, true);
}
// return false;
});
... ...
... ... @@ -242,6 +242,7 @@ seckillObj = {
data = $.extend(data, {isApp: yoho.isApp});
$('.product-list').html(self.listTemplate(data));
lazyload('img.lazy');
window.scrollTo(0, 0);
window.rePosFooter();
},
error: function(data) {
... ...
... ... @@ -16,7 +16,7 @@ search.start();
$('.goods-container').on('click', '.good-info', function() {
var C_ID = getChannel(),
UDID = window.queryString.udid || '',
UDID = window.queryString.udid || window.queryString.anbiudid || '',
SID = window.queryString.session_id || '',
skn = $(this).attr('data-id');
... ...