...
|
...
|
@@ -9,6 +9,8 @@ let lazyLoad = require('yoho-jquery-lazyload'); |
|
|
|
|
|
let filter = require('plugin/filter');
|
|
|
|
|
|
let $callback = $.Callbacks(); // eslint-disable-line
|
|
|
|
|
|
new Swiper('.handpick-swiper', {
|
|
|
// Optional parameters
|
|
|
lazyLoading: true,
|
...
|
...
|
@@ -178,10 +180,14 @@ let searchView = function() { |
|
|
goods: data
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$container.append(html);
|
|
|
|
|
|
|
|
|
lazyLoad(html);
|
|
|
|
|
|
return html;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -223,7 +229,12 @@ let searchView = function() { |
|
|
searchParams.page.total = res.pageTotal;
|
|
|
searchParams.page.cur = page.cur + 1;
|
|
|
|
|
|
renderGoods($box, res.list);
|
|
|
let html = renderGoods($box, res.list);
|
|
|
|
|
|
|
|
|
$callback.fire(html, searchParams);
|
|
|
|
|
|
|
|
|
})
|
|
|
.always(() => {
|
|
|
$loading.remove();
|
...
|
...
|
@@ -274,12 +285,177 @@ let searchView = function() { |
|
|
|
|
|
return {
|
|
|
fetchNew,
|
|
|
switchNav
|
|
|
switchNav,
|
|
|
searchParams
|
|
|
};
|
|
|
};
|
|
|
|
|
|
let search = searchView();
|
|
|
|
|
|
|
|
|
|
|
|
// analysis
|
|
|
|
|
|
// 两个轮播 获取 分析的数据
|
|
|
function _swiperData($item, bool) {
|
|
|
let $img = $item.find('img');
|
|
|
let $anchor = $item.find('a');
|
|
|
|
|
|
if (bool) {
|
|
|
return {
|
|
|
IMAGE_URL: $img.attr('src') || $img.attr('data-atrr'),
|
|
|
ACTION_URL: $anchor.attr('href')
|
|
|
};
|
|
|
} else {
|
|
|
return {
|
|
|
F_URL: $anchor.attr('href')
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 楼层分析配置
|
|
|
let analysisMap = {
|
|
|
'banner-top': {
|
|
|
container: '.banner-top', // floor容器
|
|
|
item: '.swiper-slide', // floor item
|
|
|
floorInfo: {F_NAME: 'banner', F_ID: '0'}, // analysis 信息
|
|
|
|
|
|
extraAttrs: _swiperData // 从item 获取 额外字段
|
|
|
},
|
|
|
|
|
|
'new-recommend': {
|
|
|
container: '#new-recommend',
|
|
|
item: '.brand-news-count',
|
|
|
floorInfo: {F_NAME: '为您推荐', F_ID: '1'},
|
|
|
|
|
|
extraAttrs: function($item) {
|
|
|
return {
|
|
|
BRAND_ID: $item.data('brand'),
|
|
|
SHOP_ID: $item.data('shop')
|
|
|
};
|
|
|
}
|
|
|
},
|
|
|
|
|
|
handpick: {
|
|
|
container: '#handpick',
|
|
|
item: '.swiper-slide',
|
|
|
floorInfo: {F_NAME: '精选抢先看', F_ID: '2'},
|
|
|
|
|
|
extraAttrs: _swiperData
|
|
|
},
|
|
|
|
|
|
'new-goods': {
|
|
|
container: '#new-goods',
|
|
|
item: '.good-info',
|
|
|
floorInfo: {F_NAME: '最新上架', F_ID: '3'},
|
|
|
|
|
|
|
|
|
/**
|
|
|
* $item .good-info
|
|
|
* $target recommend-type 里面的<a>
|
|
|
*/
|
|
|
extraAttrs: function($item, $target) {
|
|
|
let type = $item.data('type');
|
|
|
let _attrs = {};
|
|
|
|
|
|
$target = $target instanceof $ && $target;
|
|
|
|
|
|
function tagsStr(_$item, handler, $_target) {
|
|
|
let $li;
|
|
|
|
|
|
if (!$_target) {
|
|
|
$li = _$item.find('li');
|
|
|
} else {
|
|
|
$li = $_target.closest('li');
|
|
|
}
|
|
|
|
|
|
return [].map.call($li, handler).join();
|
|
|
}
|
|
|
|
|
|
function tagIndex(arr, $_target) {
|
|
|
if ($_target) {
|
|
|
arr.L_INDEX = $_target.index();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
let handler;
|
|
|
|
|
|
switch (type) {
|
|
|
case 'guang-article':
|
|
|
_attrs = {
|
|
|
RECOMMEND_TYPE: 'fashionArticle',
|
|
|
ARTICLE_ID: $item.data('id')
|
|
|
};
|
|
|
break;
|
|
|
case 'season-tags':
|
|
|
handler = li => $(li).data('cate');
|
|
|
_attrs = {
|
|
|
RECOMMEND_TYPE: 'seasonSort',
|
|
|
CATE_ID: tagsStr($item, handler, $target)
|
|
|
};
|
|
|
|
|
|
tagIndex(_attrs, $target);
|
|
|
break;
|
|
|
case 'search-tags':
|
|
|
handler = li => $(li).find('a').text();
|
|
|
_attrs = {
|
|
|
RECOMMEND_TYPE: 'hotSearchTerm',
|
|
|
KEYWORD_WORD: tagsStr($item, handler, $target)
|
|
|
};
|
|
|
|
|
|
tagIndex(_attrs, $target);
|
|
|
break;
|
|
|
case 'hot-shop':
|
|
|
_attrs = {
|
|
|
RECOMMEND_TYPE: 'hotShop',
|
|
|
BRAND_ID: $item.data('brand'),
|
|
|
SHOP_ID: $item.data('shop')
|
|
|
};
|
|
|
break;
|
|
|
default:
|
|
|
_attrs = {
|
|
|
PRD_SKN: $item.data('id')
|
|
|
};
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if ($target) {
|
|
|
_attrs.SORT_NM = search.searchParams.order;
|
|
|
_attrs.FILTER_VALUE = search.searchParams.filter;
|
|
|
}
|
|
|
|
|
|
return _attrs;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
let analysis = require('./new/analysis');
|
|
|
let analysisWorker = require('./new/new-arrival-analysis');
|
|
|
|
|
|
|
|
|
let {analysisShowData} = analysisWorker(analysisMap, 'YB_NEW_ARRIVAL_FLR_C');
|
|
|
|
|
|
|
|
|
// 最新上架 的 每页的曝光数据,发送给yas
|
|
|
$callback.add(function(html, searchParams) {
|
|
|
let pageData = analysisShowData('new-goods', {container: $(`<div>${html}</div>`)});
|
|
|
|
|
|
pageData.SORT_NM = searchParams.order;
|
|
|
pageData.FILTER_VALUE = searchParams.filter;
|
|
|
|
|
|
analysis('YB_SHOW_NEW_ARRIVAL', {data: pageData});
|
|
|
});
|
|
|
|
|
|
$(function() {
|
|
|
setTimeout(()=> {
|
|
|
// 新品到着页面曝光时的页面数据,异步的单独发
|
|
|
analysis('YB_SHOW_NEW_ARRIVAL', {
|
|
|
data: ['banner-top', 'new-recommend', 'handpick'].map(analysisShowData)
|
|
|
});
|
|
|
}, 1000);
|
|
|
});
|
|
|
|
|
|
|
|
|
window.search = searchView();
|
|
|
window.filter = filter;
|
|
|
window.$ = $;
|
|
|
|
...
|
...
|
|