...
|
...
|
@@ -419,8 +419,7 @@ define('yohood', function(require, exports) { |
|
|
// $('.slide-control').hide();
|
|
|
// }
|
|
|
|
|
|
//所有品牌
|
|
|
console.log($(".all_brand"));
|
|
|
//所有品牌
|
|
|
$(".all_brand").on("click", function() {
|
|
|
$("input[type=text]").val("");
|
|
|
$(".search-btn").click();
|
...
|
...
|
@@ -450,42 +449,76 @@ define('yohood', function(require, exports) { |
|
|
}
|
|
|
return s;
|
|
|
}
|
|
|
//搜素品牌
|
|
|
$('.search-wrap').find('input').on('keyup', function() {
|
|
|
$(".search-btn").trigger("click.search");
|
|
|
});
|
|
|
$(".search-btn").bind("click.search", function() {
|
|
|
var brand = $.trim($("input[type=text]").val());
|
|
|
var template = '<ul class="brand-list cooperation-list clearfix">{li}</ul>';
|
|
|
var noSearchTemplate = '<div class="no-search" style="display:block;"><p>未搜索到“{brand}”的相关品牌</p><a href="javascript:;" class="all_brand"><查看全部品牌</a></div>';
|
|
|
var html = '';
|
|
|
$.ajax({
|
|
|
type: "post",
|
|
|
url: "/brand/getbrand",
|
|
|
data: {
|
|
|
brand: encodeURIComponent(brand)
|
|
|
},
|
|
|
success: function(data) {
|
|
|
var brands = data.data;
|
|
|
if (data.code == 200 && brands != "") {
|
|
|
$.each(brands, function(k, v) {
|
|
|
html += '<li><a href="javascript:;" target="_blank" title="' + v.name + '"><div class="img-box" brand_id="' + v.id + '">' +
|
|
|
'<img class="grey-brand-logo" width="145" height="97" src="' + common.getImages(v.logo, 'source', 'blogimg', 'primary') + '" alt="" alt="' + v.name + '"></div>' +
|
|
|
'<p>' + cutString(v.name, 20) + '</p></a></li>';
|
|
|
});
|
|
|
$(".brand-content").html(template.replace('{li}', html));
|
|
|
} else {
|
|
|
$(".brand-content").html("");
|
|
|
$(".brand-content").html(noSearchTemplate.replace('{brand}', tools.escapeHTML(brand).replace(/\"/g, "“").replace(/\'/g, "‘")));
|
|
|
|
|
|
({
|
|
|
brandSort: function(brands, sortBase) {
|
|
|
var brandName = "",
|
|
|
i = 0,
|
|
|
len = 0;
|
|
|
|
|
|
if (brands === null || brands === undefined) {
|
|
|
return brands;
|
|
|
}
|
|
|
if (typeof sortBase !== "string" || sortBase === "") {
|
|
|
return brands;
|
|
|
}
|
|
|
|
|
|
for (i = 0, len = brands.length; i < len; i++) {
|
|
|
brandName = brands[i].name;
|
|
|
console.log(brand[i]);
|
|
|
if (brandName.indexOf(sortBase) === 0) {
|
|
|
brands.splice(i, 1).concat(brands);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$(".all_brand").on("click", function() {
|
|
|
$("input[type=text]").val("");
|
|
|
$(".search-btn").click();
|
|
|
return brands;
|
|
|
},
|
|
|
init: function() {
|
|
|
var that = this;
|
|
|
//搜素品牌
|
|
|
$('.search-wrap').find('input').on('keyup', function() {
|
|
|
$(".search-btn").trigger("click.search");
|
|
|
});
|
|
|
$(".search-btn").bind("click.search", function() {
|
|
|
var brand = $.trim($("input[type=text]").val());
|
|
|
var template = '<ul class="brand-list cooperation-list clearfix">{li}</ul>';
|
|
|
var noSearchTemplate = '<div class="no-search" style="display:block;"><p>未搜索到“{brand}”的相关品牌</p><a href="javascript:;" class="all_brand"><查看全部品牌</a></div>';
|
|
|
var html = '';
|
|
|
$.ajax({
|
|
|
type: "post",
|
|
|
url: "/brand/getbrand",
|
|
|
data: {
|
|
|
brand: encodeURIComponent(brand)
|
|
|
},
|
|
|
success: function(data) {
|
|
|
var brands = data.data;
|
|
|
if (data.code == 200 && brands != "") {
|
|
|
// brands = that.brandSort(brands, brand);
|
|
|
$.each(brands, function(k, v) {
|
|
|
html += '<li><a href="javascript:;" target="_blank" title="' + v.name + '"><div class="img-box" brand_id="' + v.id + '">' +
|
|
|
'<img class="grey-brand-logo" width="145" height="97" src="' + common.getImages(v.logo, 'source', 'blogimg', 'primary') + '" alt="" alt="' + v.name + '"></div>' +
|
|
|
'<p>' + cutString(v.name, 20) + '</p></a></li>';
|
|
|
});
|
|
|
$(".brand-content").html(template.replace('{li}', html));
|
|
|
} else {
|
|
|
$(".brand-content").html("");
|
|
|
$(".brand-content").html(noSearchTemplate.replace('{brand}', tools.escapeHTML(brand).replace(/\"/g, "“").replace(/\'/g, "‘")));
|
|
|
}
|
|
|
|
|
|
$(".all_brand").on("click", function() {
|
|
|
$("input[type=text]").val("");
|
|
|
$(".search-btn").click();
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
|
|
|
console.log(1);
|
|
|
|
|
|
}
|
|
|
}).init();
|
|
|
|
|
|
|
|
|
//品牌列表
|
|
|
$(".brand-list li .img-box").live("click", function(event) {
|
|
|
var brand_id = $(this).attr("brand_id");
|
...
|
...
|
|