Authored by 郭成尧

list-js

... ... @@ -33,7 +33,7 @@ var $input = $('#search-input input'),
$buriedpoint = $('.buriedpoint'),
$search = $('#search');
var shopId, sort, brand, outlets, ageLevel;
var shopId,sort,brand,outlets,app_type;
// 默认筛选条件
var defaultOpt = require('../../common/query-param');
... ... @@ -43,7 +43,7 @@ var $listNav = $('#list-nav'),
// 导航数据信息
navInfo = {
newest: {
order: 0,
order: 1,
reload: true,
page: 0,
end: false
... ... @@ -155,7 +155,8 @@ function getQueryString(name) {
shopId = getQueryString('shop_id');
sort = getQueryString('sort');
outlets = getQueryString('outlets');
ageLevel = outlets = getQueryString('ageLevel');
age_level = getQueryString('ageLevel');
app_type = getQueryString('app_type');
/**
* 筛选注册的回调,筛选子项点击后逻辑
... ... @@ -215,7 +216,7 @@ function search(opt) {
color: opt.id
};
break;
case 'ageLevel':
case 'age_level':
ext = {
age_level: opt.id
};
... ... @@ -293,18 +294,18 @@ function search(opt) {
params.outlets = outlets;
}
if (app_type) {
params.app_type = app_type;
}
$.extend(setting, defaultOpt, params);
/* if shop_id del brand */
if (shopId) {
delete setting.brand;
}
searching = true;
loading.showLoadingMask();
$.ajax({
type: 'GET',
url: '/product/search/search',
url: location.protocol + '//m.yohobuy.com/product/search/search',
data: setting,
success: function(data) {
var noResult = '<p class="no-result">未找到相关搜索结果</p>',
... ... @@ -385,14 +386,15 @@ function search(opt) {
}
// require('../../common/suspend-cart'); //悬浮购物车
if (shopId) {
delete defaultOpt.brand;
Object.assign(defaultOpt, {shop_id: shopId});
/* tar add 160914 */
if ($brandHeader.data('isbaseshop') === 1) {
Object.assign(defaultOpt, {shop_id: $brandHeader.data('id')});
}
$.ajax({
type: 'GET',
url: '/product/search/filter',
url: location.protocol + '//m.yohobuy.com/product/search/filter',
data: defaultOpt,
success: function(data) {
$goodsContainer.append(data);
... ...
... ... @@ -34,6 +34,7 @@ var $subNav = $('.home-sub-nav'),
shopId = $('input[name="shop_id"]').val(),
appVersion = $('input[name="app_version"]').val(),
brand = $('input[name="brand"]').val(),
coverChannel = $('input[name="coverChannel"]').val(),
favId = $('input[name="favId"]').val();
var winH = $(window).height(),
... ... @@ -149,6 +150,10 @@ function getPageGoods(info) {
return;
}
if (info.data && coverChannel) {
info.data.coverChannel = coverChannel;
}
searching = true;
$.ajax({
type: 'GET',
... ... @@ -219,7 +224,7 @@ function hotData(callback) {
req.callBack = function(data) {
$('#popularity').append(data);
navInfo.hot.page++;
myScroll.refresh();
// myScroll.refresh();
lazyLoad($('#popularity .lazy'));
scH = $('#scroller').outerHeight();
searching = false;
... ... @@ -265,7 +270,7 @@ function tabChange(dom, index) {
$nav1.removeClass('fixed-top absolute');
$nav2.removeClass('fixed-top absolute');
}
myScroll && myScroll.refresh();
// myScroll && myScroll.refresh();
scH = $('#scroller').outerHeight();
if (!$nav1.hasClass('hide')) {
myScroll && myScroll.scrollTo(0, 0 - imgH);
... ... @@ -443,7 +448,7 @@ document.addEventListener('touchmove', function(e) {
// window ready 后重新refresh iscroll
$(window).ready(function() {
myScroll && myScroll.refresh();
// myScroll && myScroll.refresh();
imgH = $('#nav-top').outerHeight();
nav1H = $('#nav').outerHeight();
main1H = $('#nav-main').height();
... ... @@ -460,7 +465,7 @@ $(window).ready(function() {
setTimeout(function() {
scH = $('#scroller').outerHeight();
}, 1000);
}, 500);
myScroll.on('scroll', scrollHandler);
... ... @@ -505,6 +510,8 @@ function search(opt) {
opt.url = location.protocol + '//m.yohobuy.com/index/search/search';
}
$pre = $listNav.find('.active').eq(0);
if (!opt.nextPage) {
// 筛选项变更则重置reload为true
... ... @@ -527,6 +534,8 @@ function search(opt) {
ext = {
gender: opt.id
};
ext.coverChannel = opt.id;
break;
case 'brand':
ext = {
... ... @@ -588,6 +597,12 @@ function search(opt) {
// 不需要重新加载并且数据请求结束
return;
}
//封面图,defaultOpt对象也有可能包含coverChannel,但defaultOpt优先级高
if (coverChannel) {
setting.coverChannel = coverChannel;
}
$.extend(setting, defaultOpt, {
type: navType,
order: nav.order,
... ... @@ -653,7 +668,7 @@ function search(opt) {
window.rePosFooter();
myScroll.refresh();
myScroll && myScroll.refresh();
reNav1Pos();
bindGoodThumbClick();
... ... @@ -691,18 +706,9 @@ $subNav.on('touchend touchcancel', function(e) {
// 筛选面板切换状态
if ($this.hasClass('active')) {
filter.hideFilter();
// 点击筛选钱的active项回复active
$pre.addClass('active');
$this.removeClass('active');
myScroll && myScroll.enable();
} else {
$pre = $this.siblings('.active');
$pre.removeClass('active');
$this.addClass('active');
myScroll && myScroll.scrollTo(0, -(imgH + main1oH + nav1H));
theY = imgH + main1oH + nav1H;
... ... @@ -747,9 +753,8 @@ $subNav.on('touchend touchcancel', function(e) {
// 价格/折扣切换排序状态
$this.find('.icon > .iconfont').toggleClass('cur');
$pre = $this; // 更新pre为当前项
nav.reload = true; // 重置reload,HTML会被替换为逆序的HTML
nav.order = nav.order === 0 ? 1 : 0; // 切换排序
nav.reload = true; //重置reload,HTML会被替换为逆序的HTML
nav.order = nav.order === 0 ? 1 : 0; //切换排序
$goodsContainer.children('.container:not(.hide)').addClass('hide');
... ... @@ -773,8 +778,6 @@ $subNav.on('touchend touchcancel', function(e) {
} else {
$active = $subNav.find('.active');
$pre = $this; // $pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
if ($active.hasClass('filter')) {
// 若之前active项为筛选,则隐藏筛选面板
... ... @@ -799,6 +802,9 @@ $subNav.on('touchend touchcancel', function(e) {
default:
break;
}
theY = imgH + main1oH + nav1H;
reNav1Pos();
}
$subNav.children().removeClass('active');
... ... @@ -838,14 +844,14 @@ $listNav.on('touchstart', 'li', function(e) {
$(this).addClass('bytouch');
}).on('touchend touchcancel', function() {
$listNav.find('li').removeClass('bytouch');
myScroll && myScroll.refresh();
// myScroll && myScroll.refresh();
});
$nav2.on('touchstart', 'li', function(e) {
$(this).addClass('bytouch');
}).on('touchend touchcancel', function() {
$nav2.find('li').removeClass('bytouch');
myScroll && myScroll.refresh();
// myScroll && myScroll.refresh();
});
// 底部导航点击
... ... @@ -920,9 +926,9 @@ $collect.on('touchstart', function() {
}
setTimeout(function() {
myScroll.refresh();
// myScroll.refresh();
scH = $('#scroller').outerHeight();
}, 1000);
}, 500);
searching = false;
},
error: function() {
... ...