Authored by 郝肖肖

merage searchOptimi

... ... @@ -237,7 +237,7 @@ const category = (req, res, next) => {
initialData.uid = uid;
}
searchModel.getSearchData(initialData).then((firstScreenGoodsList) => {
searchModel.getSearchData(initialData).then((firstPageGoods) => {
res.render('search/goods-list', {
_noLazy: true, // 首屏不使用lazyload
module: 'product',
... ... @@ -246,7 +246,7 @@ const category = (req, res, next) => {
navTitle: req.query.title || req.query.sort_name
}),
goodList: params,
firstPageGoodsList: firstScreenGoodsList.list,
firstPageGoods: firstPageGoods || [],
showDownloadApp: true,
pageFooter: true,
category: true,
... ...
... ... @@ -70,7 +70,9 @@ const shop = {
let brandShop = shopResult[0];
let newGoods = shopResult[1];
params.newGoods = newGoods.list;
params.newGoods = newGoods.list || [];
params.suggestion = newGoods.suggestion || [];
if (brandId === 0) {
params.query = domain;
}
... ... @@ -119,6 +121,7 @@ const shop = {
navTitle: title !== '' ? title : domain
}),
goodList: params,
suggestion: params.suggestion || [],
showDownloadApp: true,
pageFooter: true,
title: title + '|' + title + '潮流服装服饰-Yoho!Buy有货',
... ...
... ... @@ -35,7 +35,7 @@ const blkNewGoods = (req, res, next) => {
initialData.uid = uid;
}
searchModel.getSearchData(initialData).then(firstScreenGoodsList => {
searchModel.getSearchData(initialData).then(firstPageGoods => {
res.render('search/goods-list', {
module: 'product',
page: 'search-list',
... ... @@ -43,7 +43,7 @@ const blkNewGoods = (req, res, next) => {
navTitle: req.query.title || req.query.sort_name || '新品抢先看'
}),
goodList: params,
firstPageGoodsList: firstScreenGoodsList.list,
firstPageGoods: firstPageGoods || [],
showDownloadApp: true,
pageFooter: true
});
... ...
... ... @@ -20,9 +20,8 @@ const list = (req, res, next) => {
let params = Object.assign({
isSearch: true, // 搜索列表将最新改成默认的标识
cartUrl: helpers.urlFormat('/cart/index/index')
}, req.query);
}, req.query, {query: (req.query.query || '').toString()});
let title = '';
let query = (req.query.query || '').toString();
let isQueryFirstClass = false; // 标识用户搜的是不是一级品类
let isQuerySecondClass = false; // 标识用户搜的是不是二级品类
let domain = null;
... ... @@ -32,7 +31,6 @@ const list = (req, res, next) => {
params.shopId = params.shop_id;
}
params.query = query;
params.isApp = req.yoho.isApp;
params.physical_channel = req.yoho.channel && searchProcess.getChannelType(req.yoho.channel);
... ... @@ -50,34 +48,37 @@ const list = (req, res, next) => {
limit: 12
}, params);
if (query) {
query = query.toLowerCase();
}
if (uid) {
initialData.uid = uid;
}
/* 判断是不是品牌, 是品牌跳到品牌列表页(显示搜索框),判断是不是品类, 是品类加导航标题(不显示搜索框) */
return Promise.all([
searchModel.getBrandDomain(query),
searchModel.getBrandDomain(params.query.toLowerCase()),
searchModel.getClassNames(),
searchModel.getSearchData(initialData)
]).then(result => {
if (query) {
// 推荐词条件判断 redmine: 18567
if (result[2].suggestion && result[2].suggestion.termsSuggestion &&
result[2].suggestion.termsSuggestion.length) {
params.query = result[2].suggestion.termsSuggestion[0].name;
}
if (params.query) {
domain = result[0];
// 跳转到品牌商品列表页
if (domain !== null && !params.shop_id) {
let urlPro = {
from: 'search',
query: query
}
query: params.query
};
if (req.query.app_type) {
urlPro = _.assign(urlPro, {
app_type: req.query.app_type
})
});
}
let url = helpers.urlFormat('', urlPro, domain);
... ... @@ -92,7 +93,7 @@ const list = (req, res, next) => {
_.forEach(result[1].first, (obj) => {
// 精确查一级品类
if (obj === query) {
if (obj === params.query) {
isQueryFirstClass = true;
return false;
}
... ... @@ -100,7 +101,7 @@ const list = (req, res, next) => {
_.forEach(result[1].second, (obj) => {
// 精确查二级品类
if (obj === query) {
if (obj === params.query) {
isQuerySecondClass = true;
return false;
}
... ... @@ -111,13 +112,13 @@ const list = (req, res, next) => {
// 搜索是一级品类
if (isQueryFirstClass) {
title = '全部' + query;
title = '全部' + params.query;
} else if (isQuerySecondClass) { // 搜索是二级品类
title = query;
title = params.query;
} else { // 搜索其它内容
if (query || params.form) {
if (params.query || params.form) {
params.search = {
default: query === '' ? false : query,
default: params.query === '' ? false : params.query,
url: helpers.urlFormat('', null, 'search')
};
}
... ... @@ -135,7 +136,8 @@ const list = (req, res, next) => {
}),
title: title,
goodList: params,
firstPageGoodsList: result[2].list || [],
firstPageGoods: result[2] || [],
suggestion: result[2].suggestion || [],
pageFooter: true,
shopId: params.shop_id || ''
});
... ... @@ -170,7 +172,9 @@ const index = (req, res, next) => {
pageFooter: true,
width750: true,
search: {
defaultTerms: (result && result.hotTerms && result.hotTerms.defaultTerms && result.hotTerms.defaultTerms.length !== 0) ? result.hotTerms.defaultTerms[0].content : '',
defaultTerms: (result && result.hotTerms &&
result.hotTerms.defaultTerms && result.hotTerms.defaultTerms.length !== 0) ?
result.hotTerms.defaultTerms[0].content : '',
url: helpers.urlFormat('', null, 'search'),
hotTerms: result.hotTerms,
wantTerms: result.guessTerms
... ...
... ... @@ -186,16 +186,37 @@ const getSearchData = (params) => {
return _searchGoods(params).then((result) => {
if (result && result.code === 200) {
let newList = {};
let suggestion = {};
newList.list = productProcess.processProductList(result.data.product_list || [], {
isApp: params.isApp || (params.appVersion && params.appVersion !== 'false'),
gender: _coverChannel[params.coverChannel]
});
params.page = parseInt(params.page, 10);
result.data.total = parseInt(result.data && result.data.total || 0, 10);
if (parseInt(params.page, 10) === 1) {
if (params.page === 1) {
newList.total = result.data.total;
}
// 推荐词条件判断 redmine: 18567
if (params.page === 1 && (result.data.isChangedQuery === 'Y' ||
result.data.total <= 20 || params.needSuggestion === 'Y')) {
params.isChangedQuery = result.data.isChangedQuery === 'Y';
suggestion = {
isNeedSuggestion: params.isChangedQuery || params.needSuggestion === 'Y', // 是否是关键词搜索判断
termsSuggestion: productProcess.termsSuggestion(
result.data.suggestion && result.data.suggestion.terms_suggestion || [], params
),
isMaybeLike: (params.isChangedQuery || params.needSuggestion === 'Y') &&
result.data.total > 0 ? false : true // 猜你喜欢显示不显示判断
};
suggestion.isNeedSuggestionOne = suggestion.termsSuggestion.length > 1;// 如果只有一个<或者试试不显示>
}
newList.suggestion = suggestion;
return newList;
} else {
logger.error('get product search api return code is not 200');
... ...
... ... @@ -52,44 +52,14 @@
<!-- 优惠卷 -->
<div class="coupon-group"></div>
<!-- /品牌页面 -->
<ul id="list-nav" class="list-nav clearfix">
<li class="default active buriedpoint first-li-more" data-bp-id="shop_listnav_default_1">
<a href="javascript:void(0);">
<span class="nav-txt">默认</span>
<span class="iconfont up cur hide">&#xe615;</span>
<span class="iconfont down cur">&#xe616;</span>
</a>
</li>
<li class="price buriedpoint" data-bp-id="shop_listnav_price_1">
<a href="javascript:void(0);">
<span class="nav-txt">价格</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="discount buriedpoint" data-bp-id="shop_listnav_discount_1">
<a href="javascript:void(0);">
<span class="nav-txt">折扣</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="filter buriedpoint" data-bp-id="shop_listnav_filter_1">
<a href="javascript:void(0);">
<span class="nav-txt">筛选</span>
<span class="iconfont cur">&#xe613;</span>
</a>
</li>
</ul>
<!--搜索默认排序列表-->
{{> product/search-default-sort-list}}
{{!--筛选tab--}}
{{> product/filter-tab}}
<div id="goods-container" class="goods-container">
{{!--搜索推荐词模板--}}
{{> search/search-word-content}}
<div class="default-goods container clearfix">
{{#newGoods}}
{{> common/goods}}
... ... @@ -102,6 +72,14 @@
{{> common/filter}}
</div>
{{> common/query-param}} {{> common/suspend-cart}} {{/ goodList}}
{{!--搜索列表显示过少,显示猜您喜欢--}}
{{#if @root.suggestion.isMaybeLike}}
<div class="maybe-like-search">您可能喜欢的</div>
<div id="goods-list" class="maybe-like-goods"></div>
{{/if}}
{{> common/query-param}}
{{> common/suspend-cart}}
{{/ goodList}}
<input type="text" class="domain" style="display:none" value={{domain}}>
</div>
... ...
<div class="good-list-page yoho-page">
{{# goodList}}
{{# goodList}}
<!-- 基础店铺页面 -->
{{# baseShopHome}}
<div id="brand-header" class="brand-header" data-id={{id}} data-isbaseshop="{{isBaseShop}}">
... ... @@ -27,45 +27,14 @@
</div>
<input type="hidden" name="app_version" value="{{appVersion}}">
{{/ baseShopHome}}
<!-- 优惠卷 -->
<div class="coupon-group"></div>
<!-- /基础店铺页面 -->
<ul id="list-nav" class="list-nav clearfix">
<li class="default active buriedpoint first-li-more" data-bp-id="shop_listnav_default_1">
<a href="javascript:void(0);">
<span class="nav-txt">默认</span>
<span class="iconfont up cur hide">&#xe615;</span>
<span class="iconfont down cur">&#xe616;</span>
</a>
</li>
<li class="price buriedpoint" data-bp-id="shop_listnav_price_1">
<a href="javascript:void(0);">
<span class="nav-txt">价格</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="discount buriedpoint" data-bp-id="shop_listnav_discount_1">
<a href="javascript:void(0);">
<span class="nav-txt">折扣</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="filter buriedpoint" data-bp-id="shop_listnav_filter_1">
<a href="javascript:void(0);">
<span class="nav-txt">筛选</span>
<span class="iconfont cur">&#xe613;</span>
</a>
</li>
</ul>
<!--搜索默认排序列表-->
{{> product/search-default-sort-list}}
{{!--筛选tab--}}
{{> product/filter-tab}}
<div id="goods-container" class="goods-container">
<div class="default-goods container clearfix">
... ... @@ -79,6 +48,8 @@
{{> common/filter}}
</div>
{{> common/query-param}} {{> common/suspend-cart}} {{/ goodList}}
<input type="text" class="shopId" style="display:none" value={{shopId}}>
{{> common/query-param}}
{{> common/suspend-cart}}
{{/ goodList}}
<input type="text" class="shopId" style="display:none" value={{shopId}}>
</div>
... ...
... ... @@ -119,11 +119,14 @@
<div class="discount-area first" id="navlist2">
<ul id="list-nav" class="home-sub-nav list-nav pos-list clearfix">
<li class="default active buriedpoint first-li-more" data-bp-id="shop_listnav_default_1">
<li class="default active buriedpoint" data-bp-id="shop_listnav_default_1">
<a href="javascript:void(0);">
<span class="nav-txt">默认</span>
<span class="iconfont up cur hide">&#xe615;</span>
<span class="iconfont down cur">&#xe616;</span>
</a>
</li>
<li class="new buriedpoint" data-bp-id="shop_listnav_new_1">
<a href="javascript:void(0);">
<span class="nav-txt">最新</span>
</a>
</li>
<li class="price buriedpoint" data-bp-id="shop_listnav_price_1">
... ... @@ -151,12 +154,6 @@
</a>
</li>
</ul>
<div class='new-list classics hide'>
<ul>
<li class='active default' data-bp-id='shop_listnav_default_1'>默认</li>
<li class='new' data-bp-id='shop_listnav_new_1'>最新</li>
</ul>
</div>
</div>
<div class="discount-area first">
... ... @@ -189,11 +186,14 @@
</ul>
<ul id="pos-list" class="home-sub-nav pos-list hide">
<li class="default active buriedpoint first-li-more" data-bp-id="shop_listnav_default_1">
<li class="default active buriedpoint" data-bp-id="shop_listnav_default_1">
<a href="javascript:void(0);">
<span class="nav-txt">默认</span>
<span class="iconfont up cur hide">&#xe615;</span>
<span class="iconfont down cur">&#xe616;</span>
</a>
</li>
<li class="new buriedpoint" data-bp-id="shop_listnav_new_1">
<a href="javascript:void(0);">
<span class="nav-txt">最新</span>
</a>
</li>
<li class="price buriedpoint" data-bp-id="shop_poslist_price_1">
... ...
<div class="discount-detail-page goods-page yoho-page" data-product-pool="{{product_pool}}">
{{> sale/banner}}
<div>
<ul id="list-nav" class="list-nav clearfix">
<li class="default active first-li-more">
<a href="javascript:void(0);">
<span class="span-test">默认</span>
<span class="iconfont up cur hide">&#xe615;</span>
<span class="iconfont down cur">&#xe616;</span>
</a>
</li>
<li class="price">
<a href="javascript:void(0);">
<span class="span-test">价格</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="discount">
<a href="javascript:void(0);">
<span class="span-test">折扣</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="filter">
<a href="javascript:void(0);">
<span class="span-test">筛选</span>
<span class="iconfont cur">&#xe613;</span>
</a>
</li>
</ul>
<!--搜索默认排序列表-->
{{> product/search-default-sort-list}}
</div>
{{!--筛选tab--}}
{{> product/filter-tab}}
{{> sale/common}}
<input type="hidden" id="discount" value="discount">
</div>
\ No newline at end of file
</div>
... ...
... ... @@ -48,8 +48,12 @@
{{/floorHeader}}
<div class="sale-nav-wrap">
{{> common/filter-nav}}
<div class='list-nav-layer'>
{{!--筛选tab--}}
{{> product/filter-tab}}
</div>
</div>
{{> sale/common}}
{{> common/suspend-home}}
</div>
... ...
<div class="sale-vip-page goods-page yoho-page">
{{> sale/banner}}
<div class='list-nav-layer'>
<ul id="list-nav" class="list-nav clearfix">
<li class="default active first-li-more">
<a href="javascript:void(0);">
<span class="span-test">默认</span>
<span class="iconfont up cur hide">&#xe615;</span>
<span class="iconfont down cur">&#xe616;</span>
</a>
</li>
<li class="price">
<a href="javascript:void(0);">
<span class="span-test">价格</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="sale">
<a href="javascript:void(0);">
<span class="span-test">销量</span>
</a>
</li>
<li class="filter">
<a href="javascript:void(0);">
<span class="span-test">筛选</span>
<span class="iconfont cur">&#xe613;</span>
</a>
</li>
</ul>
<!--搜索默认排序列表-->
{{> product/search-default-sort-list}}
{{!--筛选tab--}}
{{> product/filter-tab}}
</div>
{{> sale/common}}
</div>
\ No newline at end of file
</div>
... ...
... ... @@ -222,7 +222,7 @@
</a>
</li>
</ul>
<!--搜索默认排序列表-->
{{> product/search-default-sort-list}}
</div>
... ...
... ... @@ -31,7 +31,8 @@
<img class="lazy" data-original={{banner}}>
</div>
{{/ shopBanner}}
<!-- 品牌页面 -->
{{!--品牌页面--}}
{{# brandHome}}
<div id="brand-header" class="brand-header" data-id={{id}}>
<img class="lazy" data-original={{banner}}>
... ... @@ -57,9 +58,9 @@
</div>
</div>
{{/ brandHome}}
<!-- /品牌页面 -->
{{!--/品牌页面--}}
<!-- 基础店铺页面 -->
{{!--基础店铺页面--}}
{{# baseShopHome}}
<div id="brand-header" class="brand-header" data-id={{id}} data-isbaseshop="{{isBaseShop}}">
<img class="lazy" data-original={{banner}}>
... ... @@ -86,59 +87,28 @@
</div>
<input type="hidden" name="app_version" value="{{appVersion}}">
{{/ baseShopHome}}
<!-- /基础店铺页面 -->
{{!--/基础店铺页面--}}
{{#ifor brandHome baseShopHome}}
<!-- 优惠卷 -->
{{!--优惠卷--}}
<div class="coupon-group"></div>
{{/ifor}}
<div>
<ul id="list-nav" class="list-nav clearfix">
<li class="default active buriedpoint first-li-more" data-bp-id="shop_listnav_default_1">
<a href="javascript:void(0);">
<span class="nav-txt">默认</span>
<span class="iconfont up cur hide">&#xe615;</span>
<span class="iconfont down cur">&#xe616;</span>
</a>
</li>
<li class="price buriedpoint" data-bp-id="shop_listnav_price_1">
<a href="javascript:void(0);">
<span class="nav-txt">价格</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="discount buriedpoint" data-bp-id="shop_listnav_discount_1">
<a href="javascript:void(0);">
<span class="nav-txt">折扣</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="filter buriedpoint" data-bp-id="shop_listnav_filter_1">
<a href="javascript:void(0);">
<span class="nav-txt">筛选</span>
<span class="iconfont cur">&#xe613;</span>
</a>
</li>
</ul>
{{!--筛选tab--}}
{{> product/filter-tab}}
<!--搜索默认排序列表-->
{{> product/search-default-sort-list}}
</div>
{{#@root.introText}}
<p class="intro-text">{{@root.introText}}</p>
{{/@root.introText}}
<div id="goods-container" class="goods-container">
{{#@root.introText}}
<p class="intro-text">{{@root.introText}}</p>
{{/@root.introText}}
{{!--搜索推荐词模板--}}
{{> search/search-word-content}}
<div class="firstscreen-goods container clearfix">
{{#@root.firstPageGoodsList}}
{{#@root.firstPageGoods.list}}
{{> common/goods}}
{{/@root.firstPageGoodsList}}
{{/@root.firstPageGoods.list}}
</div>
<div class="search-divide">正在加载...</div>
<div class="default-goods container clearfix"></div>
... ... @@ -150,6 +120,12 @@
{{> common/filter}}
</div>
{{!--搜索列表显示过少,显示猜您喜欢--}}
{{#if @root.suggestion.isMaybeLike}}
<div class="maybe-like-search">您可能喜欢的</div>
<div id="goods-list" class="maybe-like-goods"></div>
{{/if}}
{{> common/query-param}}
{{> common/suspend-home}}
{{> common/suspend-cart}}
... ...
{{#if @root.suggestion.isNeedSuggestion}}
<div class="word-content">
{{!--相关商品少于指定数据,显示关键词--}}
<div class="list-too-little">
{{#if @root.suggestion.isNeedSuggestion}}
{{#each @root.suggestion.termsSuggestion}}
{{#if select}}
没有找到相关商品,为您推荐"{{name}}"的搜索结果{{#if @root.suggestion.isNeedSuggestionOne}}或者试试{{/if}}
{{/if}}
{{/each}}
{{else}}
相关商品太少了,试试
{{/if}}
{{#each @root.suggestion.termsSuggestion}}
{{#unless select}}
<span class="word"><a href="{{link}}">{{name}}</a></span>
{{/unless}}
{{/each}}
</div>
</div>
{{/if}}
... ...
... ... @@ -10,19 +10,28 @@ const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
const domains = {
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// liveApi: 'http://testapi.live.yohops.com:9999/',
// singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
// api: 'http://dev-api.yohops.com:9999/',
// service: 'http://dev-service.yohops.com:9999/',
// liveApi: 'http://api.live.yoho.cn/',
// singleApi: 'http://single.yoho.cn/',
imSocket: 'ws://socket.yohobuy.com:10240',
imCs: 'https://im.yohobuy.com/api',
imServer: 'https://im.yohobuy.com/server'
imSocket: 'wss://imsocket.yohobuy.com:443',
imCs: 'https://imhttp.yohobuy.com/api',
imServer: 'https://imhttp.yohobuy.com/server'
};
module.exports = {
... ...
<div class="filter-tab">
<ul id="list-nav" class="list-nav clearfix">
<li class="default active buriedpoint" data-bp-id="shop_listnav_default_1">
<a href="javascript:void(0);">
<span class="nav-txt">默认</span>
</a>
</li>
<li class="new buriedpoint" data-bp-id="shop_listnav_new_1">
<a href="javascript:void(0);">
<span class="nav-txt">最新</span>
</a>
</li>
<li class="price buriedpoint" data-bp-id="shop_listnav_price_1">
<a href="javascript:void(0);">
<span class="nav-txt">价格</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="discount buriedpoint" data-bp-id="shop_listnav_discount_1">
<a href="javascript:void(0);">
<span class="nav-txt">折扣</span>
<span class="icon">
<i class="iconfont up cur">&#xe615;</i>
<i class="iconfont down">&#xe616;</i>
</span>
</a>
</li>
<li class="filter buriedpoint" data-bp-id="shop_listnav_filter_1">
<a href="javascript:void(0);">
<span class="nav-txt">筛选</span>
<span class="iconfont cur">&#xe613;</span>
</a>
</li>
</ul>
</div>
... ...
{{!--无结果提示--}}
<div class="no-result-new">
<p>没有找到相关商品</p>
<p>试试搜索别的看看</p>
</div>
... ...
... ... @@ -48,9 +48,10 @@ module.exports = function(specificGender) {
url = '/product/recom/maylikekids';
} else if (lifestyleType) {
// 有货币页面加载男生首页的数据
url = specificGender === 'lifestyle' ? '/product/recom/maylike?gender=1,3&rec_pos=100001' : '/product/recom/maylikelife';
url = specificGender === 'lifestyle' ?
'/product/recom/maylike?gender=1,3&rec_pos=100001' :
'/product/recom/maylikelife';
} else if (yohoCoinType) {
gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
... ... @@ -65,8 +66,8 @@ module.exports = function(specificGender) {
RECPOSE = 110006;
} else {
gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
'1,3&rec_pos=100001' : '2,3&rec_pos=100002';
gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap') ||
$('.yoho-header').hasClass('boys')) ? '1,3&rec_pos=100001' : '2,3&rec_pos=100002';
url = '/product/recom/maylike?gender=' + gender;
}
... ... @@ -85,7 +86,8 @@ module.exports = function(specificGender) {
$curNav = $navList.children('.focus');
if (lifestyleType) {
navHammer = $navList[0] ? new Hammer($navList[0]) : undefined;
navHammer = $navList[0] ? new Hammer($navList[0]) : null;
if (navHammer) {
navHammer.on('tap', function(e) {
var $this = $(e.target).closest('li'),
... ... @@ -116,15 +118,23 @@ module.exports = function(specificGender) {
loading.init($('.maybe-like'));
// 如果对象不存在,就不须要执行
if (!$goodList.length) {
searching = true;
console.warn('maybe like required object is not existent!');
return false;
}
function search() {
if (searching) {
return;
}
searching = true;
loading.showLoadingMask();
// num = $goodList.find('.good-info').length;
$.ajax({
type: 'GET',
url: url,
... ... @@ -153,13 +163,13 @@ module.exports = function(specificGender) {
data: {
gender: channel
},
success: function(data) {
success: function(result) {
bottomBannerLoaded = true;
if (data && data.img) {
if (result && result.img) {
$('#load-more-img').show();
$('#load-more-img a').attr('href', data.url);
$('#load-more-img a > img').attr('src', data.img);
$('#load-more-img a').attr('href', result.url);
$('#load-more-img a > img').attr('src', result.img);
}
},
error: function() {
... ... @@ -242,8 +252,9 @@ module.exports = function(specificGender) {
// 为您优选埋点 http://redmine.yoho.cn/issues/10116
$('.maybe-like .goods-list').on('click', 'a', function() {
var index = $(this).closest('.good-info').index() + 1,
pageNum = 50;
var pageNum = 50;
index = $(this).closest('.good-info').index() + 1;
window.givePoint({
REC_POSE: RECPOSE,
... ... @@ -255,251 +266,3 @@ module.exports = function(specificGender) {
return true;
});
};
/**
* “你可能喜欢”模块JS
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/10/12
*/
// module.exports = function(specificGender) {
// var $ = require('yoho-jquery'),
// Hammer = require('yoho-hammer'),
// ellipsis = require('yoho-mlellipsis'),
// tip = require('../plugin/tip'),
// loading = require('../plugin/loading'),
// lazyLoad = require('yoho-jquery-lazyload');
// var navHammer,
// winH = $(window).height(),
// $goodList = $('#goods-list'),
// searching = false,
// page = 0,
// gender = null,
// num,
// url,
// RECPOSE = '';
// // The kidsType can be specified by the parameter. Add by @ZhaoBiao
// var kidsType = specificGender === 'kids' || $('.mobile-wrap').hasClass('kids-wrap') ? true : false,
// lifestyleType = specificGender === 'lifestyle' ||
// $('.mobile-wrap').hasClass('lifestyle-wrap') ? true : false,
// yohoCoinType = $('.coin').length ? true : false;
// var $curNav,
// index,
// $navList = $('#maybe-like-nav');
// var $footer;
// var bottomBannerLoaded;
// ellipsis.init();
// // ajax url
// if (kidsType) {
// url = '/product/recom/maylikekids';
// } else if (lifestyleType) {
// //有货币页面加载男生首页的数据
// url = specificGender === 'lifestyle' ? '/product/recom/maylike?gender=1,3&rec_pos=100001' : '/product/recom/maylikelife';
// } else if (yohoCoinType) {
// gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
// '1,3&rec_pos=100009' : '2,3&rec_pos=100009',
// url = '/product/recom/maylike?gender=' + gender;
// RECPOSE = 110009;
// } else if (logisticType) { //物流页面
// gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
// '1,3&rec_pos=100006' : '2,3&rec_pos=100006',
// url = '/product/recom/maylike?gender=' + gender;
// RECPOSE = 110006;
// } else {
// gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
// '1,3&rec_pos=100001' : '2,3&rec_pos=100002',
// url = '/product/recom/maylike?gender=' + gender;
// }
// // 首页男生和女生,推荐位ID,埋点
// if (window.location.pathname === '/boys') {
// RECPOSE = 110001;
// } else if (window.location.pathname === '/girls') {
// RECPOSE = 110002;
// }
// $curNav = $navList.children('.focus');
// if (lifestyleType) {
// navHammer = $navList[0] ? new Hammer($navList[0]) : null;
// if (navHammer) {
// navHammer.on('tap', function(e) {
// var $this = $(e.target).closest('li'),
// $goods = $('.goods-list'),
// $content;
// e.preventDefault();
// if ($this.hasClass('focus')) {
// return;
// }
// index = $this.index();
// $this.addClass('focus');
// $curNav.removeClass('focus');
// $goods.not('.hide').addClass('hide');
// $content = $goods.eq(index);
// $content.removeClass('hide');
// $curNav = $this;
// $(document).trigger('scroll'); // Trigger lazyLoad
// e.srcEvent.stopPropagation();
// });
// }
// }
// loading.init($('.maybe-like'));
// function search() {
// if (searching) {
// return;
// }
// searching = true;
// loading.showLoadingMask();
// // num = $goodList.find('.good-info').length;
// $.ajax({
// type: 'GET',
// url: url,
// data: {
// page: page + 1
// },
// success: function(data) {
// var PRDID = [];
// if (data === ' ') {
// loading.hideLoadingMask();
// // 有货币页面不加载底部
// if (gender && !specificGender) {
// if (bottomBannerLoaded) {
// return;
// }
// url = '/channel/bottomBanner';
// $.ajax({
// type: 'GET',
// url: url,
// data: {
// gender: gender
// },
// success: function(res) {
// res = res.data;
// bottomBannerLoaded = true;
// if (res && res.img) {
// $('#load-more-img').show();
// $('#load-more-img a').attr('href', res.url);
// $('#load-more-img a > img').attr('src', res.img);
// }
// }
// });
// }
// return;
// } else {
// searching = false;
// }
// // 加载到数据后,去除bottom样式,使得footer能够随着页面长度的增加改变位置
// if (data.length > 1) {
// $footer ? null : $footer = $('#yoho-footer');
// $footer.hasClass('bottom') ? $footer.removeClass('bottom') : null;
// }
// num = $goodList.find('.good-info').length;
// $goodList.append(data);
// // 2015/10/31 fei.hong: 修复第一页分页不显示图片的问题
// if (num === 0) {
// lazyLoad($goodList.find('.good-info').find('img.lazy'));
// } else {
// lazyLoad($goodList.find('.good-info:gt(' + (num - 1) + ')').find('img.lazy'));
// }
// loading.hideLoadingMask();
// page++;
// $('.good-detail-text .name').each(function() {
// var $this = $(this),
// $title = $this.find('a');
// $title[0].mlellipsis(2);
// });
// // 为您优选埋点 start
// PRDID = [];
// $(data).closest('.good-info').each(function() {
// PRDID.push($(this).data('id'));
// });
// window.givePoint({
// REC_POSE: RECPOSE,
// PRD_ID: PRDID.join(','),
// PRD_NUM: $(data).closest('.good-info').length,
// ACTION_ID: 0,
// PAGE_NUM: page
// });
// // 为您优选埋点 end
// },
// error: function() {
// tip.show('网络断开连接了~');
// searching = false;
// loading.hideLoadingMask();
// }
// });
// }
// $('.maybe-like p').on('touchstart', function() {
// search();
// });
// function scrollHandler() {
// if ($(window).scrollTop() + winH >= $(document).height() - 200) {
// search();
// }
// }
// // 优惠券页面直接加载你可能喜欢。add by @zhaobiao
// if (specificGender) {
// search();
// }
// // srcoll to load more
// $(window).scroll(function() {
// window.requestAnimationFrame(scrollHandler);
// });
// // 为您优选埋点
// $('.maybe-like .goods-list').on('click', 'a', function() {
// var pageNum = 50;
// index = $(this).closest('.good-info').index() + 1;
// window.givePoint({
// REC_POSE: RECPOSE,
// PRD_ID: $(this).closest('.good-info').data('id'),
// PRD_NUM: index % pageNum === 0 ? pageNum : index % pageNum,
// ACTION_ID: 1,
// PAGE_NUM: Math.ceil(index / pageNum)
// });
// return true;
// });
// };
... ...
... ... @@ -17,8 +17,7 @@ var $goodsContainer = $('#goods-container'),
$pgc = $goodsContainer.find('.price-goods'),
$agc = $goodsContainer.find('.all-goods'),
$cgc = $goodsContainer.find('.category-goods'),
$sgc = $goodsContainer.find('.sale-goods'),
$newList = $('.new-list');
$sgc = $goodsContainer.find('.sale-goods');
var winH = $(window).height(),
noResult = '<p class="no-result">未找到相关搜索结果</p>';
... ... @@ -384,18 +383,6 @@ $listNav.bind('contextmenu', function() {
return false;
});
function newListHide() {
var $firstLi = $listNav.find('li.first-li-more');
if ($newList.hasClass('hide')) {
$firstLi.find('span.up').addClass('hide');
$firstLi.find('span.down').removeClass('hide');
} else {
$firstLi.find('span.down').addClass('hide');
$firstLi.find('span.up').removeClass('hide');
}
}
$listNav.on('touchend touchcancel', function(e) {
var $this = $(e.target).closest('li'),
nav,
... ... @@ -408,23 +395,6 @@ $listNav.on('touchend touchcancel', function(e) {
return;
}
if ($this.hasClass('first-li-more')) {
filter.hideFilter();
$newList.toggleClass('hide');
if ($this.hasClass('default')) {
$newList.find('li.default').addClass('active').siblings().removeClass('active');
} else if ($this.hasClass('new')) {
$newList.find('li.new').addClass('active').siblings().removeClass('active');
} else if ($this.hasClass('sale')) {
$newList.find('li.sale').addClass('active').siblings().removeClass('active');
}
newListHide();
return true;
}
// 最新li 列表
$newList.addClass('hide');
if ($this.hasClass('filter')) {
// 筛选面板切换状态
... ... @@ -452,7 +422,8 @@ $listNav.on('touchend touchcancel', function(e) {
if ($this.hasClass('active')) {
// 最新无排序切换
if ($this.hasClass('new') || $this.hasClass('sale') || $this.hasClass('all')) {
if ($this.hasClass('default') || $this.hasClass('new') ||
$this.hasClass('sale') || $this.hasClass('all')) {
return;
}
... ... @@ -551,69 +522,6 @@ $listNav.on('touchstart', 'li', function() {
$listNav.find('li').removeClass('bytouch');
});
$newList.on('touchstart', 'li', function(e) {
var navType,
$firstLiDom = $listNav.find('li.first-li-more');
e.preventDefault();
if ($(this).hasClass('new')) {
navType = 'new';
} else if ($(this).hasClass('default')) {
navType = 'default';
} else if ($(this).hasClass('sale')) {
navType = 'sale';
}
$newList.addClass('hide');
$firstLiDom.find('.span-test').text($(this).text());
$firstLiDom.addClass('active').siblings().removeClass('active');
$listNav.find('.first-li-more').removeClass('new default sale').addClass(navType);
newListHide();
if ($(this).hasClass('active')) {
return;
}
// 切换container显示
$goodsContainer.children('.container:not(.hide)').addClass('hide');
switch (navType) {
case 'new':
$ngc.removeClass('hide');
break;
case 'price':
$pgc.removeClass('hide');
break;
case 'discount':
$dgc.removeClass('hide');
break;
case 'default':
$defaultgc.removeClass('hide');
break;
case 'sale':
$sgc.removeClass('hide');
break;
default:
break;
}
$pre = $firstLiDom;
search({filtering: true});
});
$(document).on('touchstart', function(e) {
if (!$newList.hasClass('hide') &&
$(e.target).closest('.new-list, li.first-li-more').length <= 0) {
$newList.addClass('hide');
newListHide();
}
});
module.exports = {
start: search
};
... ...
... ... @@ -26,8 +26,7 @@ var $goodsContainer = $('#goods-container'),
$ngc = $goodsContainer.children('.new-goods'),
$sgc = $goodsContainer.children('.sale-goods'),
$pgc = $goodsContainer.children('.price-goods'),
$dgc = $goodsContainer.children('.discount-goods'),
$newList = $('.new-list');
$dgc = $goodsContainer.children('.discount-goods');
var winH = $(window).height();
... ... @@ -66,19 +65,19 @@ var $listNav = $('#list-nav'),
default: {
order: 0,
reload: true,
page: 1,
page: 0,
end: false
},
new: {
order: 0,
reload: true,
page: 1,
page: 0,
end: false
},
sale: {
order: 0,
reload: true,
page: 1,
page: 0,
end: false
}
},
... ... @@ -92,7 +91,7 @@ var C_ID, RES_QTY, argument, optype, filext = {};
var category = $('#category-point').val();
var noResult = '<p class="no-result">未找到相关搜索结果</p>';
var noResultHbs = require('product/search/no-result-new.hbs');
require('common');
... ... @@ -100,7 +99,8 @@ C_ID = window._ChannelVary[window.cookie('_Channel')];
// 首屏无数据
if ($fsgc.children().length === 0) {
$goodsContainer.html(noResult);
$goodsContainer.html(noResultHbs());
window.rePosFooter();
}
ellipsis.init();
... ... @@ -240,7 +240,7 @@ gender = getQueryString('gender');
price = getQueryString('price');
p_d = getQueryString('p_d');
brand = getQueryString('brand');
query = getQueryString('query');
query = $('.query-param[data-attr="query"]').val() || getQueryString('query');
limited = getQueryString('limited');
specialoffer = getQueryString('specialoffer');
specialsale_id = getQueryString('specialsale_id');
... ... @@ -406,9 +406,8 @@ function search(opt) {
if (nav.reload) {
page = 1;
} else if (nav.end) {
$('.search-divide').remove();
// 不需要重新加载并且数据请求结束
$('.search-divide').remove();
return;
}
... ... @@ -586,7 +585,7 @@ function search(opt) {
nav.end = true;
if (nav.reload) {
if (data.total === 0) {
$container.html(noResult);
$container.html(noResultHbs());
}
yasparm = Object.assign(yasparm, {
... ... @@ -752,7 +751,6 @@ if ($brandHeader.data('isbaseshop') === true) {
Object.assign(defaultOpt, {shop_id: $brandHeader.data('id')});
}
// console.log(defaultOpt)
(function() {
var pars = {};
... ... @@ -874,88 +872,6 @@ $listNav.bind('contextmenu', function() {
return false;
});
function newListHide() {
var $firstLi = $listNav.find('li.first-li-more');
if ($newList.hasClass('hide')) {
$firstLi.find('span.up').addClass('hide');
$firstLi.find('span.down').removeClass('hide');
} else {
$firstLi.find('span.down').addClass('hide');
$firstLi.find('span.up').removeClass('hide');
}
}
$newList.on('touchstart', 'li', function(e) {
var navType, bpIdData = $(this).attr('data-bp-id') || '',
$firstLiDom = $listNav.find('li.first-li-more');
e.preventDefault();
if ($(this).hasClass('new')) {
navType = 'new';
} else if ($(this).hasClass('default')) {
navType = 'default';
} else if ($(this).hasClass('sale')) {
navType = 'sale';
}
$newList.addClass('hide');
$firstLiDom.find('.nav-txt').text($(this).text());
$firstLiDom.attr('data-bp-id', bpIdData).addClass('active').siblings().removeClass('active');
$listNav.find('.first-li-more').removeClass('new default sale').addClass(navType);
$(document).trigger('shouldSendBpData', [bpIdData]);
newListHide();
if (navType !== 'default') {
$fsgc.addClass('hide');
}
if ($(this).hasClass('active')) {
return;
}
// 切换container显示
$goodsContainer.children('.container:not(.hide)').addClass('hide');
switch (navType) {
case 'new':
$ngc.removeClass('hide');
break;
case 'price':
$pgc.removeClass('hide');
break;
case 'discount':
$dgc.removeClass('hide');
break;
case 'default':
$defaultgc.removeClass('hide');
$fsgc.removeClass('hide');
break;
case 'sale':
$sgc.removeClass('hide');
break;
default:
break;
}
$pre = $firstLiDom;
search({filtering: true});
});
$(document).on('touchstart', function(e) {
if (!$newList.hasClass('hide') &&
$(e.target).closest('.new-list, li.first-li-more').length <= 0) {
$newList.addClass('hide');
newListHide();
}
});
$listNav.on('touchend touchcancel', function(e) {
var $this = $(e.target).closest('li'),
nav,
... ... @@ -963,23 +879,6 @@ $listNav.on('touchend touchcancel', function(e) {
$active;
var bpIdData = $(this).find('.buriedpoint').attr('data-bp-id') || '';
if ($this.hasClass('first-li-more')) {
filter.hideFilter();
$newList.toggleClass('hide');
if ($this.hasClass('default')) {
$newList.find('li.default').addClass('active').siblings().removeClass('active');
} else if ($this.hasClass('new')) {
$newList.find('li.new').addClass('active').siblings().removeClass('active');
} else if ($this.hasClass('sale')) {
$newList.find('li.sale').addClass('active').siblings().removeClass('active');
}
newListHide();
return true;
}
// 最新li 列表
$newList.addClass('hide');
if ($this.hasClass('filter')) {
// 筛选面板切换状态
... ... @@ -1015,8 +914,8 @@ $listNav.on('touchend touchcancel', function(e) {
if ($this.hasClass('active')) {
// 最新无排序切换
if ($this.hasClass('new')) {
// 默认、最新无排序切换
if ($this.hasClass('default') || $this.hasClass('new')) {
return;
}
... ... @@ -1073,7 +972,7 @@ $listNav.on('touchend touchcancel', function(e) {
}
if (nav.reload) {
$(document).trigger('shouldSendBpData', [bpIdData]);
search({filtering: true});
search();
}
}
});
... ... @@ -1228,3 +1127,5 @@ $('#goods-container').on('click', '.good-info', function() {
var fuckNum = $('.good-info').length;
fuckNum < 12 && $('.search-divide').remove();
require('channel/maybe-like')(true);
... ...
... ... @@ -122,12 +122,14 @@ var defaultOpt = require('../common/query-param');
filter.initFilter({
fCbFn: search,
hCbFn: function() {
$('.filter ').removeClass('active');
// 切换active状态到$pre上
$pre.addClass('active');
$('#pos-list').addClass('hide');
$pre.siblings('.filter').removeClass('active');
scrollHandler();
subNavScrollTo();
}
});
... ... @@ -151,7 +153,7 @@ var $listNav = $('#list-nav'),
default: {
order: 0,
reload: true,
page: 1,
page: 0,
end: false
},
hot: {
... ... @@ -187,11 +189,6 @@ var viewType = 1, // 1-首页,2-上新,3-人气
listModValue = 4 - listCount % 4,
listIndex;
// $('.main-wrap').css({
// position: 'static'
// });
// 焦点效果
if ($('.banner-swiper').find('li').size() > 1) {
bannerSwiper = new Swiper('.banner-swiper', {
... ... @@ -445,22 +442,6 @@ function scrollHandler(e) {
}
}
document.addEventListener('touchmove', function(e) {
// sub classify不阻止默认事件
if ($(e.target).closest('.sub-classify').length === 0) {
// e.preventDefault();
}
if ($('.filter-mask').length && !$('.filter-mask').hasClass('hide')) {
// e.preventDefault();
// e.stopPropagation();
}
}, false);
/* if (!isIphone) {
return;
}*/
// window ready 后重新refresh iscroll
$(window).ready(function() {
// myScroll && myScroll.refresh();
... ... @@ -683,42 +664,20 @@ function search(opt, callback) {
$listNav.bind('contextmenu', function(e) {
return false;
});
function newListHide() {
var $firstLi = $listNav.find('li.first-li-more');
if ($newList.hasClass('hide')) {
$firstLi.find('span.up').addClass('hide');
$firstLi.find('span.down').removeClass('hide');
} else {
$firstLi.find('span.down').addClass('hide');
$firstLi.find('span.up').removeClass('hide');
}
}
$newList.on('touchstart', 'li', function(e) {
var navType, bpIdData = $(this).attr('data-bp-id') || '',
$firstLiDom = $subNav.find('li.first-li-more'),
cls = '';
var navType, bpIdData = $(this).attr('data-bp-id') || '';
e.preventDefault();
if ($(this).hasClass('new')) {
navType = 'newest';
cls = 'new';
} else if ($(this).hasClass('default')) {
navType = 'default';
cls = 'default';
} else if ($(this).hasClass('sale')) {
navType = 'sale';
cls = 'sale';
}
$newList.addClass('hide');
$('#pos-list').addClass('hide');
$firstLiDom.find('.nav-txt').text($(this).text());
$firstLiDom.attr('data-bp-id', bpIdData).addClass('active').siblings().removeClass('active');
$subNav.find('.first-li-more').removeClass('new default sale').addClass(cls);
$(document).trigger('shouldSendBpData', [bpIdData]);
newListHide();
// 切换container显示
$goodsContainer.children('.container:not(.hide)').addClass('hide');
... ... @@ -738,15 +697,10 @@ $newList.on('touchstart', 'li', function(e) {
case 'default':
$defaultgc.removeClass('hide');
break;
case 'sale':
$sgc.removeClass('hide');
break;
default:
break;
}
$pre = $('.first-li-more');
var nav = navInfo[navType];
if (nav.reload) {
... ... @@ -765,13 +719,6 @@ $newList.on('touchstart', 'li', function(e) {
});
$(document).on('touchstart', function(e) {
if (!$newList.hasClass('hide') &&
$(e.target).closest('.new-list, li.first-li-more').length <= 0) {
$newList.addClass('hide');
newListHide();
}
});
function subNavScrollTo() {
setTimeout(function() {
window.scrollTo(0, $('#list-nav').offset().top + 5);
... ... @@ -791,145 +738,118 @@ $subNav.on('touchend touchcancel', function(e) {
if (typeof $this === 'undefined' || $this.length === 0) {
return;
}
if ($this.hasClass('first-li-more')) {
filter.hideFilter();
$newList.toggleClass('hide');
if ($('#pos-list').hasClass('hide')) {
$newList.removeClass('classics');
} else {
$newList.addClass('classics');
}
if ($this.hasClass('default')) {
$newList.find('li.default').addClass('active').siblings().removeClass('active');
} else if ($this.hasClass('new')) {
$newList.find('li.new').addClass('active').siblings().removeClass('active');
} else if ($this.hasClass('sale')) {
$newList.find('li.sale').addClass('active').siblings().removeClass('active');
}
newListHide();
} else {
// 最新li 列表
$newList.addClass('hide');
// 最新li 列表
$newList.addClass('hide');
if ($this.hasClass('filter')) {
if ($this.hasClass('filter')) {
// 筛选面板切换状态
if ($this.hasClass('active') && !$('.filter-mask').hasClass('hide')) {
$('.home-sub-nav>li.filter').removeClass('active');
$this.removeClass('active');
filter.hideFilter();
// 筛选面板切换状态
if ($this.hasClass('active') && !$('.filter-mask').hasClass('hide')) {
$('.home-sub-nav>li.filter').removeClass('active');
$this.removeClass('active');
filter.hideFilter();
} else {
$('.home-sub-nav>li.filter').addClass('active');
$this.addClass('active');
filter.showFilter();
if ($this.closest('.pos-list').length > 0) {
$('.filter-mask').addClass('call-by-fix').css('top', '');
} else {
$('.home-sub-nav>li.filter').addClass('active');
$this.addClass('active');
$('.filter-mask').removeClass('call-by-fix').css('top', $this.offset().top + nav1H);
}
if ($('#pos-list').hasClass('hide')) {
$('#pos-list').removeClass('hide');
}
}
subNavScrollTo();
} else {
filter.showFilter();
filter.hideFilter();// 隐藏面板
if ($this.hasClass('new')) {
cname = '.new';
navType = 'newest';
} else if ($this.hasClass('price')) {
cname = '.price';
navType = 'price';
} else if ($this.hasClass('discount')) {
cname = '.discount';
navType = 'discount';
} else if ($this.hasClass('default')) {
cname = '.default';
navType = 'default';
}
if ($this.closest('.pos-list').length > 0) {
$('.filter-mask').addClass('call-by-fix').css('top', '');
} else {
$('.filter-mask').removeClass('call-by-fix').css('top', $this.offset().top + nav1H);
}
if ($('#pos-list').hasClass('hide')) {
$('#pos-list').removeClass('hide');
}
nav = navInfo[navType];
var reloadCb = function() {
$goodsContainer.children('.container:not(.hide)').addClass('hide');
switch (navType) {
case 'newest':
$ngc.removeClass('hide');
break;
case 'price':
$pgc.removeClass('hide');
break;
case 'discount':
$dgc.removeClass('hide');
break;
case 'default':
$defaultgc.removeClass('hide');
break;
default:
break;
}
} else {
};
filter.hideFilter();// 隐藏面板
if ($this.hasClass('active')) {
// 最新无排序切换
if ($this.hasClass('new')) {
cname = '.new';
navType = 'newest';
} else if ($this.hasClass('price')) {
cname = '.price';
navType = 'price';
} else if ($this.hasClass('discount')) {
cname = '.discount';
navType = 'discount';
} else if ($this.hasClass('default')) {
cname = '.default';
navType = 'default';
return;
}
nav = navInfo[navType];
var reloadCb = function() {
$goodsContainer.children('.container:not(.hide)').addClass('hide');
switch (navType) {
case 'newest':
$ngc.removeClass('hide');
break;
case 'price':
$pgc.removeClass('hide');
break;
case 'discount':
$dgc.removeClass('hide');
break;
case 'default':
$defaultgc.removeClass('hide');
break;
default:
break;
}
};
if ($this.hasClass('price') || $this.hasClass('discount')) {
$this = $subNav.find(cname);
if ($this.hasClass('active')) {
// 最新无排序切换
if ($this.hasClass('new')) {
return;
}
// 价格/折扣切换排序状态
$this.find('.icon > .iconfont').toggleClass('cur');
nav.reload = true; // 重置reload,HTML会被替换为逆序的HTML
nav.order = nav.order === 0 ? 1 : 0; // 切换排序
if ($this.hasClass('price') || $this.hasClass('discount')) {
$this = $subNav.find(cname);
// 价格/折扣切换排序状态
$this.find('.icon > .iconfont').toggleClass('cur');
nav.reload = true; // 重置reload,HTML会被替换为逆序的HTML
nav.order = nav.order === 0 ? 1 : 0; // 切换排序
}
} else {
$active = $subNav.find('.active');
}
} else {
$active = $subNav.find('.active');
if ($active.hasClass('filter')) {
if ($active.hasClass('filter')) {
// 若之前active项为筛选,则隐藏筛选面板
filter.hideFilter();
}
$subNav.children().removeClass('active');
$subNav.find(cname).addClass('active');
}
if (!$('#pos-list').hasClass('hide')) {
subNavScrollTo();
}
if (nav.reload) {
search({
type: 'shop_id',
id: shopId,
brand: brand,
appVersion: appVersion,
url: '/product/search/search',
nextPage: false
}, reloadCb);
// 若之前active项为筛选,则隐藏筛选面板
filter.hideFilter();
}
$subNav.children().removeClass('active');
$subNav.find(cname).addClass('active');
}
if (!$('#pos-list').hasClass('hide')) {
subNavScrollTo();
}
if (nav.reload) {
search({
type: 'shop_id',
id: shopId,
brand: brand,
appVersion: appVersion,
url: '/product/search/search',
nextPage: false
}, reloadCb);
}
}
if ($('#list-nav').offset().top > $(document).scrollTop() && $('.filter-mask').hasClass('hide')) {
if ($this.hasClass('first-li-more') && !$('#pos-list').hasClass('hide')) {
if ($('.new-list').hasClass('hide')) {
$('.new-list').removeClass('full-height');
$('#pos-list').addClass('hide');
} else {
$('.new-list').addClass('full-height');
}
} else {
$('#pos-list').addClass('hide');
}
$('#pos-list').addClass('hide');
} else {
$('.new-list').removeClass('full-height');
}
... ... @@ -942,7 +862,6 @@ $listNav.on('touchstart', 'li', function(e) {
$(this).addClass('bytouch');
}).on('touchend touchcancel', function() {
$listNav.find('li').removeClass('bytouch');
});
$nav2.on('touchstart', 'li', function(e) {
... ...
... ... @@ -19,7 +19,7 @@ var $brandHeader = $('#brand-header'),
var filter = require('plugin/filter');
var writeSearch = require('../search/write-search');
var noResultHbs = require('product/search/no-result-new.hbs');
var tip = require('plugin/tip');
var loading = require('plugin/loading');
... ... @@ -28,8 +28,7 @@ var $goodsContainer = $('#goods-container'),
$sgc = $goodsContainer.children('.sale-goods'),
$ngc = $goodsContainer.children('.new-goods'),
$pgc = $goodsContainer.children('.price-goods'),
$dgc = $goodsContainer.children('.discount-goods'),
$newList = $('.new-list');
$dgc = $goodsContainer.children('.discount-goods');
var winH = $(window).height();
... ... @@ -52,13 +51,13 @@ var $listNav = $('#list-nav'),
newest: {
order: 0,
reload: true,
page: 1,
page: 0,
end: false
},
default: {
order: 0,
reload: true,
page: 1,
page: 0,
end: false
},
price: {
... ... @@ -389,8 +388,7 @@ function search(opt) {
withCredentials: true
},
success: function(data) {
var noResult = '<p class="no-result">未找到相关搜索结果</p>',
num,
var num,
$container,
goodIds = [],
yasparm;
... ... @@ -425,7 +423,7 @@ function search(opt) {
nav.end = true;
if (nav.reload) {
$container.html(noResult);
$container.html(noResultHbs());
yasparm = Object.assign(yasparm, {
PRD_LIST: '',
... ... @@ -601,85 +599,7 @@ writeSearch.bindWirteLocal($('#search-form'));
$listNav.bind('contextmenu', function() {
return false;
});
function newListHide() {
var $firstLi = $listNav.find('li.first-li-more');
if ($newList.hasClass('hide')) {
$firstLi.find('span.up').addClass('hide');
$firstLi.find('span.down').removeClass('hide');
} else {
$firstLi.find('span.down').addClass('hide');
$firstLi.find('span.up').removeClass('hide');
}
}
$newList.on('touchstart', 'li', function(e) {
var navType, bpIdData = $(this).attr('data-bp-id') || '',
$firstLiDom = $listNav.find('li.first-li-more'),
cls = '';
e.preventDefault();
if ($(this).hasClass('new')) {
navType = 'newest';
cls = 'new';
} else if ($(this).hasClass('default')) {
navType = 'default';
cls = 'default';
} else if ($(this).hasClass('sale')) {
navType = 'sale';
cls = 'sale';
}
$newList.addClass('hide');
$firstLiDom.find('.nav-txt').text($(this).text());
$firstLiDom.attr('data-bp-id', bpIdData).addClass('active').siblings().removeClass('active');
$listNav.find('.first-li-more').removeClass('new default sale').addClass(cls);
$(document).trigger('shouldSendBpData', [bpIdData]);
newListHide();
// 切换container显示
$goodsContainer.children('.container:not(.hide)').addClass('hide');
switch (navType) {
case 'newest':
$ngc.removeClass('hide');
break;
case 'price':
$pgc.removeClass('hide');
break;
case 'discount':
$dgc.removeClass('hide');
break;
case 'default':
$defaultgc.removeClass('hide');
break;
case 'sale':
$sgc.removeClass('hide');
break;
default:
break;
}
$pre = $('.first-li-more');
var nav = navInfo[navType];
if (nav.reload) {
search();
}
});
$(document).on('touchstart', function(e) {
if (!$newList.hasClass('hide') &&
$(e.target).closest('.new-list, li.first-li-more').length <= 0) {
$newList.addClass('hide');
newListHide();
}
});
$listNav.on('touchend touchcancel', function(e) {
var $this = $(e.target).closest('li'),
nav,
... ... @@ -687,23 +607,6 @@ $listNav.on('touchend touchcancel', function(e) {
$active;
var bpIdData = $(this).find('.buriedpoint').attr('data-bp-id') || '';
if ($this.hasClass('first-li-more')) {
filter.hideFilter();
$newList.toggleClass('hide');
if ($this.hasClass('default')) {
$newList.find('li.default').addClass('active').siblings().removeClass('active');
} else if ($this.hasClass('new')) {
$newList.find('li.new').addClass('active').siblings().removeClass('active');
} else if ($this.hasClass('sale')) {
$newList.find('li.sale').addClass('active').siblings().removeClass('active');
}
newListHide();
return true;
}
// 最新li 列表
$newList.addClass('hide');
if ($this.hasClass('filter')) {
// 筛选面板切换状态
... ... @@ -729,7 +632,7 @@ $listNav.on('touchend touchcancel', function(e) {
navType = 'price';
} else if ($this.hasClass('discount')) {
navType = 'discount';
} else if ($pre.hasClass('default')) {
} else if ($this.hasClass('default')) {
navType = 'default';
}
... ... @@ -737,8 +640,8 @@ $listNav.on('touchend touchcancel', function(e) {
if ($this.hasClass('active')) {
// 最新无排序切换
if ($this.hasClass('new')) {
// 默认、最新无排序切换
if ($this.hasClass('default') || $this.hasClass('new')) {
return;
}
... ... @@ -917,3 +820,5 @@ $('#goods-container').on('click', '.good-info', function() {
// return false;
});
require('channel/maybe-like')(true);
... ...
... ... @@ -5,7 +5,7 @@
> li {
float: left;
width: 25%;
width: 20%;
height: 66px;
text-align: center;
font-size: 28px;
... ...
... ... @@ -216,7 +216,7 @@
> li {
float: left;
width: 25%;
width: 20%;
height: 33PX;
line-height: 33PX;
text-align: center;
... ... @@ -297,7 +297,7 @@
.goods-container {
position: relative;
min-height: 880px;
min-height: auto;
padding-left: 0.375rem;
padding-top: 0.2rem;
}
... ... @@ -332,7 +332,13 @@
bottom: 258px;
}
/*搜索分割*/
/* 搜索分割 */
.intro-text,
.word-content {
margin-left: -0.375rem;
margin-top: -0.2rem;
}
.search-divide {
float: left;
height: 50px;
... ... @@ -341,4 +347,52 @@
color: #ccc;
text-align: center;
}
}
\ No newline at end of file
/* 搜索数据太小,分词 */
.list-too-little {
padding: 25px 20px;
border-bottom: 1px solid #e6e6e6;
color: #444;
font-size: 24px;
.word {
display: inline-block;
padding: 5px 15px;
border-radius: 10px;
border: 1px solid #bbb;
margin-right: 13px;
margin-top: 10px;
}
}
/* 搜索页-新版搜索无结果样式 */
.no-result-new {
height: 190px;
text-align: center;
padding-top: 30px;
padding-bottom: 90px;
p {
color: #ccc;
margin-bottom: 25px;
&:first-child {
color: #4b4b4b;
}
}
}
/* 搜索页-猜你喜欢的 */
.maybe-like-search {
height: 60px;
line-height: 60px;
background-color: #eee;
text-align: center;
font-size: 16px;
}
.maybe-like-goods {
min-height: 500px;
overflow: hidden;
}
}
... ...
... ... @@ -41,11 +41,11 @@
font-size: 14PX;
line-height: 14PX;
}
}
&:first-child {
.text {
border-left: none;
}
li:first-child {
.text {
border-left: none;
}
}
}
... ... @@ -363,7 +363,6 @@
.goods-container {
position: relative;
min-height: 440px;
/* padding-left: 15px; */
padding-top: 20px;
border-bottom: 1px solid #e0e0e0;
}
... ... @@ -383,19 +382,6 @@
-webkit-transform: scale(0.8);
font-weight: bold;
}
.default:after,
.newest:after,
.new:after,
.price:after,
.discount:after {
height: 28px;
content: "";
border-left: 1px solid #e0e0e0;
position: absolute;
top: 25px;
left: 163px;
}
}
.discount-area {
... ... @@ -411,7 +397,7 @@
height: 40PX;
float: left;
line-height: 40PX;
width: 24.8%;
width: 20%;
text-align: center;
border-sizing: border-box;
position: relative;
... ... @@ -420,33 +406,12 @@
padding-top: 0;
font-size: 14PX;
}
&.default:after,
&.newest:after,
&.new:after,
&.price:after,
&.discount:after {
height: 28px;
content: "";
border-left: 1px solid #e0e0e0;
position: absolute;
top: 25px;
left: 163px;
}
}
.active .cur {
color: #444;
}
.list-nav .icon .up {
top: -14PX;
}
.list-nav .icon .down {
top: -7PX;
}
.goods-container {
padding-top: 30px;
padding-bottom: 100px;
... ... @@ -567,7 +532,7 @@
height: 40PX;
float: left;
line-height: 40PX;
width: 24.8%;
width: 20%;
text-align: center;
border-sizing: border-box;
... ... @@ -580,8 +545,11 @@
box-sizing: border-box;
text-align: center;
width: 100%;
height: 100%;
color: #b0b0b0;
border-left: 1px solid #e0e0e0;
height: 14PX;
line-height: 14PX;
margin-top: 14PX;
}
}
... ... @@ -613,14 +581,6 @@
}
}
.pos-list .icon .up {
top: -14PX;
}
.pos-list .icon .down {
top: -7PX;
}
.category-list-top-board {
border-top: 1px solid #e0e0e0;
}
... ...
... ... @@ -196,6 +196,26 @@ exports.processProductList = (list, options) => {
return pruductList;
};
/**
* 分词数据处理
* @param list
* @param string | options
* @return array 处理之后的筛选数据
*/
exports.termsSuggestion = (list, options) => {
let termsSuggestion = [];
_.each(list, (terms, index) => {
termsSuggestion.push({
name: terms,
link: helpers.urlFormat('/', {needSuggestion: 'Y', query: terms}, 'search'),
select: (options.isChangedQuery && index === 0) ||
(options.needSuggestion === 'Y' && terms === decodeURIComponent(options.query))
});
});
return termsSuggestion;
};
/**
* 处理筛选数据
... ...