Authored by hongweigao

搜索页加载埋点、列表点击埋点

... ... @@ -648,6 +648,7 @@ exports.handleFilterData = (origin, params, total) => {
};
dest.checkedConditions.conditions.push({
name: name,
itemType: 'price',
href: handleFilterUrl(params, {}, {price: true})
});
}
... ... @@ -838,7 +839,8 @@ exports.handleSeniorFilterData = (data, params) => {
});
_.forEach(data.standard, value => {
let sub = [];
let sub = [],
standardName = value.standard_name;
// let parKey = `parameter_${value.standard_id}`;
... ... @@ -848,6 +850,7 @@ exports.handleSeniorFilterData = (data, params) => {
if (ched) {
conditions.push({
name: subValue.standard_name,
itemType: standardName,
href: handleFilterUrl(params, {
standard: getStandard(qStandard, null, {
k: value.standard_id,
... ... @@ -910,7 +913,6 @@ exports.handleFilterDataAll = (data, qs) => {
Object.assign(destFilter, seniorFilter, baseFilter);
_.set(destFilter, 'checkedConditions.conditions', conditions);
return destFilter;
};
... ...
{{# footPager}}
<div class="foot-pager clearfix">
<div class="foot-pager clearfix" data-total={{../totalCount}}>
<span class="total">
{{# tip}}
{{#if totalText}}
... ... @@ -19,10 +19,10 @@
{{# pages}}
<a{{#if url}} href="{{url}}"{{/if}}{{#if cur}} class="cur"{{/if}}>{{num}}</a>
{{/ pages}}
{{# nextPage}}
<a href="{{url}}" title="下一页">下一页<span class="iconfont">&#xe60c;</span></a>
{{/ nextPage}}
</div>
</div>
{{/ footPager}}
\ No newline at end of file
{{/ footPager}}
... ...
... ... @@ -6,7 +6,7 @@
<span class="title">已选条件:</span>
<div class="attr-content clearfix">
{{#each conditions}}
<a class="tag" href="{{href}}">
<a class="tag" href="{{href}}" name="{{name}}" itemType="{{itemType}}">
{{#if name}}
{{name}}
{{^}}
... ... @@ -28,7 +28,7 @@
<div class="attr-content clearfix">
{{#each channel}}
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}" name="{{name}}">
{{name}}
</a>
{{/each}}
... ... @@ -42,7 +42,7 @@
<div class="attr-content clearfix">
{{#each gender}}
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}" name="{{name}}">
{{name}}
</a>
{{/each}}
... ... @@ -58,7 +58,7 @@
<ul class="sort-pre clearfix">
{{#each sort}}
<li data-id="{{id}}">
<span class="attr {{#if checked}}checked{{/if}}">
<span class="attr {{#if checked}}checked{{/if}}" name="{{name}}">
{{name}}
<div class="sort-up-icon"></div>
</span>
... ... @@ -70,7 +70,7 @@
{{#each sort}}
<ul class="sort-sub clearfix hide">
{{#each sub}}
<li class="attr {{#if checked}}checked{{/if}}">
<li class="attr {{#if checked}}checked{{/if}}" name="{{name}}">
<a href="{{href}}">{{name}}</a>
</li>
{{/each}}
... ... @@ -88,7 +88,7 @@
<div class="attr-content clearfix">
{{#each misort}}
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}" name="{{name}}">
{{name}}
</a>
{{/each}}
... ... @@ -136,7 +136,7 @@
<div class="attr-content clearfix">
{{#each ageLevel}}
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}" name="{{name}}">
{{name}}
</a>
{{/each}}
... ... @@ -150,7 +150,7 @@
<div class="attr-content clearfix">
{{# price}}
<a class="attr{{#if checked}} checked{{/if}}" href="{{href}}">{{name}}</a>
<a class="attr{{#if checked}} checked{{/if}}" href="{{href}}" name="{{name}}">{{name}}</a>
{{/ price}}
<div class="ud-price-range">
... ... @@ -166,12 +166,12 @@
{{/if}}
{{#if discount}}
<div class="price section">
<div class="discount section">
<span class="title">折扣:</span>
<div class="attr-content clearfix">
{{# discount}}
<a class="attr{{#if checked}} checked{{/if}}" href="{{href}}">¥{{name}}</a>
<a class="attr{{#if checked}} checked{{/if}}" href="{{href}}" name="{{name}}">¥{{name}}</a>
{{/ discount}}
</div>
</div>
... ... @@ -184,7 +184,7 @@
<div class="attr-content clearfix">
{{# color}}
<a class="attr{{#if checked}} checked{{/if}}" href="{{href}}">
<a class="attr{{#if checked}} checked{{/if}}" href="{{href}}" name="{{name}}">
{{#if checked}}
<span class="color-block">
<i class="sub-color-block" style="background: {{rgb}}"></i>
... ... @@ -204,7 +204,7 @@
<div class="attr-content clearfix">
{{# size}}
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">{{name}}</a>
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}" name="{{name}}">{{name}}</a>
{{/ size}}
</div>
</div>
... ...
... ... @@ -13,6 +13,47 @@ function getCookie(name) {
}
}
// 频道、性别、品类、折扣、人群、颜色、尺码、分类
function _getCommonFilterValue() {
var $section = $('.channel, .sort, .discount, .misort, .color, .size');
var $attrchecked = $section.find('.attr-content .attr.checked');
var filterValue = '';
$attrchecked.each(function() {
var $this = $(this);
var key = $this.parents('.attr-content').prev().html(),
name = $this.attr('name');
filterValue += key + name + ';';
});
return filterValue;
}
// 价格、品牌、高级筛选
function _getOtherFilterValue() {
var filterValue = '';
$('.checked-conditions .attr-content .tag').each(function() {
var type = $(this).attr('itemType'),
name = $(this).attr('name');
switch (type) {
case 'brands':
type = '品牌';
break;
case 'price':
type = '价格';
break;
default:
break;
}
filterValue += type + ':' + name + ';';
});
return filterValue;
}
/** *埋点方法***/
function givePoint(op, parameter) {
var CID = 1;
... ... @@ -45,12 +86,18 @@ function givePoint(op, parameter) {
C_ID: CID
}, parameter);
console.info(op);
console.info(parameter);
window._yas.sendCustomInfo({
op: op,
param: JSON.stringify(parameter)
}, true);
}
};
function getFilterValue() {
return _getCommonFilterValue() + _getOtherFilterValue();
};
exports.givePoint = givePoint;
exports.getFilterValue = getFilterValue;
... ...
... ... @@ -9,10 +9,11 @@
* 页面已经被 nginx 缓存,变化后的数据需要通过 ajax 进行获取后,重新绑定事件。
*/
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload'),
yas = require('../common/data-yas'),
dataLazyLoad = require('../plugins/lazy-load')(document);
var $ = require('yoho-jquery');
var lazyLoad = require('yoho-jquery-lazyload');
var yas = require('../common/data-yas');
var dataLazyLoad = require('../plugins/lazy-load')(document);
var bindEvent = $.Callbacks(); // eslint-disable-line
var clickAcquireCouponEvent = $.Callbacks('unique'); // eslint-disable-line
... ... @@ -456,6 +457,7 @@ bindEvent.add(function() {
coltyp = cancel ? 2 : 1;
// 收藏埋點
yas.givePoint('YB_COLLECTION_C', {PRD_ID: id, COL_TYP: coltyp });
$.ajax({
... ...
... ... @@ -99,7 +99,6 @@ exports.init = function(num) {
containerPt, // 商品列表容器的上内边距
_from = event.target.attr('data-from') || '';
pics = [];
event.target.find('.hideList > li').each(function() {
pic = $(this).data();
... ... @@ -138,6 +137,7 @@ exports.init = function(num) {
if (diffWidth <= 0) {
wrapperX = wrapperX + diffWidth - 25;
}
$goodItemWrapper.attr('activeIndex', event.activeIndex);
$goodItemWrapper.css({
width: wrapperWidth,
left: wrapperX,
... ...
... ... @@ -3,10 +3,26 @@
* @author: sefon 2016-7-12 15:28:22
*/
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
var $ = require('yoho-jquery');
var yas = require('../common/data-yas');
var lazyLoad = require('yoho-jquery-lazyload');
var product = require('./index/product');
var product = require('./index/product'),
qs = window.queryString;
var $footPage = $('.foot-pager1').data('total'),
$productIdArr = [],
$leftUl = $('.sort-container .sort-child-list'),
$leftLi = $leftUl.find('li.active');
var filterValue = yas.getFilterValue();
$('.good-info .product-id').each(function() {
$productIdArr.push($(this).html());
});
require('../common');
require('../plugins/filter');
... ... @@ -15,6 +31,55 @@ require('./detail/latest-walk');
product.init(4);
lazyLoad($('img.lazy'), {
failure_limit: 20
});
/*
* 页面加载完
*/
$(function() {
var sto = setInterval(function() {
if (window._yas && window._yas.sendCustomInfo) {
// 关键词搜索结果页展示时
yas.givePoint('YB_KEYWORD_GOODS_LIST_L', {
KEYWORD: qs.query,
RES_QTY: $footPage || 0,
PRD_LIST: $productIdArr.join(','),
PAGE_NUM: qs.pager || 1,
FILTER_VALUE: filterValue,
L1_SORT: $leftLi.length > 0 ? $leftLi.parent().prev().attr('title') : '',
L2_SORT: $leftLi.find('a').attr('title') || '',
SORT_TYPE: qs.order || 's_n_desc'
});
clearInterval(sto);
}
}, 100);
// 点击搜索列表商品
$('.good-item-wrapper').click(function() {
var $this = $(this),
proId = $this.find('.product-id').html(),
aIndex = $this.attr('activeIndex'),
pageNum = qs.pager || 1,
limit = qs.limit || 60,
proNum = (parseInt(pageNum, 10) - 1) * limit + parseInt(aIndex, 10);
// 点击搜索列表商品埋点
yas.givePoint('YB_KEYWORD_GOODS_LIST_C', {
KEYWORD: qs.query,
PRD_ID: proId,
PRD_NUM: proNum,
PAGE_NUM: pageNum,
FILTER_VALUE: filterValue,
L1_SORT: $leftLi.length > 0 ? $leftLi.parent().prev().attr('title') : '',
L2_SORT: $leftLi.find('a').attr('title') || '',
SORT_TYPE: qs.order || 's_n_desc'
});
});
});
... ...