...
|
...
|
@@ -5,7 +5,7 @@ |
|
|
*/
|
|
|
|
|
|
|
|
|
var Swiper = require('yoho-swiper'),
|
|
|
var lazyLoad = require('yoho-jquery-lazyload'),
|
|
|
$ = require('yoho-jquery');
|
|
|
|
|
|
var $recommendForYou = $('.recommend-for-you'),
|
...
|
...
|
@@ -14,6 +14,40 @@ var $recommendForYou = $('.recommend-for-you'), |
|
|
end = false,
|
|
|
requesting = false;
|
|
|
|
|
|
var RECID = (new Date().getTime() + '_H5_YOHOBUY_' + Math.floor(Math.random() * 1000000 + 1000000) +
|
|
|
'_' + Math.floor(Math.random() * 1000000 + 1000000));
|
|
|
|
|
|
var getChannel, C_ID, uuidVal, goodid, goodIds = [], prdLoad;
|
|
|
|
|
|
getChannel = function functionName() {
|
|
|
var name = window.cookie('_Channel');
|
|
|
|
|
|
return {
|
|
|
boys: 1,
|
|
|
girls: 2,
|
|
|
kids: 3,
|
|
|
lifestyle: 4
|
|
|
}[name] || 1;
|
|
|
};
|
|
|
|
|
|
C_ID = getChannel();
|
|
|
|
|
|
function yasRequest(PRD_ID, PRD_NUM, ACTION_ID) {
|
|
|
if (window._yas && window._yas.sendCustomInfo) {
|
|
|
window._yas.sendCustomInfo({
|
|
|
op: 'YB_CHOOSE_FOR_YOU_Y',
|
|
|
param: JSON.stringify({
|
|
|
REC_POSE: 100013,
|
|
|
REC_ID: RECID,
|
|
|
PRD_ID: PRD_ID,
|
|
|
PRD_NUM: PRD_NUM,
|
|
|
C_ID: C_ID,
|
|
|
ACTION_ID: ACTION_ID,
|
|
|
PAGE_NUM: 1
|
|
|
})
|
|
|
}, true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function request() {
|
|
|
if (requesting || end) {
|
...
|
...
|
@@ -24,25 +58,32 @@ function request() { |
|
|
|
|
|
if (preferenceUrl) {
|
|
|
$.get(preferenceUrl).then(function(html) {
|
|
|
if ($(html).find('.swiper-slide').length < 5) {
|
|
|
$recommendForYou.hide();
|
|
|
} else {
|
|
|
$recommendForYou.html(html).show();
|
|
|
if ($('#swiper-recommend').length) {
|
|
|
new Swiper('#swiper-recommend', {
|
|
|
slidesPerView: 'auto',
|
|
|
grabCursor: true,
|
|
|
slideElement: 'a',
|
|
|
lazyLoading: true,
|
|
|
watchSlidesVisibility: true
|
|
|
});
|
|
|
$recommendForYou.html(html).show();
|
|
|
lazyLoad($recommendForYou.find('img.lazy'));
|
|
|
|
|
|
// 为你优选埋点- 加载
|
|
|
|
|
|
$('.goods-container').find('.good-info').each(function() {
|
|
|
goodid = $(this).data('good-id');
|
|
|
|
|
|
if (goodid) {
|
|
|
goodIds.push(goodid);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
prdLoad = JSON.stringify(goodIds).replace(/\[|\]|/g, '');
|
|
|
|
|
|
yasRequest(prdLoad, goodIds.length, 0);
|
|
|
|
|
|
requesting = false;
|
|
|
end = true;
|
|
|
// 点击商品
|
|
|
$('.good-info').on('click', function() {
|
|
|
var PRD_ID = $(this).data('good-id'),
|
|
|
PRD_NUM = $(this).index();
|
|
|
|
|
|
window.rePosFooter();
|
|
|
yasRequest(PRD_ID, PRD_NUM, 1);
|
|
|
|
|
|
// return false;
|
|
|
});
|
|
|
|
|
|
}).fail(function() {
|
|
|
$recommendForYou.hide();
|
...
|
...
|
@@ -59,3 +100,5 @@ function scrollHandler() { |
|
|
$(window).scroll(function() {
|
|
|
window.requestAnimationFrame(scrollHandler);
|
|
|
});
|
|
|
|
|
|
|
...
|
...
|
|