Authored by hf

Merge branch 'develop'

... ... @@ -70,43 +70,46 @@ function searchResult() {
i = 0,
html = '';
// 遍历首字母搜索
$.each(brandsData, function(k, v) {
if ($.isArray(v)) {
if (keyword !== '') {
// 遍历首字母搜索
$.each(brandsData, function(k, v) {
if ($.isArray(v)) {
// 遍历品牌,进行匹配
$.each(v, function(i, brand) {
if (brand.name.toLowerCase().indexOf(keyword) > -1) {
result[k] = result[k] || [];
result[k].push(brand);
}
});
}
});
// 遍历品牌,进行匹配
// 根据搜索结果生成 HTML
$.each(result, function(k, v) {
var brandHtml = ['<div class="brand-list bar-', i, '">'];
i++;
brandHtml.push('<div class="title-bar"><h2>');
brandHtml.push(k);
brandHtml.push('</h2></div>');
$.each(v, function(i, brand) {
if (brand.name.toLowerCase().indexOf(keyword) > -1) {
result[k] = result[k] || [];
result[k].push(brand);
brandHtml.push('<p><a href="' + brand.url + '">' + brand.name);
if (brand.isNew) {
brandHtml.push('<i class="icon-hot">HOT</i>');
}
if (brand.isHot) {
brandHtml.push('<i class="icon-new">NEW</i>');
}
brandHtml.push('</a></p>');
});
}
});
brandHtml.push('</div>');
html += brandHtml.join('');
// 根据搜索结果生成 HTML
$.each(result, function(k, v) {
var brandHtml = ['<div class="brand-list bar-', i, '">'];
i++;
brandHtml.push('<div class="title-bar"><h2>');
brandHtml.push(k);
brandHtml.push('</h2></div>');
$.each(v, function(i, brand) {
brandHtml.push('<p><a href="' + brand.url + '">' + brand.name);
if (brand.isNew) {
brandHtml.push('<i class="icon-hot">HOT</i>');
}
if (brand.isHot) {
brandHtml.push('<i class="icon-new">NEW</i>');
}
brandHtml.push('</a></p>');
});
brandHtml.push('</div>');
html += brandHtml.join('');
});
}
// 插入 dom,绑定事件
$('.search-result').html(html);
... ... @@ -118,7 +121,6 @@ if ($('.brand-search-page').length) {
$keyword.on('input', function() {
if ($keyword.val().length) {
searchResult();
$icon.css('color', '#000');
$(this).closest('.search-box').css('width', '11.25rem');
$('.search-action').show();
... ... @@ -127,6 +129,7 @@ if ($('.brand-search-page').length) {
$(this).closest('.search-box').css('width', '12.5rem');
$('.search-action').hide();
}
searchResult();
}).focus();
clearTextHammer = new Hammer($('.clear-text')[0]);
... ...
.good-list-page {
.search-input {
position: relative;
padding: 7px 46px 7px 15px;
padding: 7px 15px;
background: #f8f8f8;
> form {
position: relative;
}
.search-icon {
position: absolute;
font-size: 12px;
top: 16px;
left: 24px;
top: 9px;
left: 10px;
}
input {
height: 30px;
width: 95%;
width: 85%;
border-radius: 15px;
text-indent: 26px;
background: #fff;
... ... @@ -22,14 +26,13 @@
.clear-input {
position: absolute;
top: 12px;
top: 5px;
right: 50px;
}
.search {
position: absolute;
top: 12px;
right: .4rem;
float: right;
margin-top: 6px;
border: none;
background: transparent;
font-size: 16px;
... ...