Authored by hongweigao

你可能喜欢埋点

... ... @@ -123,7 +123,7 @@
</div>
<div class="goods-slide">
<div data-role="recommend-slide" class="slide-panel"></div>
<div data-role="recommend-slide" class="slide-panel recommend-slider"></div>
</div>
{{/if_cond}}
... ... @@ -134,4 +134,4 @@
</div>
{{/ brandAbout}}
</div>
\ No newline at end of file
</div>
... ...
... ... @@ -22,11 +22,11 @@
</div>
<div class="goods-slide">
<div data-role="recommend-slide" class="slide-panel"></div>
<div data-role="recommend-slide" class="slide-panel recommend-slider"></div>
</div>
<div>
<textarea class="lazy-load-object-2" style="visibility: hidden;">
<script>getSearchRecommend();</script>
</textarea>
</div>
</div>{{/if}}
\ No newline at end of file
</div>{{/if}}
... ...
... ... @@ -2,7 +2,7 @@
<div class="goods-slide-item">
<ul class="goods clearfix img-list">
{{#each item}}
<li class="good img-item" data-id="id" data-skn="skn">
<li class="good img-item" data-id="{{id}}" data-skn="{{skn}}">
<a href="{{href}}" target="_blank" class="good-img">
<img class="lazy" data-original="{{img}}"/>
</a>
... ...
... ... @@ -10,10 +10,28 @@ var dataLazyLoad = require('../plugins/lazy-load')(document);
var $ = require('yoho-jquery');
var recommendTpl = require('hbs/product/good-slide.hbs');
var $recommendSlide = $('[data-role="recommend-slide"]');
var yas = require('../common/data-yas');
var $goodsIdArr = [];
require('../plugins/slider');
require('../common/center-slider');
function randomString(len) {
var $chars = 'ABCDEFGHJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-';
var maxPos = $chars.length,
pwd = '',
i;
for (i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
}
function getSearchRecommend() {
$.ajax({
... ... @@ -44,6 +62,12 @@ function getSearchRecommend() {
shownum: 5,
isCircle: true
});
$('.recommend-slider .img-item').each(function() {
$goodsIdArr.push($(this).data('id'));
});
initPageYas();
}
}
... ... @@ -52,6 +76,40 @@ function getSearchRecommend() {
window.getSearchRecommend = getSearchRecommend;
/*
* 页面加载完
*/
function initPageYas() {
var loadYas = {
REC_POSE: 100101,
REC_ID: randomString(40),
PRD_ID: $goodsIdArr.join(','),
PRD_NUM: $goodsIdArr.length,
ACTION_ID: 0,
PAGE_NUM: 1
};
// 关键词搜索结果页展示时
yas.givePoint('YB_CHOOSE_FOR_YOU_Y', loadYas);
}
// 点击你可能喜欢的商品埋点
$('.recommend-slider').on('click', '.img-item', function() {
var $this = $(this);
var proId = $this.data('id');
var loadYas = {
REC_POSE: 100101,
REC_ID: randomString(40),
PRD_ID: proId,
PRD_NUM: $goodsIdArr.indexOf(proId) + 1,
ACTION_ID: 1,
PAGE_NUM: 1
};
// 关键词搜索结果页展示时
yas.givePoint('YB_CHOOSE_FOR_YOU_Y', loadYas);
});
// 数据懒加载
dataLazyLoad.init({cls: '.lazy-load-object-2', threshold: 700});
... ...