Authored by 刘传洋

search bug

... ... @@ -37,7 +37,18 @@ const getProductList = (params) => {
limit: 60
};
Object.assign(finalParams, params);
let nparams = {};
if(params && params.price) {
let mp = params.price.split(',');
let nmp = [];
nmp[0] = (mp && mp[0]) || 0;
nmp[1] = (mp && mp[1]) || 99999;
nparams.price = nmp.join(',');
}
Object.assign(finalParams, params, nparams);
return yohoApi.get('', finalParams);
};
... ...
... ... @@ -357,8 +357,8 @@ exports.handleSortData = (origin, params) => {
{
name: `全部${value.sort_name}`,
num: value.count,
href: handleFilterUrl(params, {msort: value.sort_id}),
childActive: params.misort === value.sort_id
href: handleFilterUrl(params, {msort: value.sort_id}, {misort : true}),
childActive: (params.msort === value.sort_id) && !params.misort
}
],
href: handleFilterUrl(params, {msort: value.sort_id}),
... ...
... ... @@ -43,14 +43,14 @@ exports.getSearchData = (params) => {
// 获取左侧类目数据
if (result[1].code === 200) {
finalResult.search = {
leftContent: searchHandler.handleSortData(result[1].data.sort, params),
pathNav: searchHandler.handlePathNavData({total: result[1].data.total }, params, 'search')
leftContent: searchHandler.handleSortData(result[1].data.sort, params)
};
}
// 获取商品数据和顶部筛选条件
if (result[2].code === 200) {
Object.assign(finalResult.search, {
pathNav: searchHandler.handlePathNavData({total: result[2].data.total }, params, 'search'),
filters: searchHandler.handleFilterData(result[2].data.filter, params),
opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
totalCount: result[2].data.total,
... ... @@ -58,7 +58,8 @@ exports.getSearchData = (params) => {
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params)),
latestWalk: 7,
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total)
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total)//,
//brandBanner : isset($data['brand']) && !empty($data['brand']) ? self::getBannerFormat($data['brand'], $options['brandBanner']) : array();
});
}
return finalResult;
... ...
... ... @@ -259,6 +259,16 @@
</div>
\{{/carData}}
</script>
<script type="text/html" id="search-suggest-tml">
\{{#data}}
<li>
<a style="display: block;" href="\{{href}}" class="clearfix clear search-item" title="\{{keyword}}" act="\{{href}}">
<span class="searchvalue" >\{{keyword}}</span>
<span class="valuenum">约\{{count}}个商品</span>
</a>
</li>
\{{/data}}
</script>
</div>
<input id="api-domain" type="hidden" value="{{apiDomain}}">
... ...
... ... @@ -744,4 +744,38 @@ window.submitSearch = function() {
}
};
/**
* 查询跳转后保留关键字
* @return {[type]} [description]
*/
function actionAddKeyWords() {
var $keywords = $('#nav_keyword').text();
var defaultsearch = $('#defaultsearch').val();
var $querykey = $('#query-key');
if ($keywords !== '') {
$querykey.css({
color: '#000'
});
$querykey.val($keywords);
} else {
$querykey.css({
color: '#e0e0e0'
});
$querykey.val(defaultsearch);
$querykey.on('focus', function(e) {
$querykey.css({
color: '#000'
});
$querykey.val('');
});
}
$(document).click(function(e) {
if (!$(e.target).closest('.searchspan, .search-list').length) {
$('.search-list').hide();
}
});
}
actionCover();
actionAddKeyWords();
\ No newline at end of file
... ...