Authored by 郝肖肖

Merge branch 'feature/plusstarSpeck' into release/5.1

... ... @@ -86,6 +86,7 @@ exports.resourcesGoodsList = (req, res, next) => {
param = {
productSkn: productSkn.split(','),
limit: req.body.limit,
yh_channel: req.body.yh_channel
};
... ...
... ... @@ -51,7 +51,6 @@ const getProductBatch = (param, options) => {
method: 'h5.product.batch',
productSkn: param.productSkn.join(','),
yh_channel: param.yh_channel,
page: param.page || 1,
limit: param.limit || param.productSkn.length
}).then(result => {
let data = {};
... ...
{{#if result.product_list}}
<input type='hidden' value='{{result.page_total}}' class='page-total' />
{{/if}}
{{#each result.product_list}}
{{> common/goods}}
{{/each}}
\ No newline at end of file
... ...
var $ = require('yoho-jquery'),
tip = require('../plugin/tip'),
Swiper = require('yoho-swiper'),
loading = require('../plugin/loading'),
debounce = require('lodash/debounce');
var plusstar = {},
$footer = $('#yoho-footer');
var windowHeight = $(window).height();
var scrollFn,
scrollTop,
RECPOSE,
isApp,
searching = false,
speckParamApp = {
udid: '',
apt: '',
... ... @@ -21,6 +25,9 @@ require('../common');
plusstar = {
common: {
codeDefault: '',
page: 1,
pagesize: 20,
pageTotal: 1,
productSkns: []
},
init: function() {
... ... @@ -30,13 +37,6 @@ plusstar = {
$tabUlDom = $('.plusstar-page .tab-nav ul');
// 重置tab code位置
if (window.localStorage) {
$tabUlDom.find('li').each(function() {
localStorage.setItem($(this).data('code'), 0);
});
}
$tabUlDom.find('li').css({
width: 100 / $tabUlDom.find('li').length + '%'
});
... ... @@ -58,18 +58,16 @@ plusstar = {
if (window._yas && window._yas.sendCustomInfo) {
window._yas.sendCustomInfo({
op: 'YB_FASHION_TAB_C',
param: JSON.stringify($.extend(speckParamApp, {
TAB_ID: $liDom.index() + 1,
PRD_ID: ''
}))
param: JSON.stringify($.extend({
TAB_ID: $liDom.index() + 1
}, speckParamApp))
}, true);
window._yas.sendCustomInfo({
op: 'YB_FASHION_HOME_L',
param: JSON.stringify($.extend(speckParamApp, {
TAB_ID: that.ParentLiDom.index() + 1,
PRD_ID: ''
}))
param: JSON.stringify($.extend({
TAB_ID: that.ParentLiDom.index() + 1
}, speckParamApp))
}, true);
}
});
... ... @@ -106,28 +104,28 @@ plusstar = {
// 商品单击埋点
$dom = $(event.target).closest('.good-info');
index = $dom.index() + 1;
window.givePoint($.extend(speckParamApp, {
window.givePoint($.extend({
REC_POSE: RECPOSE,
PRD_ID: $dom.data('good-id'),
ORDER_CODE: '',
PRD_NUM: index,
ACTION_ID: 1
}));
PRD_NUM: index % that.common.pagesize === 0 ? that.common.pagesize : index % that.common.pagesize,
ACTION_ID: 1,
page_num: Math.ceil(index / that.common.pagesize)
}, speckParamApp));
} else if ($(event.target).closest('.banner-top').length > 0) {
// 头部banner楼层埋点
$dom = $(event.target).closest('li');
index = $dom.index() + 1;
window._yas.sendCustomInfo({
op: 'YB_FASHION_FLR_C',
param: JSON.stringify($.extend(speckParamApp, {
param: JSON.stringify($.extend({
TAB_ID: that.ParentLiDom.index() + 1,
F_ID: $dom.closest('ul').data('id'),
F_NAME: '焦点图',
PRD_ID: '',
F_URL: $dom.find('a').attr('href'),
F_INDEX: 1,
I_INDEX: index % 2 + 1// banner,li是双倍的
}))
}, speckParamApp))
}, true);
} else if ($(event.target).closest('.speck-title-image a').length > 0) {
// 各楼层埋点
... ... @@ -136,15 +134,14 @@ plusstar = {
window._yas.sendCustomInfo({
op: 'YB_FASHION_FLR_C',
param: JSON.stringify($.extend(speckParamApp, {
param: JSON.stringify($.extend({
TAB_ID: that.ParentLiDom.index() + 1,
F_ID: $dom.data('fid'),
PRD_ID: '',
F_NAME: $dom.data('name'),
F_URL: $domA.attr('href'),
F_INDEX: $dom.index() + 1,
I_INDEX: $domA.hasClass('more') ? 0 : ($domA.index() + 1)
}))
}, speckParamApp))
}, true);
}
});
... ... @@ -152,16 +149,16 @@ plusstar = {
// 潮流优选首页加载时
window._yas.sendCustomInfo({
op: 'YB_FASHION_HOME_L',
param: JSON.stringify($.extend(speckParamApp, {
TAB_ID: that.ParentLiDom.index() + 1,
PRD_ID: ''
}))
param: JSON.stringify($.extend({
TAB_ID: that.ParentLiDom.index() + 1
}, speckParamApp))
}, true);
},
tabNav: function(code) {
var that = this;
this.common.codeDefault = code;// 记住最后一次的tab code
this.common.page = 1;// 商品列表从第一页开始
$.ajax({
type: 'GET',
... ... @@ -185,20 +182,12 @@ plusstar = {
$('.plusstar-resources').find('img.lazy').lazyload();
// 设置滚动条的位置
if (window.localStorage) {
$(document).scrollTop(localStorage.getItem(code) || 0);
}
productSkns = $(data).find('.product-skns').val();
if (productSkns) {
that.common.productSkns = productSkns.split(',');
}
setTimeout(function() {
plusstar.goodsList();
}, 10);
that.common.pageTotal = Math.round(that.common.productSkns.length / that.common.pagesize);
},
error: function() {
tip.show('网络断开连接了~');
... ... @@ -224,18 +213,32 @@ plusstar = {
var that = this,
skn = [];
if (searching) {
return;
}
searching = true;
if (that.common.page > that.common.pageTotal) {
return false;
}
loading.showLoadingMask();
skn = that.common.productSkns.slice((that.common.page - 1) * that.common.pagesize, that.common.page * that.common.pagesize);
$.ajax({
type: 'POST',
url: '/guang/plusstar/resources-goodsList',
timeout: 5000,
data: {
productSkn: that.common.productSkns.join(','),
productSkn: skn.join(','),
app_version: isApp,
limit: that.common.pagesize,
yh_channel: that.ParentLiDom.index() + 1
},
dataType: 'html',
success: function(data) {
skn = [];
loading.hideLoadingMask();
searching = false;
if (data === '') {
return true;
... ... @@ -245,13 +248,14 @@ plusstar = {
skn.push($(this).data('good-id'));
});
window.givePoint($.extend(speckParamApp, {
window.givePoint($.extend({
REC_POSE: RECPOSE,
PRD_ID: skn.join(','),
ORDER_CODE: '',
PRD_NUM: skn.length,
ACTION_ID: 0
}));
PRD_NUM: that.common.pagesize,
ACTION_ID: 0,
page_num: that.common.page++
}, speckParamApp));
$('.plusstar-resources .goods').append(data);
... ... @@ -259,16 +263,22 @@ plusstar = {
$('.resources .goods .page-total').remove();
},
error: function() {
searching = false;
tip.show('网络断开连接了~');
loading.hideLoadingMask();
}
});
}
};
scrollFn = debounce(function() {
if (window.localStorage) {
localStorage.setItem(plusstar.common.codeDefault, $(this).scrollTop());
scrollTop = $(document).scrollTop();
// 当scroll到最后一列商品的高度后继续请求下一页数据
if (400 + scrollTop >= $(document).height() - windowHeight) {
plusstar.goodsList();
}
}, 200);
$(function() {
... ...