Authored by 刘传洋

search bug

@@ -37,7 +37,18 @@ const getProductList = (params) => { @@ -37,7 +37,18 @@ const getProductList = (params) => {
37 limit: 60 37 limit: 60
38 }; 38 };
39 39
40 - Object.assign(finalParams, params); 40 + let nparams = {};
  41 +
  42 + if(params && params.price) {
  43 + let mp = params.price.split(',');
  44 + let nmp = [];
  45 +
  46 + nmp[0] = (mp && mp[0]) || 0;
  47 + nmp[1] = (mp && mp[1]) || 99999;
  48 + nparams.price = nmp.join(',');
  49 + }
  50 +
  51 + Object.assign(finalParams, params, nparams);
41 return yohoApi.get('', finalParams); 52 return yohoApi.get('', finalParams);
42 }; 53 };
43 54
@@ -357,8 +357,8 @@ exports.handleSortData = (origin, params) => { @@ -357,8 +357,8 @@ exports.handleSortData = (origin, params) => {
357 { 357 {
358 name: `全部${value.sort_name}`, 358 name: `全部${value.sort_name}`,
359 num: value.count, 359 num: value.count,
360 - href: handleFilterUrl(params, {msort: value.sort_id}),  
361 - childActive: params.misort === value.sort_id 360 + href: handleFilterUrl(params, {msort: value.sort_id}, {misort : true}),
  361 + childActive: (params.msort === value.sort_id) && !params.misort
362 } 362 }
363 ], 363 ],
364 href: handleFilterUrl(params, {msort: value.sort_id}), 364 href: handleFilterUrl(params, {msort: value.sort_id}),
@@ -43,14 +43,14 @@ exports.getSearchData = (params) => { @@ -43,14 +43,14 @@ exports.getSearchData = (params) => {
43 // 获取左侧类目数据 43 // 获取左侧类目数据
44 if (result[1].code === 200) { 44 if (result[1].code === 200) {
45 finalResult.search = { 45 finalResult.search = {
46 - leftContent: searchHandler.handleSortData(result[1].data.sort, params),  
47 - pathNav: searchHandler.handlePathNavData({total: result[1].data.total }, params, 'search') 46 + leftContent: searchHandler.handleSortData(result[1].data.sort, params)
48 }; 47 };
49 } 48 }
50 49
51 // 获取商品数据和顶部筛选条件 50 // 获取商品数据和顶部筛选条件
52 if (result[2].code === 200) { 51 if (result[2].code === 200) {
53 Object.assign(finalResult.search, { 52 Object.assign(finalResult.search, {
  53 + pathNav: searchHandler.handlePathNavData({total: result[2].data.total }, params, 'search'),
54 filters: searchHandler.handleFilterData(result[2].data.filter, params), 54 filters: searchHandler.handleFilterData(result[2].data.filter, params),
55 opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter), 55 opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
56 totalCount: result[2].data.total, 56 totalCount: result[2].data.total,
@@ -58,7 +58,8 @@ exports.getSearchData = (params) => { @@ -58,7 +58,8 @@ exports.getSearchData = (params) => {
58 goods: productProcess.processProductList(result[2].data.product_list, 58 goods: productProcess.processProductList(result[2].data.product_list,
59 Object.assign({showDiscount: false}, params)), 59 Object.assign({showDiscount: false}, params)),
60 latestWalk: 7, 60 latestWalk: 7,
61 - hasNextPage: searchHandler.handleNextPage(params, result[2].data.total) 61 + hasNextPage: searchHandler.handleNextPage(params, result[2].data.total)//,
  62 + //brandBanner : isset($data['brand']) && !empty($data['brand']) ? self::getBannerFormat($data['brand'], $options['brandBanner']) : array();
62 }); 63 });
63 } 64 }
64 return finalResult; 65 return finalResult;
@@ -259,6 +259,16 @@ @@ -259,6 +259,16 @@
259 </div> 259 </div>
260 \{{/carData}} 260 \{{/carData}}
261 </script> 261 </script>
  262 + <script type="text/html" id="search-suggest-tml">
  263 + \{{#data}}
  264 + <li>
  265 + <a style="display: block;" href="\{{href}}" class="clearfix clear search-item" title="\{{keyword}}" act="\{{href}}">
  266 + <span class="searchvalue" >\{{keyword}}</span>
  267 + <span class="valuenum">约\{{count}}个商品</span>
  268 + </a>
  269 + </li>
  270 + \{{/data}}
  271 + </script>
262 </div> 272 </div>
263 273
264 <input id="api-domain" type="hidden" value="{{apiDomain}}"> 274 <input id="api-domain" type="hidden" value="{{apiDomain}}">
@@ -744,4 +744,38 @@ window.submitSearch = function() { @@ -744,4 +744,38 @@ window.submitSearch = function() {
744 } 744 }
745 }; 745 };
746 746
  747 +/**
  748 + * 查询跳转后保留关键字
  749 + * @return {[type]} [description]
  750 + */
  751 +function actionAddKeyWords() {
  752 + var $keywords = $('#nav_keyword').text();
  753 + var defaultsearch = $('#defaultsearch').val();
  754 + var $querykey = $('#query-key');
  755 +
  756 + if ($keywords !== '') {
  757 + $querykey.css({
  758 + color: '#000'
  759 + });
  760 + $querykey.val($keywords);
  761 + } else {
  762 + $querykey.css({
  763 + color: '#e0e0e0'
  764 + });
  765 + $querykey.val(defaultsearch);
  766 + $querykey.on('focus', function(e) {
  767 + $querykey.css({
  768 + color: '#000'
  769 + });
  770 + $querykey.val('');
  771 + });
  772 + }
  773 + $(document).click(function(e) {
  774 + if (!$(e.target).closest('.searchspan, .search-list').length) {
  775 + $('.search-list').hide();
  776 + }
  777 + });
  778 +}
  779 +
747 actionCover(); 780 actionCover();
  781 +actionAddKeyWords();