...
|
...
|
@@ -1483,308 +1483,308 @@ require("js/product/sort-pager"); |
|
|
require("js/product/product");
|
|
|
});
|
|
|
define("js/product/filter", ["jquery"], function(require, exports, module){
|
|
|
/**
|
|
|
* 商品筛选逻辑
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/12/4
|
|
|
*/
|
|
|
|
|
|
var $ = require("jquery");
|
|
|
|
|
|
var checkUnicode = {
|
|
|
unchecked: '',
|
|
|
checked: ''
|
|
|
},
|
|
|
moreUnicode = {
|
|
|
up: '',
|
|
|
down: ''
|
|
|
};
|
|
|
|
|
|
//品牌相关变量
|
|
|
var $brandDefault = $('.brand .default'),
|
|
|
$brandPanel = $('.brand .brand-panel'),
|
|
|
$brandAttrs = $('.brand .attr'),
|
|
|
$brandMore = $('#brand-more'),
|
|
|
$brandMulti = $('#brand-multi');
|
|
|
|
|
|
var $brandMoreTxt, $brandMoreIcon;
|
|
|
|
|
|
//价格相关变量
|
|
|
var $udPrice = $('.ud-price-range'),
|
|
|
interReg = /^\d+$/,
|
|
|
$limit, $min, $max, $btn;
|
|
|
|
|
|
//分类相关变量
|
|
|
var $sortSub = $('.sort-sub-wrap');
|
|
|
|
|
|
//高级选项相关变量
|
|
|
var $seniorSubWrap = $('.senior-sub-wrap'),
|
|
|
$seniorAttrWrap = $('.senior-attr-wrap');
|
|
|
|
|
|
var seniorHoverTime, hoveredIndex;
|
|
|
|
|
|
//清除checkbox选中状态
|
|
|
function clearChecked($checkbox) {
|
|
|
$checkbox.removeClass('checked').html(checkUnicode.unchecked);
|
|
|
}
|
|
|
|
|
|
//显示更多品牌面板
|
|
|
function brandShowMore() {
|
|
|
$brandDefault.addClass('hide');
|
|
|
$brandPanel.removeClass('hide');
|
|
|
}
|
|
|
|
|
|
//隐藏更多品牌面板
|
|
|
function brandHideMore() {
|
|
|
$brandPanel.addClass('hide');
|
|
|
$brandDefault.removeClass('hide');
|
|
|
}
|
|
|
|
|
|
//url构造&跳转
|
|
|
function uriLoc(attr, val) {
|
|
|
var href = decodeURIComponent(window.location.search),
|
|
|
query = attr + '=' + val,
|
|
|
newHref;
|
|
|
|
|
|
if (href === '') {
|
|
|
newHref = '?' + query;
|
|
|
} else {
|
|
|
newHref = href + '&' + query;
|
|
|
}
|
|
|
|
|
|
window.location.href = newHref;
|
|
|
}
|
|
|
|
|
|
//隐藏高级选项面板
|
|
|
function hideSeniorPanel(index) {
|
|
|
$seniorSubWrap.children('.senior-sub:eq(' + hoveredIndex + ')').addClass('hide');
|
|
|
$seniorAttrWrap.children('.attr:eq(' + hoveredIndex + ')').removeClass('hover');
|
|
|
hoveredIndex = -1;
|
|
|
}
|
|
|
|
|
|
//屏蔽筛选项双击文字选中
|
|
|
$('.filter-box').on('selectstart', '.attr, .brands-index span', function() {
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
//【分类】
|
|
|
$('.sort-pre').on('click', 'li', function() {
|
|
|
var $this = $(this),
|
|
|
index = $this.index();
|
|
|
|
|
|
$this.siblings('.active').removeClass('active');
|
|
|
$this.addClass('active');
|
|
|
|
|
|
$sortSub.children(':not(.hide)').addClass('hide');
|
|
|
$sortSub.children(':eq(' + index + ')').removeClass('hide');
|
|
|
});
|
|
|
|
|
|
//【品牌】
|
|
|
if ($brandMore.length > 0) {
|
|
|
$brandMoreTxt = $brandMore.children('em');
|
|
|
$brandMoreIcon = $brandMore.children('.iconfont');
|
|
|
}
|
|
|
|
|
|
//【品牌】多选
|
|
|
$brandMulti.click(function() {
|
|
|
if ($brandPanel.css('display') === 'none') {
|
|
|
|
|
|
//显示品牌面板
|
|
|
brandShowMore();
|
|
|
}
|
|
|
|
|
|
$brandPanel.addClass('multi'); //显示出checkbox
|
|
|
$(this).addClass('hide');
|
|
|
});
|
|
|
|
|
|
//【品牌】更多
|
|
|
$brandMore.click(function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
if ($this.hasClass('more')) {
|
|
|
brandHideMore();
|
|
|
|
|
|
$brandMoreTxt.text('更多');
|
|
|
$brandMoreIcon.html(moreUnicode.down);
|
|
|
} else {
|
|
|
brandShowMore();
|
|
|
|
|
|
$brandMoreTxt.text('收起');
|
|
|
$brandMoreIcon.html(moreUnicode.up);
|
|
|
}
|
|
|
|
|
|
$(this).toggleClass('more');
|
|
|
});
|
|
|
|
|
|
//【品牌】索引
|
|
|
$('.brands-index').on('click', 'span', function() {
|
|
|
var $this = $(this),
|
|
|
index = $this.data('index');
|
|
|
|
|
|
if ($this.index() === 0) {
|
|
|
|
|
|
//全部
|
|
|
$brandAttrs.removeClass('hide');
|
|
|
} else {
|
|
|
$brandAttrs.addClass('hide').filter('[data-index=' + index + ']').removeClass('hide');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//【品牌】搜索
|
|
|
$('#brand-search-input').keyup(function() {
|
|
|
var val = $(this).val().toLowerCase();
|
|
|
|
|
|
if (val === '') {
|
|
|
$brandAttrs.removeClass('hide');
|
|
|
} else {
|
|
|
$brandAttrs.addClass('hide').filter('[data-key*="' + val + '"]').removeClass('hide');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//【品牌】多选确定
|
|
|
$('#brand-multi-ok').click(function() {
|
|
|
var val = '';
|
|
|
|
|
|
if ($(this).hasClass('dis')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$brandPanel.find('.checked').each(function() {
|
|
|
var id = $(this).data('id');
|
|
|
|
|
|
val += (val === '') ? id : (',' + id);
|
|
|
});
|
|
|
|
|
|
uriLoc('brand', val);
|
|
|
});
|
|
|
|
|
|
//【品牌/高级选项】多选取消
|
|
|
$('.multi-select-cancel').click(function() {
|
|
|
var $panel = $(this).closest('.multi');
|
|
|
|
|
|
if ($panel.hasClass('brand-panel')) {
|
|
|
brandHideMore();
|
|
|
|
|
|
$brandMulti.removeClass('hide'); //显示多选按钮
|
|
|
}
|
|
|
|
|
|
$panel.removeClass('multi');
|
|
|
clearChecked($panel.find('.checkbox.checked')); //清除选中状态
|
|
|
});
|
|
|
|
|
|
//【品牌/高级选项】checkbox
|
|
|
$('.check-container').on('click', '.attr', function() {
|
|
|
var $this = $(this),
|
|
|
$check = $this.find('.checkbox'),
|
|
|
$btnOk = $this.parent('.check-container').next('.btns').find('.multi-select-ok');
|
|
|
|
|
|
$check.toggleClass('checked');
|
|
|
|
|
|
if ($check.hasClass('checked')) {
|
|
|
$check.html(checkUnicode.checked);
|
|
|
} else {
|
|
|
$check.html(checkUnicode.unchecked);
|
|
|
}
|
|
|
|
|
|
//更新按钮状态
|
|
|
if ($check.hasClass('checked') ||
|
|
|
$this.siblings('.attr').find('.checked').length > 0) {
|
|
|
$btnOk.removeClass('dis');
|
|
|
} else {
|
|
|
$btnOk.addClass('dis');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//【品牌/高级选项】当多选时阻止链接默认跳转
|
|
|
$('.brand, .senior').on('click', '.attr > a', function(e) {
|
|
|
if ($(this).closest('.multi').length > 0) {
|
|
|
e.preventDefault();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//【价格】用户定义价格处理
|
|
|
if ($udPrice.length > 0) {
|
|
|
$limit = $udPrice.find('.limit');
|
|
|
$min = $limit.filter('.min');
|
|
|
$max = $limit.filter('.max');
|
|
|
$btn = $udPrice.find('.price-sure');
|
|
|
|
|
|
//【价格】输入
|
|
|
$limit.keyup(function() {
|
|
|
var min = $.trim($min.val()),
|
|
|
max = $.trim($max.val()),
|
|
|
isMinInt = interReg.test(min),
|
|
|
isMaxInt = interReg.test(max);
|
|
|
|
|
|
if (isMaxInt && (min === '' || isMinInt) ||
|
|
|
isMinInt && (max === '' || isMaxInt)
|
|
|
) {
|
|
|
$btn.removeClass('hide');
|
|
|
} else {
|
|
|
$btn.addClass('hide');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//【价格】多项查询
|
|
|
$btn.click(function() {
|
|
|
var min = $.trim($min.val()),
|
|
|
max = $.trim($max.val()),
|
|
|
tmp;
|
|
|
|
|
|
//对于min大于max的情况,交换位置
|
|
|
if (min !== '' && max !== '' && +min > +max) {
|
|
|
tmp = max;
|
|
|
max = min;
|
|
|
min = tmp;
|
|
|
}
|
|
|
|
|
|
uriLoc('price', min + ',' + max);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//【高级选项】鼠标移入显示子项
|
|
|
$seniorAttrWrap.on('mouseenter', '.attr', function() {
|
|
|
var $this = $(this);
|
|
|
var index = $this.index();
|
|
|
|
|
|
$this.addClass('hover').siblings().removeClass('hover');
|
|
|
|
|
|
$seniorSubWrap.children('.senior-sub:eq(' + index + ')').removeClass('hide').siblings().addClass('hide');
|
|
|
}).on('mouseleave', '.attr', function() {
|
|
|
var $this = $(this),
|
|
|
index = $this.index();
|
|
|
|
|
|
hoveredIndex = index;
|
|
|
|
|
|
seniorHoverTime = setTimeout(function() {
|
|
|
hideSeniorPanel();
|
|
|
}, 100);
|
|
|
});
|
|
|
|
|
|
//【高级选项】多选
|
|
|
$('.senior-sub').on('click', '.multi-select', function() {
|
|
|
$(this).closest('.senior-sub').addClass('multi');
|
|
|
}).on('click', '.multi-select-ok', function() {
|
|
|
var $btn = $(this),
|
|
|
$sub = $btn.closest('.senior-sub'),
|
|
|
val = '';
|
|
|
|
|
|
if ($btn.hasClass('dis')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$sub.find('.checked').each(function() {
|
|
|
var id = $(this).data('id');
|
|
|
|
|
|
val += (val === '') ? id : (',' + id);
|
|
|
});
|
|
|
|
|
|
uriLoc($sub.data('attr'), val);
|
|
|
}).on('mouseenter', function() {
|
|
|
clearTimeout(seniorHoverTime);
|
|
|
}).on('mouseleave', function() {
|
|
|
hideSeniorPanel();
|
|
|
});
|
|
|
/**
|
|
|
* 商品筛选逻辑
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/12/4
|
|
|
*/
|
|
|
|
|
|
var $ = require("jquery");
|
|
|
|
|
|
var checkUnicode = {
|
|
|
unchecked: '',
|
|
|
checked: ''
|
|
|
},
|
|
|
moreUnicode = {
|
|
|
up: '',
|
|
|
down: ''
|
|
|
};
|
|
|
|
|
|
//品牌相关变量
|
|
|
var $brandDefault = $('.brand .default'),
|
|
|
$brandPanel = $('.brand .brand-panel'),
|
|
|
$brandAttrs = $('.brand .attr'),
|
|
|
$brandMore = $('#brand-more'),
|
|
|
$brandMulti = $('#brand-multi');
|
|
|
|
|
|
var $brandMoreTxt, $brandMoreIcon;
|
|
|
|
|
|
//价格相关变量
|
|
|
var $udPrice = $('.ud-price-range'),
|
|
|
interReg = /^\d+$/,
|
|
|
$limit, $min, $max, $btn;
|
|
|
|
|
|
//分类相关变量
|
|
|
var $sortSub = $('.sort-sub-wrap');
|
|
|
|
|
|
//高级选项相关变量
|
|
|
var $seniorSubWrap = $('.senior-sub-wrap'),
|
|
|
$seniorAttrWrap = $('.senior-attr-wrap');
|
|
|
|
|
|
var seniorHoverTime, hoveredIndex;
|
|
|
|
|
|
//清除checkbox选中状态
|
|
|
function clearChecked($checkbox) {
|
|
|
$checkbox.removeClass('checked').html(checkUnicode.unchecked);
|
|
|
}
|
|
|
|
|
|
//显示更多品牌面板
|
|
|
function brandShowMore() {
|
|
|
$brandDefault.addClass('hide');
|
|
|
$brandPanel.removeClass('hide');
|
|
|
}
|
|
|
|
|
|
//隐藏更多品牌面板
|
|
|
function brandHideMore() {
|
|
|
$brandPanel.addClass('hide');
|
|
|
$brandDefault.removeClass('hide');
|
|
|
}
|
|
|
|
|
|
//url构造&跳转
|
|
|
function uriLoc(attr, val) {
|
|
|
var href = decodeURIComponent(window.location.search),
|
|
|
query = attr + '=' + val,
|
|
|
newHref;
|
|
|
|
|
|
if (href === '') {
|
|
|
newHref = '?' + query;
|
|
|
} else {
|
|
|
newHref = href + '&' + query;
|
|
|
}
|
|
|
|
|
|
window.location.href = newHref;
|
|
|
}
|
|
|
|
|
|
//隐藏高级选项面板
|
|
|
function hideSeniorPanel(index) {
|
|
|
$seniorSubWrap.children('.senior-sub:eq(' + hoveredIndex + ')').addClass('hide');
|
|
|
$seniorAttrWrap.children('.attr:eq(' + hoveredIndex + ')').removeClass('hover');
|
|
|
hoveredIndex = -1;
|
|
|
}
|
|
|
|
|
|
//屏蔽筛选项双击文字选中
|
|
|
$('.filter-box').on('selectstart', '.attr, .brands-index span', function() {
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
//【分类】
|
|
|
$('.sort-pre').on('click', 'li', function() {
|
|
|
var $this = $(this),
|
|
|
index = $this.index();
|
|
|
|
|
|
$this.siblings('.active').removeClass('active');
|
|
|
$this.addClass('active');
|
|
|
|
|
|
$sortSub.children(':not(.hide)').addClass('hide');
|
|
|
$sortSub.children(':eq(' + index + ')').removeClass('hide');
|
|
|
});
|
|
|
|
|
|
//【品牌】
|
|
|
if ($brandMore.length > 0) {
|
|
|
$brandMoreTxt = $brandMore.children('em');
|
|
|
$brandMoreIcon = $brandMore.children('.iconfont');
|
|
|
}
|
|
|
|
|
|
//【品牌】多选
|
|
|
$brandMulti.click(function() {
|
|
|
if ($brandPanel.css('display') === 'none') {
|
|
|
|
|
|
//显示品牌面板
|
|
|
$brandMore.trigger('click');
|
|
|
}
|
|
|
|
|
|
$brandPanel.addClass('multi'); //显示出checkbox
|
|
|
$(this).addClass('hide');
|
|
|
});
|
|
|
|
|
|
//【品牌】更多
|
|
|
$brandMore.click(function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
if ($this.hasClass('more')) {
|
|
|
brandHideMore();
|
|
|
|
|
|
$brandMoreTxt.text('更多');
|
|
|
$brandMoreIcon.html(moreUnicode.down);
|
|
|
} else {
|
|
|
brandShowMore();
|
|
|
|
|
|
$brandMoreTxt.text('收起');
|
|
|
$brandMoreIcon.html(moreUnicode.up);
|
|
|
}
|
|
|
|
|
|
$(this).toggleClass('more');
|
|
|
});
|
|
|
|
|
|
//【品牌】索引
|
|
|
$('.brands-index').on('click', 'span', function() {
|
|
|
var $this = $(this),
|
|
|
index = $this.data('index');
|
|
|
|
|
|
if ($this.index() === 0) {
|
|
|
|
|
|
//全部
|
|
|
$brandAttrs.removeClass('hide');
|
|
|
} else {
|
|
|
$brandAttrs.addClass('hide').filter('[data-index=' + index + ']').removeClass('hide');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//【品牌】搜索
|
|
|
$('#brand-search-input').keyup(function() {
|
|
|
var val = $(this).val().toLowerCase();
|
|
|
|
|
|
if (val === '') {
|
|
|
$brandAttrs.removeClass('hide');
|
|
|
} else {
|
|
|
$brandAttrs.addClass('hide').filter('[data-key*="' + val + '"]').removeClass('hide');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//【品牌】多选确定
|
|
|
$('#brand-multi-ok').click(function() {
|
|
|
var val = '';
|
|
|
|
|
|
if ($(this).hasClass('dis')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$brandPanel.find('.checked').each(function() {
|
|
|
var id = $(this).data('id');
|
|
|
|
|
|
val += (val === '') ? id : (',' + id);
|
|
|
});
|
|
|
|
|
|
uriLoc('brand', val);
|
|
|
});
|
|
|
|
|
|
//【品牌/高级选项】多选取消
|
|
|
$('.multi-select-cancel').click(function() {
|
|
|
var $panel = $(this).closest('.multi');
|
|
|
|
|
|
if ($panel.hasClass('brand-panel')) {
|
|
|
|
|
|
$brandMulti.removeClass('hide'); //显示多选按钮
|
|
|
$brandMore.trigger('click');
|
|
|
}
|
|
|
|
|
|
$panel.removeClass('multi');
|
|
|
clearChecked($panel.find('.checkbox.checked')); //清除选中状态
|
|
|
});
|
|
|
|
|
|
//【品牌/高级选项】checkbox
|
|
|
$('.check-container').on('click', '.attr', function() {
|
|
|
var $this = $(this),
|
|
|
$check = $this.find('.checkbox'),
|
|
|
$btnOk = $this.parent('.check-container').next('.btns').find('.multi-select-ok');
|
|
|
|
|
|
$check.toggleClass('checked');
|
|
|
|
|
|
if ($check.hasClass('checked')) {
|
|
|
$check.html(checkUnicode.checked);
|
|
|
} else {
|
|
|
$check.html(checkUnicode.unchecked);
|
|
|
}
|
|
|
|
|
|
//更新按钮状态
|
|
|
if ($check.hasClass('checked') ||
|
|
|
$this.siblings('.attr').find('.checked').length > 0) {
|
|
|
$btnOk.removeClass('dis');
|
|
|
} else {
|
|
|
$btnOk.addClass('dis');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//【品牌/高级选项】当多选时阻止链接默认跳转
|
|
|
$('.brand, .senior').on('click', '.attr > a', function(e) {
|
|
|
if ($(this).closest('.multi').length > 0) {
|
|
|
e.preventDefault();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//【价格】用户定义价格处理
|
|
|
if ($udPrice.length > 0) {
|
|
|
$limit = $udPrice.find('.limit');
|
|
|
$min = $limit.filter('.min');
|
|
|
$max = $limit.filter('.max');
|
|
|
$btn = $udPrice.find('.price-sure');
|
|
|
|
|
|
//【价格】输入
|
|
|
$limit.keyup(function() {
|
|
|
var min = $.trim($min.val()),
|
|
|
max = $.trim($max.val()),
|
|
|
isMinInt = interReg.test(min),
|
|
|
isMaxInt = interReg.test(max);
|
|
|
|
|
|
if (isMaxInt && (min === '' || isMinInt) ||
|
|
|
isMinInt && (max === '' || isMaxInt)
|
|
|
) {
|
|
|
$btn.removeClass('hide');
|
|
|
} else {
|
|
|
$btn.addClass('hide');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//【价格】多项查询
|
|
|
$btn.click(function() {
|
|
|
var min = $.trim($min.val()),
|
|
|
max = $.trim($max.val()),
|
|
|
tmp;
|
|
|
|
|
|
//对于min大于max的情况,交换位置
|
|
|
if (min !== '' && max !== '' && +min > +max) {
|
|
|
tmp = max;
|
|
|
max = min;
|
|
|
min = tmp;
|
|
|
}
|
|
|
|
|
|
uriLoc('price', min + ',' + max);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//【高级选项】鼠标移入显示子项
|
|
|
$seniorAttrWrap.on('mouseenter', '.attr', function() {
|
|
|
var $this = $(this);
|
|
|
var index = $this.index();
|
|
|
|
|
|
$this.addClass('hover').siblings().removeClass('hover');
|
|
|
|
|
|
$seniorSubWrap.children('.senior-sub:eq(' + index + ')').removeClass('hide').siblings().addClass('hide');
|
|
|
}).on('mouseleave', '.attr', function() {
|
|
|
var $this = $(this),
|
|
|
index = $this.index();
|
|
|
|
|
|
hoveredIndex = index;
|
|
|
|
|
|
seniorHoverTime = setTimeout(function() {
|
|
|
hideSeniorPanel();
|
|
|
}, 100);
|
|
|
});
|
|
|
|
|
|
//【高级选项】多选
|
|
|
$('.senior-sub').on('click', '.multi-select', function() {
|
|
|
$(this).closest('.senior-sub').addClass('multi');
|
|
|
}).on('click', '.multi-select-ok', function() {
|
|
|
var $btn = $(this),
|
|
|
$sub = $btn.closest('.senior-sub'),
|
|
|
val = '';
|
|
|
|
|
|
if ($btn.hasClass('dis')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$sub.find('.checked').each(function() {
|
|
|
var id = $(this).data('id');
|
|
|
|
|
|
val += (val === '') ? id : (',' + id);
|
|
|
});
|
|
|
|
|
|
uriLoc($sub.data('attr'), val);
|
|
|
}).on('mouseenter', function() {
|
|
|
clearTimeout(seniorHoverTime);
|
|
|
}).on('mouseleave', function() {
|
|
|
hideSeniorPanel();
|
|
|
});
|
|
|
|
|
|
});
|
|
|
define("js/product/sort-pager", ["jquery"], function(require, exports, module){
|
...
|
...
|
@@ -2658,6 +2658,13 @@ require("js/common/logo-brand"); |
|
|
|
|
|
require("js/common/accordion");
|
|
|
|
|
|
$(document).on('mouseenter', '.imgopacity a img', function() {
|
|
|
$(this).css('opacity', 0.8);
|
|
|
});
|
|
|
$(document).on('mouseout', '.imgopacity a img', function() {
|
|
|
$(this).css('opacity', 1);
|
|
|
});
|
|
|
|
|
|
if (homePage === 'brands') {
|
|
|
require("js/home/brands");
|
|
|
}
|
...
|
...
|
@@ -3586,235 +3593,235 @@ $brand.hover(function() { |
|
|
|
|
|
});
|
|
|
define("js/common/new-arrivls", ["jquery","lazyload","handlebars","source-map"], function(require, exports, module){
|
|
|
var $ = require("jquery"),
|
|
|
lazyload = require("lazyload");
|
|
|
var Handlebars = require("handlebars");
|
|
|
|
|
|
function InfiniteLoad(options) {
|
|
|
var defaults = {
|
|
|
index: 0,
|
|
|
isload: true,//是否正在加载
|
|
|
isrun: true,//判断是否执行
|
|
|
offset: {
|
|
|
height: null,
|
|
|
width: null
|
|
|
}
|
|
|
};
|
|
|
|
|
|
this.registerEvent = {
|
|
|
before: [],
|
|
|
change: [],
|
|
|
after: []
|
|
|
};
|
|
|
|
|
|
this.options = $.extend(true, {}, defaults, options);
|
|
|
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
InfiniteLoad.prototype.on = function(name, callback) {
|
|
|
var g = this;
|
|
|
var _e = g.registerEvent[name];
|
|
|
|
|
|
if (_e) {
|
|
|
_e.push(callback);
|
|
|
}
|
|
|
return _e;
|
|
|
};
|
|
|
|
|
|
InfiniteLoad.prototype.exect = function(key, params) {
|
|
|
var g = this;
|
|
|
var e;
|
|
|
|
|
|
if (g.registerEvent[key] && g.registerEvent[key].length > 0) {
|
|
|
for (e in g.registerEvent[key]) {
|
|
|
if (g.registerEvent[key].hasOwnProperty(e)) {
|
|
|
g.registerEvent[key][e](params);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
InfiniteLoad.prototype.init = function() {
|
|
|
var g = this;
|
|
|
var p = this.options;
|
|
|
|
|
|
function __loadMore() {
|
|
|
|
|
|
if (p.isrun && p.isload && g.__directionCalculation()) {
|
|
|
p.isload = false;
|
|
|
p.index++;
|
|
|
g.exect('after', p);
|
|
|
}
|
|
|
|
|
|
g.exect('change', p);
|
|
|
}
|
|
|
|
|
|
g.exect('before', p);
|
|
|
|
|
|
$(window).scroll(__loadMore);
|
|
|
};
|
|
|
|
|
|
InfiniteLoad.prototype.emit = function() {
|
|
|
var p = this.options;
|
|
|
|
|
|
p.isload = true;
|
|
|
};
|
|
|
|
|
|
InfiniteLoad.prototype.stop = function() {
|
|
|
var p = this.options;
|
|
|
|
|
|
p.isrun = false;
|
|
|
p.isload = false;
|
|
|
};
|
|
|
|
|
|
InfiniteLoad.prototype.__directionCalculation = function() {
|
|
|
var p = this.options;
|
|
|
|
|
|
if (p.offset.height && p.offset.height() > 0 && $(window).scrollTop() + $(window).height() >= p.offset.height()) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
};
|
|
|
|
|
|
module.exports = function(data) {
|
|
|
var $container = $('#newarrivals .goods-container');
|
|
|
var $load = $('.loading a');
|
|
|
var load = new InfiniteLoad({
|
|
|
index: 1,
|
|
|
isload: false,
|
|
|
offset: {
|
|
|
height: function() {
|
|
|
return parseFloat($container.offset().top) + parseFloat($container.height()) - 200;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
var loadAjax;
|
|
|
var url = data.url,
|
|
|
count = data.count,
|
|
|
rows = data.rows;
|
|
|
|
|
|
data.pageIndex = 0;
|
|
|
|
|
|
delete data.url;
|
|
|
delete data.count;
|
|
|
delete data.rows;
|
|
|
|
|
|
loadAjax = function(url, data, count) {
|
|
|
|
|
|
var options = {
|
|
|
type: 'POST',
|
|
|
url: url,
|
|
|
success: function(result) {
|
|
|
var code = result.code;
|
|
|
var myTemplate,len,pos;
|
|
|
|
|
|
if (code === 200) {
|
|
|
len = result.goods.length % count;
|
|
|
pos = result.goods.length - len - 1;
|
|
|
|
|
|
result.goods.splice(pos, len);
|
|
|
|
|
|
myTemplate = Handlebars.compile(load.tpl);
|
|
|
|
|
|
$container.append(myTemplate(result.goods));
|
|
|
data.pageIndex = data.pageIndex + result.goods.length;
|
|
|
|
|
|
//懒加载插件貌似有点问题,图片先直接展示
|
|
|
lazyload($container.find('img.lazy'));
|
|
|
|
|
|
load.emit();
|
|
|
} else {
|
|
|
|
|
|
load.stop();
|
|
|
$load.html('查看更多');
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
|
|
|
load.stop();
|
|
|
$load.html('网络断开连接了~');
|
|
|
}
|
|
|
};
|
|
|
|
|
|
options.data = data;
|
|
|
$.ajax(options);
|
|
|
};
|
|
|
|
|
|
|
|
|
load.on('after', function(p) {
|
|
|
|
|
|
data.pageCount = count * rows[1];
|
|
|
|
|
|
loadAjax(url, data);
|
|
|
});
|
|
|
|
|
|
load.on('before', function(p) {
|
|
|
|
|
|
|
|
|
load.tpl = '{{#each this}}';
|
|
|
load.tpl += '<div class="good-info" data-skn="{{skn}}">';
|
|
|
load.tpl += ' <div class="tag-container clearfix">';
|
|
|
load.tpl += ' {{# tags}}';
|
|
|
load.tpl += ' {{# isNew}}';
|
|
|
load.tpl += ' <span class="good-tag new-tag">NEW</span>';
|
|
|
load.tpl += ' {{/ isNew}}';
|
|
|
load.tpl += ' {{# isReNew}}';
|
|
|
load.tpl += ' <span class="good-tag renew-tag">再到着</span>';
|
|
|
load.tpl += ' {{/ isReNew}}';
|
|
|
load.tpl += ' {{# isSale}}';
|
|
|
load.tpl += ' <span class="good-tag sale-tag">SALE</span>';
|
|
|
load.tpl += ' {{/ isSale}}';
|
|
|
load.tpl += ' {{# isNewFestival}}';
|
|
|
load.tpl += ' <span class="good-tag new-festival-tag">新品节</span>';
|
|
|
load.tpl += ' {{/ isNewFestival}}';
|
|
|
load.tpl += ' {{# isLimit}}';
|
|
|
load.tpl += ' <span class="good-tag limit-tag">限量商品</span>';
|
|
|
load.tpl += ' {{/ isLimit}}';
|
|
|
load.tpl += ' {{# isYearEndPromotion}}';
|
|
|
load.tpl += ' <span class="good-tag yep-tag">年终大促</span>';
|
|
|
load.tpl += ' {{/ isYearEndPromotion}}';
|
|
|
load.tpl += ' {{# isYearMidPromotion}}';
|
|
|
load.tpl += ' <span class="good-tag ymp-tag">年中热促</span>';
|
|
|
load.tpl += ' {{/ isYearMidPromotion}}';
|
|
|
load.tpl += ' {{/ tags}}';
|
|
|
load.tpl += ' </div>';
|
|
|
load.tpl += ' <div class="good-detail-img">';
|
|
|
load.tpl += ' <a class="good-thumb" href="{{url}}" target= "_blank">';
|
|
|
load.tpl += ' <img class="lazy" data-original="{{thumb}}">';
|
|
|
load.tpl += ' </a>';
|
|
|
load.tpl += ' {{# isFew}}';
|
|
|
load.tpl += ' <p class="few-tag">即将售罄</p>';
|
|
|
load.tpl += ' {{/ isFew}}';
|
|
|
|
|
|
load.tpl += ' {{#if showColBtn}}';
|
|
|
load.tpl += ' <span class="col-btn iconfont{{#if coled}} coled{{/if}}"></span>';
|
|
|
load.tpl += ' {{/if}}';
|
|
|
load.tpl += ' </div>';
|
|
|
load.tpl += ' <div class="good-detail-text">';
|
|
|
load.tpl += ' <a href="{{url}}" target= "_blank">{{name}}</a>';
|
|
|
load.tpl += ' <p class="price">';
|
|
|
load.tpl += ' <span class="sale-price{{#unless marketPrice}}prime-cost{{/unless}}">';
|
|
|
load.tpl += ' ¥{{salePrice}}';
|
|
|
load.tpl += ' </span>';
|
|
|
load.tpl += ' {{# marketPrice}}';
|
|
|
load.tpl += ' <span class="market-price">¥{{.}}</span>';
|
|
|
load.tpl += ' {{/ marketPrice}}';
|
|
|
load.tpl += ' </p>';
|
|
|
load.tpl += ' </div>';
|
|
|
load.tpl += '</div>';
|
|
|
load.tpl += '{{/each}}';
|
|
|
|
|
|
|
|
|
data.pageCount = count * rows[0];
|
|
|
|
|
|
loadAjax(url, data, data.count);
|
|
|
|
|
|
//load.emit();
|
|
|
});
|
|
|
|
|
|
load.init();
|
|
|
|
|
|
var $ = require("jquery"),
|
|
|
lazyload = require("lazyload");
|
|
|
var Handlebars = require("handlebars");
|
|
|
|
|
|
function InfiniteLoad(options) {
|
|
|
var defaults = {
|
|
|
index: 0,
|
|
|
isload: true,//是否正在加载
|
|
|
isrun: true,//判断是否执行
|
|
|
offset: {
|
|
|
height: null,
|
|
|
width: null
|
|
|
}
|
|
|
};
|
|
|
|
|
|
this.registerEvent = {
|
|
|
before: [],
|
|
|
change: [],
|
|
|
after: []
|
|
|
};
|
|
|
|
|
|
this.options = $.extend(true, {}, defaults, options);
|
|
|
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
InfiniteLoad.prototype.on = function(name, callback) {
|
|
|
var g = this;
|
|
|
var _e = g.registerEvent[name];
|
|
|
|
|
|
if (_e) {
|
|
|
_e.push(callback);
|
|
|
}
|
|
|
return _e;
|
|
|
};
|
|
|
|
|
|
InfiniteLoad.prototype.exect = function(key, params) {
|
|
|
var g = this;
|
|
|
var e;
|
|
|
|
|
|
if (g.registerEvent[key] && g.registerEvent[key].length > 0) {
|
|
|
for (e in g.registerEvent[key]) {
|
|
|
if (g.registerEvent[key].hasOwnProperty(e)) {
|
|
|
g.registerEvent[key][e](params);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
InfiniteLoad.prototype.init = function() {
|
|
|
var g = this;
|
|
|
var p = this.options;
|
|
|
|
|
|
function __loadMore() {
|
|
|
|
|
|
if (p.isrun && p.isload && g.__directionCalculation()) {
|
|
|
p.isload = false;
|
|
|
p.index++;
|
|
|
g.exect('after', p);
|
|
|
}
|
|
|
|
|
|
g.exect('change', p);
|
|
|
}
|
|
|
|
|
|
g.exect('before', p);
|
|
|
|
|
|
$(window).scroll(__loadMore);
|
|
|
};
|
|
|
|
|
|
InfiniteLoad.prototype.emit = function() {
|
|
|
var p = this.options;
|
|
|
|
|
|
p.isload = true;
|
|
|
};
|
|
|
|
|
|
InfiniteLoad.prototype.stop = function() {
|
|
|
var p = this.options;
|
|
|
|
|
|
p.isrun = false;
|
|
|
p.isload = false;
|
|
|
};
|
|
|
|
|
|
InfiniteLoad.prototype.__directionCalculation = function() {
|
|
|
var p = this.options;
|
|
|
|
|
|
if (p.offset.height && p.offset.height() > 0 && $(window).scrollTop() + $(window).height() >= p.offset.height()) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
};
|
|
|
|
|
|
module.exports = function(data) {
|
|
|
var $container = $('#newarrivals .goods-container');
|
|
|
var $load = $('.loading a');
|
|
|
var load = new InfiniteLoad({
|
|
|
index: 1,
|
|
|
isload: false,
|
|
|
offset: {
|
|
|
height: function() {
|
|
|
return parseFloat($container.offset().top) + parseFloat($container.height()) - 200;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
var loadAjax;
|
|
|
var url = data.url,
|
|
|
count = data.count,
|
|
|
rows = data.rows;
|
|
|
|
|
|
data.pageIndex = 0;
|
|
|
|
|
|
delete data.url;
|
|
|
delete data.count;
|
|
|
delete data.rows;
|
|
|
|
|
|
loadAjax = function(url, data, count) {
|
|
|
|
|
|
var options = {
|
|
|
type: 'POST',
|
|
|
url: url,
|
|
|
success: function(result) {
|
|
|
var code = result.code;
|
|
|
var myTemplate,len,pos;
|
|
|
|
|
|
if (code === 200) {
|
|
|
len = result.goods.length % count;
|
|
|
pos = result.goods.length - len - 1;
|
|
|
|
|
|
result.goods.splice(pos, len);
|
|
|
|
|
|
myTemplate = Handlebars.compile(load.tpl);
|
|
|
|
|
|
$container.append(myTemplate(result.goods));
|
|
|
data.pageIndex = data.pageIndex + result.goods.length;
|
|
|
|
|
|
//懒加载插件貌似有点问题,图片先直接展示
|
|
|
lazyload($container.find('img.lazy'));
|
|
|
|
|
|
load.emit();
|
|
|
} else {
|
|
|
|
|
|
load.stop();
|
|
|
$load.html('查看更多');
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
|
|
|
load.stop();
|
|
|
$load.html('网络断开连接了~');
|
|
|
}
|
|
|
};
|
|
|
|
|
|
options.data = data;
|
|
|
$.ajax(options);
|
|
|
};
|
|
|
|
|
|
|
|
|
load.on('after', function(p) {
|
|
|
|
|
|
data.pageCount = count * rows[1];
|
|
|
|
|
|
loadAjax(url, data);
|
|
|
});
|
|
|
|
|
|
load.on('before', function(p) {
|
|
|
|
|
|
|
|
|
load.tpl = '{{#each this}}';
|
|
|
load.tpl += '<div class="good-info imgopacity" data-skn="{{skn}}">';
|
|
|
load.tpl += ' <div class="tag-container clearfix">';
|
|
|
load.tpl += ' {{# tags}}';
|
|
|
load.tpl += ' {{# isNew}}';
|
|
|
load.tpl += ' <span class="good-tag new-tag">NEW</span>';
|
|
|
load.tpl += ' {{/ isNew}}';
|
|
|
load.tpl += ' {{# isReNew}}';
|
|
|
load.tpl += ' <span class="good-tag renew-tag">再到着</span>';
|
|
|
load.tpl += ' {{/ isReNew}}';
|
|
|
load.tpl += ' {{# isSale}}';
|
|
|
load.tpl += ' <span class="good-tag sale-tag">SALE</span>';
|
|
|
load.tpl += ' {{/ isSale}}';
|
|
|
load.tpl += ' {{# isNewFestival}}';
|
|
|
load.tpl += ' <span class="good-tag new-festival-tag">新品节</span>';
|
|
|
load.tpl += ' {{/ isNewFestival}}';
|
|
|
load.tpl += ' {{# isLimit}}';
|
|
|
load.tpl += ' <span class="good-tag limit-tag">限量商品</span>';
|
|
|
load.tpl += ' {{/ isLimit}}';
|
|
|
load.tpl += ' {{# isYearEndPromotion}}';
|
|
|
load.tpl += ' <span class="good-tag yep-tag">年终大促</span>';
|
|
|
load.tpl += ' {{/ isYearEndPromotion}}';
|
|
|
load.tpl += ' {{# isYearMidPromotion}}';
|
|
|
load.tpl += ' <span class="good-tag ymp-tag">年中热促</span>';
|
|
|
load.tpl += ' {{/ isYearMidPromotion}}';
|
|
|
load.tpl += ' {{/ tags}}';
|
|
|
load.tpl += ' </div>';
|
|
|
load.tpl += ' <div class="good-detail-img">';
|
|
|
load.tpl += ' <a class="good-thumb" href="{{url}}" target= "_blank">';
|
|
|
load.tpl += ' <img class="lazy" data-original="{{thumb}}">';
|
|
|
load.tpl += ' </a>';
|
|
|
load.tpl += ' {{# isFew}}';
|
|
|
load.tpl += ' <p class="few-tag">即将售罄</p>';
|
|
|
load.tpl += ' {{/ isFew}}';
|
|
|
|
|
|
load.tpl += ' {{#if showColBtn}}';
|
|
|
load.tpl += ' <span class="col-btn iconfont{{#if coled}} coled{{/if}}"></span>';
|
|
|
load.tpl += ' {{/if}}';
|
|
|
load.tpl += ' </div>';
|
|
|
load.tpl += ' <div class="good-detail-text">';
|
|
|
load.tpl += ' <a href="{{url}}" target= "_blank">{{name}}</a>';
|
|
|
load.tpl += ' <p class="price">';
|
|
|
load.tpl += ' <span class="sale-price{{#unless marketPrice}}prime-cost{{/unless}}">';
|
|
|
load.tpl += ' ¥{{salePrice}}';
|
|
|
load.tpl += ' </span>';
|
|
|
load.tpl += ' {{# marketPrice}}';
|
|
|
load.tpl += ' <span class="market-price">¥{{.}}</span>';
|
|
|
load.tpl += ' {{/ marketPrice}}';
|
|
|
load.tpl += ' </p>';
|
|
|
load.tpl += ' </div>';
|
|
|
load.tpl += '</div>';
|
|
|
load.tpl += '{{/each}}';
|
|
|
|
|
|
|
|
|
data.pageCount = count * rows[0];
|
|
|
|
|
|
loadAjax(url, data, data.count);
|
|
|
|
|
|
//load.emit();
|
|
|
});
|
|
|
|
|
|
load.init();
|
|
|
|
|
|
};
|
|
|
});
|
|
|
define("js/passport/entry", ["jquery","jquery.placeholder"], function(require, exports, module){
|
...
|
...
|
@@ -3859,7 +3866,9 @@ var $pwdIntensity = $('.pwd-intensity'), |
|
|
|
|
|
//signup验证
|
|
|
var $region = $('#country-code'),
|
|
|
$regionSelect = $('#region');
|
|
|
$regionSelect = $('#region'),
|
|
|
isPwd = false,
|
|
|
pwdVal;
|
|
|
|
|
|
setTimeout(function() {
|
|
|
$pn.val('');
|
...
|
...
|
@@ -3873,10 +3882,13 @@ setTimeout(function() { |
|
|
$ca.attr('maxlength', caCount);
|
|
|
|
|
|
//密码规则提示
|
|
|
$pwd.focus(function() {
|
|
|
$pwd.focus(function(event) {
|
|
|
$pwdTips.removeClass('hide');
|
|
|
isPwd = true;
|
|
|
pwdVal = $(this).val();
|
|
|
}).blur(function() {
|
|
|
$pwdTips.addClass('hide');
|
|
|
isPwd = false;
|
|
|
});
|
|
|
|
|
|
|
...
|
...
|
@@ -4339,6 +4351,23 @@ exports.init = function(page) { |
|
|
});
|
|
|
});
|
|
|
|
|
|
// 防止粘贴密码
|
|
|
/*$('#pwd, #repwd').keydown(function (event) {
|
|
|
|
|
|
console.log(event.ctrlKey);
|
|
|
console.log(isPwd);
|
|
|
console.log(event.keyCode);
|
|
|
|
|
|
if (event.ctrlKey && isPwd && event.keyCode === 86) {
|
|
|
$(this).val(pwdVal);
|
|
|
}
|
|
|
|
|
|
});*/
|
|
|
|
|
|
$pwd[0].onpaste = function() {
|
|
|
return false;
|
|
|
};
|
|
|
|
|
|
//ajax表单提交
|
|
|
$registerBtn.click(function() {
|
|
|
|
...
|
...
|
|