Showing
1 changed file
with
4 additions
and
1 deletions
@@ -70,6 +70,8 @@ function searchResult() { | @@ -70,6 +70,8 @@ function searchResult() { | ||
70 | i = 0, | 70 | i = 0, |
71 | html = ''; | 71 | html = ''; |
72 | 72 | ||
73 | + if (keyword !== '') { | ||
74 | + | ||
73 | // 遍历首字母搜索 | 75 | // 遍历首字母搜索 |
74 | $.each(brandsData, function(k, v) { | 76 | $.each(brandsData, function(k, v) { |
75 | if ($.isArray(v)) { | 77 | if ($.isArray(v)) { |
@@ -107,6 +109,7 @@ function searchResult() { | @@ -107,6 +109,7 @@ function searchResult() { | ||
107 | html += brandHtml.join(''); | 109 | html += brandHtml.join(''); |
108 | 110 | ||
109 | }); | 111 | }); |
112 | + } | ||
110 | 113 | ||
111 | // 插入 dom,绑定事件 | 114 | // 插入 dom,绑定事件 |
112 | $('.search-result').html(html); | 115 | $('.search-result').html(html); |
@@ -118,7 +121,6 @@ if ($('.brand-search-page').length) { | @@ -118,7 +121,6 @@ if ($('.brand-search-page').length) { | ||
118 | 121 | ||
119 | $keyword.on('input', function() { | 122 | $keyword.on('input', function() { |
120 | if ($keyword.val().length) { | 123 | if ($keyword.val().length) { |
121 | - searchResult(); | ||
122 | $icon.css('color', '#000'); | 124 | $icon.css('color', '#000'); |
123 | $(this).closest('.search-box').css('width', '11.25rem'); | 125 | $(this).closest('.search-box').css('width', '11.25rem'); |
124 | $('.search-action').show(); | 126 | $('.search-action').show(); |
@@ -127,6 +129,7 @@ if ($('.brand-search-page').length) { | @@ -127,6 +129,7 @@ if ($('.brand-search-page').length) { | ||
127 | $(this).closest('.search-box').css('width', '12.5rem'); | 129 | $(this).closest('.search-box').css('width', '12.5rem'); |
128 | $('.search-action').hide(); | 130 | $('.search-action').hide(); |
129 | } | 131 | } |
132 | + searchResult(); | ||
130 | }).focus(); | 133 | }).focus(); |
131 | 134 | ||
132 | clearTextHammer = new Hammer($('.clear-text')[0]); | 135 | clearTextHammer = new Hammer($('.clear-text')[0]); |
-
Please register or login to post a comment