Authored by 郭成尧

goods-show-order-params

... ... @@ -142,7 +142,7 @@
<div id="goods-container" class="goods-container">
<div class="firstscreen-goods container clearfix"></div>
<div class="search-divide">正在加载...</div>
{{!--<div class="search-divide">正在加载...</div>--}}
<div class="default-goods container clearfix"></div>
<div class="new-goods container clearfix"></div>
<div class="sale-goods container clearfix"></div>
... ...
// const tip = require('../plugin/tip');
const filter = require('../plugin/filter');
const lazyLoad = require('yoho-jquery-lazyload');
// const loading = require('../plugin/loading');
... ... @@ -10,7 +11,6 @@ require('plugin/sticky');
require('./shop/coupon');
let Tab = require('plugin/tab');
let defaultOpt = require('../common/query-param');
let $goodsContainer = $('#goods-container');
let $fsgc = $goodsContainer.children('.firstscreen-goods');
... ... @@ -24,7 +24,6 @@ let $pre = $listNav.find('.active'); // 记录进入筛选前的active项,初
let $filterBody = $('.filter-body');
let allGoodsTabClickTimes = 0;
let navInfo = {
price: {
order: 1,
... ... @@ -57,6 +56,8 @@ let navInfo = {
end: false
}
};
let navType = 'default'; // 目前激活的导航页面
let defaultOpt = navInfo.default; // 默认参数
/**
* 处理筛选参数
... ... @@ -75,7 +76,40 @@ function handleChoseFilter() {
*/
function getGoodsList() {
handleChoseFilter();
console.log('ok');
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/search/search',
data: defaultOpt,
xhrFields: {
withCredentials: true
},
success: function(result) {
let $container = $defaultgc;
switch (navType) {
case 'new':
$container = $ngc;
break;
case 'price':
$container = $pgc;
break;
case 'discount':
$container = $dgc;
break;
case 'default':
$container = $defaultgc;
break;
case 'sale':
$container = $sgc;
break;
default:
break;
}
$container.html(result);
lazyLoad($container.find('.lazy'));
}
});
}
/**
... ... @@ -121,11 +155,10 @@ $listNav.bind('contextmenu', function() {
});
$listNav.on('touchend touchcancel', function(e) {
var $this = $(e.target).closest('li'),
nav,
navType,
$active;
var bpIdData = $(this).find('.buriedpoint').attr('data-bp-id') || '';
let $this = $(e.target).closest('li'); // 被点击的 Tab
let $active;
let nav;
let bpIdData = $(this).find('.buriedpoint').attr('data-bp-id') || '';
if ($this.hasClass('filter')) {
... ... @@ -160,6 +193,10 @@ $listNav.on('touchend touchcancel', function(e) {
nav = navInfo[navType];
/* 排序条件更新 */
defaultOpt.type = navType;
Object.assign(defaultOpt, nav);
if ($this.hasClass('active')) {
// 默认、最新无排序切换
... ... @@ -218,6 +255,7 @@ $listNav.on('touchend touchcancel', function(e) {
$active.removeClass('active');
$this.addClass('active');
}
if (nav.reload) {
$(document).trigger('shouldSendBpData', [bpIdData]);
getGoodsList({filtering: true});
... ...