...
|
...
|
@@ -21,60 +21,11 @@ var Bll={ |
|
|
Brands: [],
|
|
|
Brands1: {},
|
|
|
Brdata: [],
|
|
|
//获取品牌
|
|
|
getBrands: function() {
|
|
|
var Brand = {};
|
|
|
$.get("/ajax/yohosearch", function(res) {
|
|
|
res.data.forEach(function(item, index) {
|
|
|
var brandAlif = (item.brand_alif || "").toUpperCase();
|
|
|
if (/^[0-9]$/.test(item.brand_alif)) {
|
|
|
brandAlif = "0-9";
|
|
|
}
|
|
|
if (/^\W$/.test(item.brand_alif)) {
|
|
|
brandAlif = "#";
|
|
|
}
|
|
|
Brand[brandAlif] = Brand[brandAlif] || [];
|
|
|
Brand[brandAlif].push(item);
|
|
|
Bll.Brands1[item.id] = item;
|
|
|
});
|
|
|
for (var i in Brand) {
|
|
|
Brand[i].sort(function(a, b) {
|
|
|
var aName = a.brand_name.toLowerCase(),
|
|
|
bName = b.brand_name.toLowerCase();
|
|
|
if (aName < bName) return -1;
|
|
|
if (aName > bName) return 1;
|
|
|
return 0;
|
|
|
});
|
|
|
Bll.Brands.push({
|
|
|
name: i,
|
|
|
items: Brand[i]
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
renderBrandPic: function(Brdata) {
|
|
|
var Brands2 = [];
|
|
|
Brdata.forEach(function(item, index) {
|
|
|
if(!item.brandIco){
|
|
|
var a = Bll.Brands1[item.id]
|
|
|
a.brandIco = common.util.__joinImg("brandLogo", a.brand_ico)
|
|
|
Brands2.push(a);
|
|
|
}else{
|
|
|
item.brandIco=common.util.__template(item.brandIco,{width:110,height:150});
|
|
|
Brands2.push(item);
|
|
|
}
|
|
|
|
|
|
});
|
|
|
$("#addBrands").parent("div").parent("li").prevAll().remove();
|
|
|
$("#addPic").prepend(common.util.__template2($("#template3").html(), {
|
|
|
Brands: Brands2
|
|
|
}));
|
|
|
},
|
|
|
contentDatas:[],
|
|
|
module: null,
|
|
|
__render:function(selecter,templater,data){
|
|
|
$(selecter).html(common.util.__template2($("#"+templater).html(),data) );
|
|
|
},
|
|
|
contentDatas:[],
|
|
|
module: null,
|
|
|
toast: function(index, module) {
|
|
|
var d = new common.dialog({
|
|
|
title: (!!~index ? "修改" : "添加") + module.contentData.template_intro,
|
...
|
...
|
@@ -115,8 +66,76 @@ var Bll={ |
|
|
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
//获取品牌
|
|
|
getBrands: function() {
|
|
|
var Brand = {};
|
|
|
$.get("/ajax/yohosearch", function(res) {
|
|
|
res.data.forEach(function(item, index) {
|
|
|
var brandAlif = (item.brand_alif || "").toUpperCase();
|
|
|
if (/^[0-9]$/.test(item.brand_alif)) {
|
|
|
brandAlif = "0-9";
|
|
|
}
|
|
|
if (/^\W$/.test(item.brand_alif)) {
|
|
|
brandAlif = "#";
|
|
|
}
|
|
|
Brand[brandAlif] = Brand[brandAlif] || [];
|
|
|
Brand[brandAlif].push(item);
|
|
|
Bll.Brands1[item.id] = item;
|
|
|
});
|
|
|
for (var i in Brand) {
|
|
|
Brand[i].sort(function(a, b) {
|
|
|
var aName = a.brand_name.toLowerCase(),
|
|
|
bName = b.brand_name.toLowerCase();
|
|
|
if (aName < bName) return -1;
|
|
|
if (aName > bName) return 1;
|
|
|
return 0;
|
|
|
});
|
|
|
Bll.Brands.push({
|
|
|
name: i,
|
|
|
items: Brand[i]
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
renderBrandPic: function(Brdata) {
|
|
|
var Brands2 = [];
|
|
|
Brdata.forEach(function(item, index) {
|
|
|
if(!item.brandIco){
|
|
|
var a = Bll.Brands1[item];
|
|
|
a.brandIco = common.util.__joinImg("brandLogo", a.brand_ico);
|
|
|
Brands2.push(a);
|
|
|
}else{
|
|
|
item.brandIco=common.util.__template(item.brandIco,{width:110,height:150});
|
|
|
Brands2.push(item);
|
|
|
}
|
|
|
|
|
|
});
|
|
|
Bll.module=Bll.module||{};
|
|
|
Bll.module.contentData=Bll.module.contentData||{};
|
|
|
Bll.module.contentData.data=Bll.module.contentData.data||{};
|
|
|
Bll.module.contentData.data.list=Bll.module.contentData.data.list||[];
|
|
|
for(var i=0;i<Brands2.length;i++){
|
|
|
var pic={};
|
|
|
if( Bll.module.contentData.template_name=="kidsBrands"){
|
|
|
pic={
|
|
|
"src":Brands2[i].brandIco,
|
|
|
"id":Brands2[i].id,
|
|
|
"title":Brands2[i].brand_name
|
|
|
};
|
|
|
}else{
|
|
|
pic={
|
|
|
"src":Brands2[i].brandIco,
|
|
|
"id":Brands2[i].id,
|
|
|
"name":Brands2[i].brand_name
|
|
|
};
|
|
|
}
|
|
|
|
|
|
Bll.module.contentData.data.list.push(pic);
|
|
|
}
|
|
|
Bll.renderDialog("brands-template");
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
|
...
|
...
|
@@ -177,9 +196,13 @@ $(document).on("click", ".edit", function() { |
|
|
$(document).on("change", ".observe", function() {
|
|
|
var $this = $(this);
|
|
|
var name = $this.data("field");
|
|
|
console.log("name");
|
|
|
console.log(name);
|
|
|
Bll.module.contentData.data=common.util.__buildobj(name, '.', Bll.module.contentData.data, function(obj, name) {
|
|
|
obj[name] = $this.val();
|
|
|
});
|
|
|
console.log("Bll.module.contentData.data");
|
|
|
console.log(Bll.module.contentData.data);
|
|
|
});
|
|
|
|
|
|
$(document).on("click", '#multiLabelImage-addImage', function() {
|
...
|
...
|
@@ -251,24 +274,23 @@ Bll.renderBrandPic(Bll.Brdata); |
|
|
//打开品牌选择模态
|
|
|
$(document).on("click", "#addBrands", function() {
|
|
|
var e = new common.edit("#brandForm");
|
|
|
console.log("BLL",Bll);
|
|
|
console.log("Bll.Brands",Bll.Brands);
|
|
|
console.log("Bll.Brdata",Bll.Brdata);
|
|
|
common.dialog.confirm("选择品牌", common.util.__template2($("#template5").html(), {
|
|
|
Brands: Bll.Brands,
|
|
|
Brdata: Bll.Brdata.join('|')
|
|
|
Brands: Bll.Brands,//所有品牌数据
|
|
|
Brdata: []
|
|
|
}), function() {
|
|
|
//todo
|
|
|
Bll.Brdata = $("#brandCheckBox").val().split('|');
|
|
|
Bll.Brdata = Bll.Brdata.map(function(item, index) {
|
|
|
return {
|
|
|
"brandCategory": "1",
|
|
|
"id": item
|
|
|
}
|
|
|
});
|
|
|
Bll.renderBrandPic(Bll.Brdata);
|
|
|
});
|
|
|
e.init();
|
|
|
});
|
|
|
//删除一个品牌
|
|
|
$(document).on("click", '#remove_brand', function() {
|
|
|
var index = $(this).data("index");
|
|
|
Bll.module.contentData.data.list.splice(index,1);
|
|
|
Bll.renderDialog("brands-template");
|
|
|
});
|
|
|
/*自定义参数*/
|
|
|
$(document).on("click", '.paramsGroupDel', function() {
|
|
|
console.log($(this).data("index"));
|
...
|
...
|
|