Authored by 郭成尧

Merge branch 'hotfix/listfirst' into 'release/5.3'

优化后的搜索落地页和基础店铺也埋点



See merge request !33
... ... @@ -94,12 +94,14 @@ var category = $('#category-point').val();
var noResult = '<p class="no-result">未找到相关搜索结果</p>';
require('../../common');
C_ID = window._ChannelVary[window.cookie('_Channel')];
// 首屏无数据
if ($fsgc.children().length === 0) {
$goodsContainer.html(noResult);
}
require('../../common');
}
ellipsis.init();
... ... @@ -244,7 +246,49 @@ specialoffer = getQueryString('specialoffer');
specialsale_id = getQueryString('specialsale_id');
promotion = getQueryString('promotion');
C_ID = window._ChannelVary[window.cookie('_Channel')];
if ($fsgc.children().length > 0) {
var fsgcgoods = [],
firstop,
firstyasparm = {};
$fsgc.find('.good-info').each(function() {
var fsgcgood = $(this).data('good-id');
if (fsgcgood) {
fsgcgoods.push(fsgcgood);
}
});
if (category) {
firstop = 'YB_CATEGORY_GOODS_LIST_L';
firstyasparm = Object.assign(firstyasparm, {
CATEGORY_ID: window.queryString.msort || window.queryString.sort || ''
});
} else {
firstop = 'YB_KEYWORD_GOODS_LIST_L';
firstyasparm = Object.assign(firstyasparm, {
KEYWORD: query || ''
});
}
firstyasparm = Object.assign(firstyasparm, {
C_ID: C_ID,
RES_QTY: $fsgc.children().length,
PRD_LIST: JSON.stringify(fsgcgoods).replace(/\[|\]/g, ''),
PAGE_NUM: 1,
FILTER_VALUE: '',
SORT_TYPE: 'default'
});
setTimeout(function() {
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: firstop,
param: JSON.stringify(firstyasparm)
}, true);
}
}, 200);
}
/**
* 筛选注册的回调,筛选子项点击后逻辑
... ... @@ -252,6 +296,7 @@ C_ID = window._ChannelVary[window.cookie('_Channel')];
* @param opt {type, id}
*/
function search(opt, filtering) {
var setting = {},
ext,
att,
... ... @@ -522,11 +567,6 @@ function search(opt, filtering) {
yasparm = Object.assign(yasparm, {
CATEGORY_ID: window.queryString.msort || window.queryString.sort || ''
});
} else if ($brandHeader.length > 0) {
optype = 'YB_BRAND_GOODS_LIST_L';
yasparm = Object.assign(yasparm, {
BRAND_ID: $brandHeader.data('id')
});
} else {
optype = 'YB_KEYWORD_GOODS_LIST_L';
yasparm = Object.assign(yasparm, {
... ... @@ -1114,7 +1154,15 @@ $('#goods-container').on('click', '.good-info', function() {
var PRD_ID = $(this).data('good-id'),
PRD_NUM = $(this).index(),
FILTER_VALUE = filext ? JSON.stringify(filext).replace(/\{|\}|\"/g, '') : '',
yasparms;
yasparms,
firstType;
if ($(this).parent().hasClass('firstscreen-goods')) {
firstType = 'default';
PRD_NUM = PRD_NUM + 1;
} else if ($(this).parent().hasClass('default-goods')) {
PRD_NUM = PRD_NUM + 12;
}
yasparms = {
C_ID: C_ID,
... ... @@ -1122,7 +1170,7 @@ $('#goods-container').on('click', '.good-info', function() {
PRD_NUM: PRD_NUM,
PAGE_NUM: Math.ceil(PRD_NUM / 60),
FILTER_VALUE: FILTER_VALUE,
SORT_TYPE: argument.type
SORT_TYPE: argument ? argument.type : firstType
};
if (category) {
... ... @@ -1130,15 +1178,10 @@ $('#goods-container').on('click', '.good-info', function() {
yasparms = Object.assign(yasparms, {
CATEGORY_ID: window.queryString.msort || window.queryString.sort || ''
});
} 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 || ''
KEYWORD: argument ? argument.query : query
});
}
... ...
... ... @@ -38,6 +38,8 @@ var $input = $('#search-input input'),
$buriedpoint = $('.buriedpoint'),
$search = $('#search');
var C_ID, filext = {}, total, argument;
var shopId, sort, brand, outlets, app_type, age_level, msort, misort, coin, app_version, first_load = true;
// 默认筛选条件
... ... @@ -82,6 +84,8 @@ require('../../common');
ellipsis.init();
C_ID = window._ChannelVary[window.cookie('_Channel')];
// pageCache 获取是否收藏
(function() {
if ($('.domain').val()) {
... ... @@ -298,6 +302,7 @@ function search(opt) {
break;
}
$.extend(filext, ext);
$.extend(defaultOpt, ext); // 扩展筛选项
}
... ... @@ -374,6 +379,7 @@ function search(opt) {
loading.showLoadingMask();
}
argument = setting;
$.ajax({
type: 'GET',
... ... @@ -382,7 +388,9 @@ function search(opt) {
success: function(data) {
var noResult = '<p class="no-result">未找到相关搜索结果</p>',
num,
$container;
$container,
goodIds = [],
yasparm;
switch (navType) {
case 'newest':
... ... @@ -401,21 +409,65 @@ function search(opt) {
break;
}
yasparm = {
C_ID: C_ID,
BRAND_ID: setting.shop_id,
PAGE_NUM: setting.page,
FILTER_VALUE: opt ? JSON.stringify(filext).replace(/\{|\}|\"/g, '') : '',
SORT_TYPE: setting.type
};
if (data === '' || (data.list && data.list.length <= 0)) {
nav.end = true;
if (nav.reload) {
$container.html(noResult);
yasparm = Object.assign(yasparm, {
PRD_LIST: '',
RES_QTY: 0
});
setTimeout(function() {
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_BRAND_GOODS_LIST_C',
param: JSON.stringify(yasparm)
}, true);
}
}, 200);
}
} else {
if (nav.reload) {
var goodList = [];
$(data).each(function(i, goodInfo) {
if ($(goodInfo).hasClass('good-info')) {
goodList.push(goodInfo);
goodIds.push($(goodInfo).data('good-id'));
} else if ($(goodInfo).hasClass('total')) {
total = $(goodInfo).data('id');
}
});
yasparm = Object.assign(yasparm, {
PRD_LIST: JSON.stringify(goodIds).replace(/\[|\]/g, ''),
RES_QTY: total
});
setTimeout(function() {
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_BRAND_GOODS_LIST_C',
param: JSON.stringify(yasparm)
}, true);
}
}, 200);
if (first_load) {
first_load = false;
... ... @@ -430,6 +482,32 @@ function search(opt) {
num = $container.find('.good-info').length;
$container.append(data);
if ($container.find('.total')) {
$container.find('.total').remove();
}
$container.find('.good-info:gt(' + (num - 1) + ')').each(function() {
var goodid = $(this).data('good-id');
if (goodid) {
goodIds.push(goodid);
}
});
yasparm = Object.assign(yasparm, {
PRD_LIST: total,
RES_QTY: JSON.stringify(goodIds).replace(/\[|\]/g, '')
});
setTimeout(function() {
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_BRAND_GOODS_LIST_C',
param: JSON.stringify(yasparm)
}, true);
}
}, 200);
// lazy good-infos who append in
lazyLoad($container.find('.good-info:gt(' + (num - 1) + ') .lazy'));
}
... ... @@ -812,3 +890,26 @@ $listNav.on('touchstart', 'li', function() {
require('../../common/footer');
require('./coupon');
//点击事件埋点
$('#goods-container').on('click', '.good-info', function() {
var PRD_ID = $(this).data('good-id'),
PRD_NUM = $(this).index() + 1,
FILTER_VALUE = filext ? JSON.stringify(filext).replace(/\{|\}|\"/g, '') : '';
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_BRAND_GOODS_LIST_C',
param: JSON.stringify({
C_ID: C_ID,
PRD_ID: PRD_ID,
PRD_NUM: PRD_NUM,
PAGE_NUM: Math.ceil(PRD_NUM / 60),
FILTER_VALUE: FILTER_VALUE,
SORT_TYPE: argument ? argument.type : ''
})
}, true);
}
// return false;
});
\ No newline at end of file
... ...