...
|
...
|
@@ -2,16 +2,33 @@ var $ = require('yoho-jquery'), |
|
|
tip = require('../plugin/tip'),
|
|
|
Swiper = require('yoho-swiper'),
|
|
|
loading = require('../plugin/loading'),
|
|
|
debounce = require('lodash/debounce'),
|
|
|
lazyLoad = require('yoho-jquery-lazyload');
|
|
|
|
|
|
var plusstar = {},
|
|
|
$footer = $('#yoho-footer');
|
|
|
|
|
|
var windowHeight = $(window).height();
|
|
|
var scrollFn,
|
|
|
scrollTop,
|
|
|
RECPOSE,
|
|
|
CID,
|
|
|
isApp,
|
|
|
speckParamApp = {
|
|
|
udid: '',
|
|
|
apt: '',
|
|
|
sid: ''
|
|
|
};
|
|
|
|
|
|
require('../common');
|
|
|
|
|
|
plusstar = {
|
|
|
common: {
|
|
|
codeDefault: ''
|
|
|
codeDefault: '',
|
|
|
page: 1,
|
|
|
pagesize: 20,
|
|
|
pageTotal: 1,
|
|
|
productSkns: []
|
|
|
},
|
|
|
init: function() {
|
|
|
var that = this,
|
...
|
...
|
@@ -41,7 +58,31 @@ plusstar = { |
|
|
|
|
|
$(this).find('li').removeClass('focus');
|
|
|
$liDom.addClass('focus');
|
|
|
that.ParentLiDom = $liDom;// 保留当前tab先中的对象
|
|
|
that.tabNav($liDom.data('code'));
|
|
|
|
|
|
// 点击潮流优选上方的TAB按钮时
|
|
|
if (window._yas && window._yas.sendCustomInfo) {
|
|
|
window._yas.sendCustomInfo({
|
|
|
op: 'YB_FASHION_TAB_C',
|
|
|
apf: isApp,
|
|
|
ts: new Date().getTime(),
|
|
|
param: JSON.stringify($.extend(speckParamApp, {
|
|
|
C_ID: CID,
|
|
|
TAB_ID: $liDom.index() + 1
|
|
|
}))
|
|
|
}, true);
|
|
|
|
|
|
window._yas.sendCustomInfo({
|
|
|
op: 'YB_FASHION_HOME_L',
|
|
|
apf: isApp,
|
|
|
ts: new Date().getTime(),
|
|
|
param: JSON.stringify($.extend(speckParamApp, {
|
|
|
C_ID: CID,
|
|
|
TAB_ID: that.ParentLiDom.index() + 1
|
|
|
}))
|
|
|
}, true);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// start -- 默认选中
|
...
|
...
|
@@ -55,23 +96,103 @@ plusstar = { |
|
|
that.tabNav($liDom.data('code'));
|
|
|
|
|
|
// ent -- 默认选中
|
|
|
that.ParentLiDom = $liDom;// 保留当前tab先中的对象
|
|
|
setTimeout(function() {
|
|
|
that._yas();
|
|
|
}, 1000);
|
|
|
},
|
|
|
_yas: function() {
|
|
|
// http://redmine.yoho.cn/issues/12224
|
|
|
var that = this;
|
|
|
|
|
|
if (!window._yas || !window._yas.sendCustomInfo) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
RECPOSE = that.ParentLiDom.index() !== 0 ? 100015 : 100014;
|
|
|
$('.plusstar-resources').bind('click', function(event) {
|
|
|
var $dom, $domA, index;
|
|
|
|
|
|
if ($(event.target).closest('.good-info').length > 0) {
|
|
|
// 商品单击埋点
|
|
|
$dom = $(event.target).closest('.good-info');
|
|
|
index = $dom.index() + 1;
|
|
|
window.givePoint($.extend(speckParamApp, {
|
|
|
REC_POSE: RECPOSE,
|
|
|
PRD_ID: $dom.data('good-id'),
|
|
|
ORDER_CODE: '',
|
|
|
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)
|
|
|
}));
|
|
|
} 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',
|
|
|
apf: isApp,
|
|
|
ts: new Date().getTime(),
|
|
|
param: JSON.stringify($.extend(speckParamApp, {
|
|
|
C_ID: CID,
|
|
|
TAB_ID: that.ParentLiDom.index() + 1,
|
|
|
F_ID: $dom.closest('ul').data('id'),
|
|
|
F_NAME: '焦点图',
|
|
|
F_URL: $dom.find('a').attr('href'),
|
|
|
F_INDEX: 1,
|
|
|
I_INDEX: index
|
|
|
}))
|
|
|
}, true);
|
|
|
} else if ($(event.target).closest('.speck-title-image a').length > 0) {
|
|
|
// 各楼层埋点
|
|
|
$dom = $(event.target).closest('.speck-title-image');
|
|
|
$domA = $(event.target).closest('.speck-title-image a');
|
|
|
|
|
|
window._yas.sendCustomInfo({
|
|
|
op: 'YB_FASHION_FLR_C',
|
|
|
apf: isApp,
|
|
|
ts: new Date().getTime(),
|
|
|
param: JSON.stringify($.extend(speckParamApp, {
|
|
|
C_ID: CID,
|
|
|
TAB_ID: that.ParentLiDom.index() + 1,
|
|
|
F_ID: $dom.data('fid'),
|
|
|
F_NAME: $dom.data('name'),
|
|
|
F_URL: $domA.attr('href'),
|
|
|
F_INDEX: $dom.index() + 1,
|
|
|
I_INDEX: $domA.hasClass('more') ? 0 : ($domA.index() + 1)
|
|
|
}))
|
|
|
}, true);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 潮流优选首页加载时
|
|
|
window._yas.sendCustomInfo({
|
|
|
op: 'YB_FASHION_HOME_L',
|
|
|
apf: isApp,
|
|
|
ts: new Date().getTime(),
|
|
|
param: JSON.stringify($.extend(speckParamApp, {
|
|
|
C_ID: CID,
|
|
|
TAB_ID: that.ParentLiDom.index() + 1
|
|
|
}))
|
|
|
}, true);
|
|
|
},
|
|
|
tabNav: function(code) {
|
|
|
var that = this;
|
|
|
|
|
|
this.common.codeDefault = code;// 记住最后一次的tab code
|
|
|
|
|
|
loading.showLoadingMask();
|
|
|
this.common.page = 1;// 商品列表从第一页开始
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/guang/plusstar/resources-template',
|
|
|
data: {
|
|
|
code: code,
|
|
|
app_version: window.queryString.app_version || window.queryString.appVersion
|
|
|
app_version: isApp
|
|
|
},
|
|
|
dataType: 'html',
|
|
|
success: function(data) {
|
|
|
var productSkns = '';
|
|
|
|
|
|
$('.plusstar-resources').html(data);
|
|
|
|
|
|
if (data === '') {
|
...
|
...
|
@@ -81,7 +202,6 @@ plusstar = { |
|
|
|
|
|
that.resInit();
|
|
|
|
|
|
loading.hideLoadingMask();
|
|
|
lazyLoad($('img.lazy'));
|
|
|
|
|
|
// 处理左右滑动,未加载的图片
|
...
|
...
|
@@ -97,10 +217,15 @@ plusstar = { |
|
|
if (window.localStorage) {
|
|
|
$(document).scrollTop(localStorage.getItem(code) || 0);
|
|
|
}
|
|
|
|
|
|
productSkns = $(data).find('.product-skns').val();
|
|
|
|
|
|
if (productSkns) {
|
|
|
that.common.productSkns = productSkns.split(',');
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
loading.hideLoadingMask();
|
|
|
}
|
|
|
});
|
|
|
},
|
...
|
...
|
@@ -118,10 +243,95 @@ plusstar = { |
|
|
pagination: '.banner-top .pagination-inner'
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
goodsList: function() {
|
|
|
var that = this,
|
|
|
skn = [];
|
|
|
|
|
|
if (that.common.page > that.common.pageTotal) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
loading.showLoadingMask();
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/guang/plusstar/resources-goodsList',
|
|
|
timeout: 5000,
|
|
|
data: {
|
|
|
productSkn: that.common.productSkns.join(','),
|
|
|
app_version: isApp,
|
|
|
limit: that.common.pagesize,
|
|
|
page: that.common.page,
|
|
|
yh_channel: that.ParentLiDom.index() + 1
|
|
|
},
|
|
|
dataType: 'html',
|
|
|
success: function(data) {
|
|
|
skn = [];
|
|
|
loading.hideLoadingMask();
|
|
|
|
|
|
if (data === '') {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
if (that.common.page <= 1) {
|
|
|
that.common.pageTotal = $(data).siblings('.page-total').val();
|
|
|
}
|
|
|
|
|
|
$.each($(data).siblings('.good-info'), function() {
|
|
|
skn.push($(this).data('good-id'));
|
|
|
});
|
|
|
|
|
|
window.givePoint($.extend(speckParamApp, {
|
|
|
REC_POSE: RECPOSE,
|
|
|
PRD_ID: skn.join(','),
|
|
|
ORDER_CODE: '',
|
|
|
PRD_NUM: that.common.pagesize,
|
|
|
ACTION_ID: 0,
|
|
|
page_num: that.common.page++
|
|
|
}));
|
|
|
|
|
|
$('.plusstar-resources .goods').append(data);
|
|
|
|
|
|
lazyLoad($('.plusstar-resources .goods').find('img.lazy:not([src])'));
|
|
|
|
|
|
$('.resources .goods .page-total').remove();
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
loading.hideLoadingMask();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
scrollFn = debounce(function() {
|
|
|
scrollTop = $(document).scrollTop();
|
|
|
|
|
|
// 当scroll到最后一列商品的高度后继续请求下一页数据
|
|
|
if (400 + scrollTop >= $(document).height() - windowHeight) {
|
|
|
plusstar.goodsList();
|
|
|
}
|
|
|
|
|
|
if (window.localStorage) {
|
|
|
localStorage.setItem(plusstar.common.codeDefault, $(this).scrollTop());
|
|
|
}
|
|
|
|
|
|
}, 200);
|
|
|
|
|
|
$(function() {
|
|
|
isApp = (window.queryString.app_version || window.queryString.appVersion) ? true : false;
|
|
|
|
|
|
if (isApp) {
|
|
|
speckParamApp = {
|
|
|
udid: window.queryString.udid || '',
|
|
|
apt: window.queryString.client_type || '',
|
|
|
sid: window.queryString.sid || '',
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// 男:1,女:2,潮童:3,创意生活:4
|
|
|
CID = window._ChannelVary[window.cookie('_Channel')] || 1;
|
|
|
|
|
|
if (!(window.queryString.app_version || window.queryString.appVersion)) {
|
|
|
$('.tab-nav').css({
|
...
|
...
|
@@ -137,9 +347,8 @@ $(function() { |
|
|
|
|
|
plusstar.init();
|
|
|
|
|
|
if (window.localStorage) {
|
|
|
$(document).scroll(function() {
|
|
|
localStorage.setItem(plusstar.common.codeDefault, $(this).scrollTop());
|
|
|
});
|
|
|
}
|
|
|
// 滚动翻页
|
|
|
$(window).scroll(function() {
|
|
|
scrollFn();
|
|
|
});
|
|
|
}); |
...
|
...
|
|