Authored by hongweigao

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

@@ -648,6 +648,7 @@ exports.handleFilterData = (origin, params, total) => { @@ -648,6 +648,7 @@ exports.handleFilterData = (origin, params, total) => {
648 }; 648 };
649 dest.checkedConditions.conditions.push({ 649 dest.checkedConditions.conditions.push({
650 name: name, 650 name: name,
  651 + itemType: 'price',
651 href: handleFilterUrl(params, {}, {price: true}) 652 href: handleFilterUrl(params, {}, {price: true})
652 }); 653 });
653 } 654 }
@@ -838,7 +839,8 @@ exports.handleSeniorFilterData = (data, params) => { @@ -838,7 +839,8 @@ exports.handleSeniorFilterData = (data, params) => {
838 }); 839 });
839 840
840 _.forEach(data.standard, value => { 841 _.forEach(data.standard, value => {
841 - let sub = []; 842 + let sub = [],
  843 + standardName = value.standard_name;
842 844
843 // let parKey = `parameter_${value.standard_id}`; 845 // let parKey = `parameter_${value.standard_id}`;
844 846
@@ -848,6 +850,7 @@ exports.handleSeniorFilterData = (data, params) => { @@ -848,6 +850,7 @@ exports.handleSeniorFilterData = (data, params) => {
848 if (ched) { 850 if (ched) {
849 conditions.push({ 851 conditions.push({
850 name: subValue.standard_name, 852 name: subValue.standard_name,
  853 + itemType: standardName,
851 href: handleFilterUrl(params, { 854 href: handleFilterUrl(params, {
852 standard: getStandard(qStandard, null, { 855 standard: getStandard(qStandard, null, {
853 k: value.standard_id, 856 k: value.standard_id,
@@ -910,7 +913,6 @@ exports.handleFilterDataAll = (data, qs) => { @@ -910,7 +913,6 @@ exports.handleFilterDataAll = (data, qs) => {
910 Object.assign(destFilter, seniorFilter, baseFilter); 913 Object.assign(destFilter, seniorFilter, baseFilter);
911 914
912 _.set(destFilter, 'checkedConditions.conditions', conditions); 915 _.set(destFilter, 'checkedConditions.conditions', conditions);
913 -  
914 return destFilter; 916 return destFilter;
915 }; 917 };
916 918
1 {{# footPager}} 1 {{# footPager}}
2 2
3 - <div class="foot-pager clearfix"> 3 + <div class="foot-pager clearfix" data-total={{../totalCount}}>
4 <span class="total"> 4 <span class="total">
5 {{# tip}} 5 {{# tip}}
6 {{#if totalText}} 6 {{#if totalText}}
@@ -19,10 +19,10 @@ @@ -19,10 +19,10 @@
19 {{# pages}} 19 {{# pages}}
20 <a{{#if url}} href="{{url}}"{{/if}}{{#if cur}} class="cur"{{/if}}>{{num}}</a> 20 <a{{#if url}} href="{{url}}"{{/if}}{{#if cur}} class="cur"{{/if}}>{{num}}</a>
21 {{/ pages}} 21 {{/ pages}}
22 - 22 +
23 {{# nextPage}} 23 {{# nextPage}}
24 <a href="{{url}}" title="下一页">下一页<span class="iconfont">&#xe60c;</span></a> 24 <a href="{{url}}" title="下一页">下一页<span class="iconfont">&#xe60c;</span></a>
25 {{/ nextPage}} 25 {{/ nextPage}}
26 </div> 26 </div>
27 </div> 27 </div>
28 -{{/ footPager}}  
  28 +{{/ footPager}}
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 <span class="title">已选条件:</span> 6 <span class="title">已选条件:</span>
7 <div class="attr-content clearfix"> 7 <div class="attr-content clearfix">
8 {{#each conditions}} 8 {{#each conditions}}
9 - <a class="tag" href="{{href}}"> 9 + <a class="tag" href="{{href}}" name="{{name}}" itemType="{{itemType}}">
10 {{#if name}} 10 {{#if name}}
11 {{name}} 11 {{name}}
12 {{^}} 12 {{^}}
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 28
29 <div class="attr-content clearfix"> 29 <div class="attr-content clearfix">
30 {{#each channel}} 30 {{#each channel}}
31 - <a class="attr {{#if checked}}checked{{/if}}" href="{{href}}"> 31 + <a class="attr {{#if checked}}checked{{/if}}" href="{{href}}" name="{{name}}">
32 {{name}} 32 {{name}}
33 </a> 33 </a>
34 {{/each}} 34 {{/each}}
@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
42 42
43 <div class="attr-content clearfix"> 43 <div class="attr-content clearfix">
44 {{#each gender}} 44 {{#each gender}}
45 - <a class="attr {{#if checked}}checked{{/if}}" href="{{href}}"> 45 + <a class="attr {{#if checked}}checked{{/if}}" href="{{href}}" name="{{name}}">
46 {{name}} 46 {{name}}
47 </a> 47 </a>
48 {{/each}} 48 {{/each}}
@@ -58,7 +58,7 @@ @@ -58,7 +58,7 @@
58 <ul class="sort-pre clearfix"> 58 <ul class="sort-pre clearfix">
59 {{#each sort}} 59 {{#each sort}}
60 <li data-id="{{id}}"> 60 <li data-id="{{id}}">
61 - <span class="attr {{#if checked}}checked{{/if}}"> 61 + <span class="attr {{#if checked}}checked{{/if}}" name="{{name}}">
62 {{name}} 62 {{name}}
63 <div class="sort-up-icon"></div> 63 <div class="sort-up-icon"></div>
64 </span> 64 </span>
@@ -70,7 +70,7 @@ @@ -70,7 +70,7 @@
70 {{#each sort}} 70 {{#each sort}}
71 <ul class="sort-sub clearfix hide"> 71 <ul class="sort-sub clearfix hide">
72 {{#each sub}} 72 {{#each sub}}
73 - <li class="attr {{#if checked}}checked{{/if}}"> 73 + <li class="attr {{#if checked}}checked{{/if}}" name="{{name}}">
74 <a href="{{href}}">{{name}}</a> 74 <a href="{{href}}">{{name}}</a>
75 </li> 75 </li>
76 {{/each}} 76 {{/each}}
@@ -88,7 +88,7 @@ @@ -88,7 +88,7 @@
88 88
89 <div class="attr-content clearfix"> 89 <div class="attr-content clearfix">
90 {{#each misort}} 90 {{#each misort}}
91 - <a class="attr {{#if checked}}checked{{/if}}" href="{{href}}"> 91 + <a class="attr {{#if checked}}checked{{/if}}" href="{{href}}" name="{{name}}">
92 {{name}} 92 {{name}}
93 </a> 93 </a>
94 {{/each}} 94 {{/each}}
@@ -136,7 +136,7 @@ @@ -136,7 +136,7 @@
136 136
137 <div class="attr-content clearfix"> 137 <div class="attr-content clearfix">
138 {{#each ageLevel}} 138 {{#each ageLevel}}
139 - <a class="attr {{#if checked}}checked{{/if}}" href="{{href}}"> 139 + <a class="attr {{#if checked}}checked{{/if}}" href="{{href}}" name="{{name}}">
140 {{name}} 140 {{name}}
141 </a> 141 </a>
142 {{/each}} 142 {{/each}}
@@ -150,7 +150,7 @@ @@ -150,7 +150,7 @@
150 150
151 <div class="attr-content clearfix"> 151 <div class="attr-content clearfix">
152 {{# price}} 152 {{# price}}
153 - <a class="attr{{#if checked}} checked{{/if}}" href="{{href}}">{{name}}</a> 153 + <a class="attr{{#if checked}} checked{{/if}}" href="{{href}}" name="{{name}}">{{name}}</a>
154 {{/ price}} 154 {{/ price}}
155 155
156 <div class="ud-price-range"> 156 <div class="ud-price-range">
@@ -166,12 +166,12 @@ @@ -166,12 +166,12 @@
166 {{/if}} 166 {{/if}}
167 167
168 {{#if discount}} 168 {{#if discount}}
169 - <div class="price section"> 169 + <div class="discount section">
170 <span class="title">折扣:</span> 170 <span class="title">折扣:</span>
171 171
172 <div class="attr-content clearfix"> 172 <div class="attr-content clearfix">
173 {{# discount}} 173 {{# discount}}
174 - <a class="attr{{#if checked}} checked{{/if}}" href="{{href}}">¥{{name}}</a> 174 + <a class="attr{{#if checked}} checked{{/if}}" href="{{href}}" name="{{name}}">¥{{name}}</a>
175 {{/ discount}} 175 {{/ discount}}
176 </div> 176 </div>
177 </div> 177 </div>
@@ -184,7 +184,7 @@ @@ -184,7 +184,7 @@
184 184
185 <div class="attr-content clearfix"> 185 <div class="attr-content clearfix">
186 {{# color}} 186 {{# color}}
187 - <a class="attr{{#if checked}} checked{{/if}}" href="{{href}}"> 187 + <a class="attr{{#if checked}} checked{{/if}}" href="{{href}}" name="{{name}}">
188 {{#if checked}} 188 {{#if checked}}
189 <span class="color-block"> 189 <span class="color-block">
190 <i class="sub-color-block" style="background: {{rgb}}"></i> 190 <i class="sub-color-block" style="background: {{rgb}}"></i>
@@ -204,7 +204,7 @@ @@ -204,7 +204,7 @@
204 204
205 <div class="attr-content clearfix"> 205 <div class="attr-content clearfix">
206 {{# size}} 206 {{# size}}
207 - <a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">{{name}}</a> 207 + <a class="attr {{#if checked}}checked{{/if}}" href="{{href}}" name="{{name}}">{{name}}</a>
208 {{/ size}} 208 {{/ size}}
209 </div> 209 </div>
210 </div> 210 </div>
@@ -13,6 +13,47 @@ function getCookie(name) { @@ -13,6 +13,47 @@ function getCookie(name) {
13 } 13 }
14 } 14 }
15 15
  16 +// 频道、性别、品类、折扣、人群、颜色、尺码、分类
  17 +function _getCommonFilterValue() {
  18 + var $section = $('.channel, .sort, .discount, .misort, .color, .size');
  19 + var $attrchecked = $section.find('.attr-content .attr.checked');
  20 + var filterValue = '';
  21 +
  22 + $attrchecked.each(function() {
  23 + var $this = $(this);
  24 + var key = $this.parents('.attr-content').prev().html(),
  25 + name = $this.attr('name');
  26 +
  27 + filterValue += key + name + ';';
  28 + });
  29 +
  30 + return filterValue;
  31 +}
  32 +
  33 +// 价格、品牌、高级筛选
  34 +function _getOtherFilterValue() {
  35 + var filterValue = '';
  36 +
  37 + $('.checked-conditions .attr-content .tag').each(function() {
  38 + var type = $(this).attr('itemType'),
  39 + name = $(this).attr('name');
  40 +
  41 + switch (type) {
  42 + case 'brands':
  43 + type = '品牌';
  44 + break;
  45 + case 'price':
  46 + type = '价格';
  47 + break;
  48 + default:
  49 + break;
  50 + }
  51 + filterValue += type + ':' + name + ';';
  52 + });
  53 +
  54 + return filterValue;
  55 +}
  56 +
16 /** *埋点方法***/ 57 /** *埋点方法***/
17 function givePoint(op, parameter) { 58 function givePoint(op, parameter) {
18 var CID = 1; 59 var CID = 1;
@@ -45,12 +86,18 @@ function givePoint(op, parameter) { @@ -45,12 +86,18 @@ function givePoint(op, parameter) {
45 C_ID: CID 86 C_ID: CID
46 }, parameter); 87 }, parameter);
47 88
48 - console.info(op);  
49 console.info(parameter); 89 console.info(parameter);
50 window._yas.sendCustomInfo({ 90 window._yas.sendCustomInfo({
51 op: op, 91 op: op,
52 param: JSON.stringify(parameter) 92 param: JSON.stringify(parameter)
53 }, true); 93 }, true);
54 -} 94 +};
  95 +
  96 +function getFilterValue() {
  97 + return _getCommonFilterValue() + _getOtherFilterValue();
  98 +};
  99 +
  100 +
55 exports.givePoint = givePoint; 101 exports.givePoint = givePoint;
  102 +exports.getFilterValue = getFilterValue;
56 103
@@ -9,10 +9,11 @@ @@ -9,10 +9,11 @@
9 * 页面已经被 nginx 缓存,变化后的数据需要通过 ajax 进行获取后,重新绑定事件。 9 * 页面已经被 nginx 缓存,变化后的数据需要通过 ajax 进行获取后,重新绑定事件。
10 */ 10 */
11 11
12 -var $ = require('yoho-jquery'),  
13 - lazyLoad = require('yoho-jquery-lazyload'),  
14 - yas = require('../common/data-yas'),  
15 - dataLazyLoad = require('../plugins/lazy-load')(document); 12 +var $ = require('yoho-jquery');
  13 +
  14 +var lazyLoad = require('yoho-jquery-lazyload');
  15 +var yas = require('../common/data-yas');
  16 +var dataLazyLoad = require('../plugins/lazy-load')(document);
16 17
17 var bindEvent = $.Callbacks(); // eslint-disable-line 18 var bindEvent = $.Callbacks(); // eslint-disable-line
18 var clickAcquireCouponEvent = $.Callbacks('unique'); // eslint-disable-line 19 var clickAcquireCouponEvent = $.Callbacks('unique'); // eslint-disable-line
@@ -456,6 +457,7 @@ bindEvent.add(function() { @@ -456,6 +457,7 @@ bindEvent.add(function() {
456 457
457 coltyp = cancel ? 2 : 1; 458 coltyp = cancel ? 2 : 1;
458 459
  460 + // 收藏埋點
459 yas.givePoint('YB_COLLECTION_C', {PRD_ID: id, COL_TYP: coltyp }); 461 yas.givePoint('YB_COLLECTION_C', {PRD_ID: id, COL_TYP: coltyp });
460 462
461 $.ajax({ 463 $.ajax({
@@ -99,7 +99,6 @@ exports.init = function(num) { @@ -99,7 +99,6 @@ exports.init = function(num) {
99 containerPt, // 商品列表容器的上内边距 99 containerPt, // 商品列表容器的上内边距
100 _from = event.target.attr('data-from') || ''; 100 _from = event.target.attr('data-from') || '';
101 101
102 -  
103 pics = []; 102 pics = [];
104 event.target.find('.hideList > li').each(function() { 103 event.target.find('.hideList > li').each(function() {
105 pic = $(this).data(); 104 pic = $(this).data();
@@ -138,6 +137,7 @@ exports.init = function(num) { @@ -138,6 +137,7 @@ exports.init = function(num) {
138 if (diffWidth <= 0) { 137 if (diffWidth <= 0) {
139 wrapperX = wrapperX + diffWidth - 25; 138 wrapperX = wrapperX + diffWidth - 25;
140 } 139 }
  140 + $goodItemWrapper.attr('activeIndex', event.activeIndex);
141 $goodItemWrapper.css({ 141 $goodItemWrapper.css({
142 width: wrapperWidth, 142 width: wrapperWidth,
143 left: wrapperX, 143 left: wrapperX,
@@ -3,10 +3,26 @@ @@ -3,10 +3,26 @@
3 * @author: sefon 2016-7-12 15:28:22 3 * @author: sefon 2016-7-12 15:28:22
4 */ 4 */
5 5
6 -var $ = require('yoho-jquery'),  
7 - lazyLoad = require('yoho-jquery-lazyload'); 6 +var $ = require('yoho-jquery');
  7 +var yas = require('../common/data-yas');
  8 +var lazyLoad = require('yoho-jquery-lazyload');
8 9
9 -var product = require('./index/product'); 10 +
  11 +
  12 +var product = require('./index/product'),
  13 + qs = window.queryString;
  14 +
  15 +var $footPage = $('.foot-pager1').data('total'),
  16 + $productIdArr = [],
  17 + $leftUl = $('.sort-container .sort-child-list'),
  18 + $leftLi = $leftUl.find('li.active');
  19 +
  20 +
  21 +var filterValue = yas.getFilterValue();
  22 +
  23 +$('.good-info .product-id').each(function() {
  24 + $productIdArr.push($(this).html());
  25 +});
10 26
11 require('../common'); 27 require('../common');
12 require('../plugins/filter'); 28 require('../plugins/filter');
@@ -15,6 +31,55 @@ require('./detail/latest-walk'); @@ -15,6 +31,55 @@ require('./detail/latest-walk');
15 31
16 product.init(4); 32 product.init(4);
17 33
  34 +
  35 +
18 lazyLoad($('img.lazy'), { 36 lazyLoad($('img.lazy'), {
19 failure_limit: 20 37 failure_limit: 20
20 }); 38 });
  39 +
  40 +
  41 +/*
  42 + * 页面加载完
  43 + */
  44 +$(function() {
  45 + var sto = setInterval(function() {
  46 + if (window._yas && window._yas.sendCustomInfo) {
  47 + // 关键词搜索结果页展示时
  48 + yas.givePoint('YB_KEYWORD_GOODS_LIST_L', {
  49 + KEYWORD: qs.query,
  50 + RES_QTY: $footPage || 0,
  51 + PRD_LIST: $productIdArr.join(','),
  52 + PAGE_NUM: qs.pager || 1,
  53 + FILTER_VALUE: filterValue,
  54 + L1_SORT: $leftLi.length > 0 ? $leftLi.parent().prev().attr('title') : '',
  55 + L2_SORT: $leftLi.find('a').attr('title') || '',
  56 + SORT_TYPE: qs.order || 's_n_desc'
  57 + });
  58 + clearInterval(sto);
  59 + }
  60 + }, 100);
  61 +
  62 + // 点击搜索列表商品
  63 + $('.good-item-wrapper').click(function() {
  64 + var $this = $(this),
  65 + proId = $this.find('.product-id').html(),
  66 + aIndex = $this.attr('activeIndex'),
  67 + pageNum = qs.pager || 1,
  68 + limit = qs.limit || 60,
  69 + proNum = (parseInt(pageNum, 10) - 1) * limit + parseInt(aIndex, 10);
  70 +
  71 + // 点击搜索列表商品埋点
  72 + yas.givePoint('YB_KEYWORD_GOODS_LIST_C', {
  73 + KEYWORD: qs.query,
  74 + PRD_ID: proId,
  75 + PRD_NUM: proNum,
  76 + PAGE_NUM: pageNum,
  77 + FILTER_VALUE: filterValue,
  78 + L1_SORT: $leftLi.length > 0 ? $leftLi.parent().prev().attr('title') : '',
  79 + L2_SORT: $leftLi.find('a').attr('title') || '',
  80 + SORT_TYPE: qs.order || 's_n_desc'
  81 + });
  82 + });
  83 +});
  84 +
  85 +