...
|
...
|
@@ -15,7 +15,7 @@ if(param&¶m.length==1){ |
|
|
async:false
|
|
|
},function(res){
|
|
|
ViewModel=res.data;
|
|
|
});
|
|
|
},true);
|
|
|
}
|
|
|
|
|
|
console.log("ViewModel",ViewModel);
|
...
|
...
|
@@ -59,6 +59,15 @@ var Bll = { |
|
|
});
|
|
|
},
|
|
|
renderBrandPic: function(Brdata) {
|
|
|
var map2={};
|
|
|
Brdata.forEach(function(item){
|
|
|
map2[item.id]=item;
|
|
|
});
|
|
|
Brdata=[];
|
|
|
for(var key in map2){
|
|
|
Brdata.push(map2[key]);
|
|
|
}
|
|
|
|
|
|
var Brands2 = [];
|
|
|
Brdata.forEach(function(item, index) {
|
|
|
if(!item.brandIco){
|
...
|
...
|
@@ -75,6 +84,7 @@ var Bll = { |
|
|
$("#addPic").prepend(common.util.__template2($("#template3").html(), {
|
|
|
Brands: Brands2
|
|
|
}));
|
|
|
return Brdata;
|
|
|
},
|
|
|
contentDatas: [],
|
|
|
module: null,
|
...
|
...
|
@@ -90,7 +100,6 @@ var Bll = { |
|
|
//TODO
|
|
|
!!~index ? Bll.contentDatas[index] = module : Bll.contentDatas.push(module);
|
|
|
Bll.__render("#add-content","template_content",{modules:Bll.contentDatas});
|
|
|
console.log(Bll.contentDatas);
|
|
|
|
|
|
d.close();
|
|
|
}
|
...
|
...
|
@@ -114,7 +123,6 @@ var Bll = { |
|
|
Bll.module.contentData.data=common.util.__buildobj(names, '.', Bll.module.contentData.data, function(o, name) {
|
|
|
o[name] = obj.data;
|
|
|
});
|
|
|
console.log(Bll.module.contentData.data);
|
|
|
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -126,6 +134,13 @@ var Bll = { |
|
|
},
|
|
|
__render: function(selecter, templater, data) {
|
|
|
$(selecter).html(common.util.__template2($("#" + templater).html(), data));
|
|
|
|
|
|
var contentDrag = new common.drag("#add-content", Bll.contentDatas, function(data){
|
|
|
console.log(data);
|
|
|
Bll.contentDatas = data;
|
|
|
Bll.__render("#add-content","template_content",{modules:Bll.contentDatas});
|
|
|
});
|
|
|
contentDrag.Initialize();
|
|
|
},
|
|
|
Tags: []
|
|
|
}
|
...
|
...
|
@@ -152,6 +167,10 @@ if(ViewModel.articleContent){ |
|
|
Bll.contentDatas.push(item);
|
|
|
});
|
|
|
}
|
|
|
/*第三部解析楼层*/
|
|
|
Bll.__render("#add-content","template_content",{modules:Bll.contentDatas});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
...
|
...
|
@@ -164,7 +183,7 @@ new common.dropDown({ |
|
|
ajax: "guangGetSortList",
|
|
|
params: function() {
|
|
|
return {
|
|
|
pid: 0
|
|
|
parentId: 0
|
|
|
};
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -173,7 +192,7 @@ new common.dropDown({ |
|
|
ajax: "guangGetSortList",
|
|
|
params: function() {
|
|
|
return {
|
|
|
pid: $("#maxSortId").val()
|
|
|
parentId: $("#maxSortId").val()
|
|
|
};
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -226,14 +245,22 @@ $(document).on("click", "#addBrands", function() { |
|
|
Brdata: Bll.Brdata.join('|')
|
|
|
}), function() {
|
|
|
//todo
|
|
|
Bll.Brdata = $("#brandCheckBox").val().split('|');
|
|
|
Bll.Brdata = Bll.Brdata.map(function(item, index) {
|
|
|
return {
|
|
|
"brandCategory": "1",
|
|
|
// Bll.Brdata = $("#brandCheckBox").val().split('|');
|
|
|
// Bll.Brdata = Bll.Brdata.map(function(item, index) {
|
|
|
// return {
|
|
|
// "brandCategory": "1",
|
|
|
// "id": item
|
|
|
// }
|
|
|
// });
|
|
|
|
|
|
$("#brandCheckBox").val().split('|').forEach(function(item){
|
|
|
Bll.Brdata.push({
|
|
|
"brandCategory": "1",
|
|
|
"id": item
|
|
|
}
|
|
|
});
|
|
|
Bll.renderBrandPic(Bll.Brdata);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
Bll.Brdata=Bll.renderBrandPic(Bll.Brdata);
|
|
|
});
|
|
|
e.init();
|
|
|
});
|
...
|
...
|
@@ -322,7 +349,7 @@ $("#content_btns").html(common.util.__template2($("#template_content_btns").html |
|
|
|
|
|
$(document).on("click", ".add_btn", function() {
|
|
|
var item = Button[$(this).data("index")];
|
|
|
Bll.module={};
|
|
|
Bll.module={templateKey:item.template_name};
|
|
|
Bll.module.contentData = $.extend(true, {}, item);
|
|
|
Bll.toast(-1, Bll.module);
|
|
|
});
|
...
|
...
|
@@ -333,17 +360,15 @@ $(document).on("click", ".del", function() { |
|
|
|
|
|
$(document).on("change", ".observe", function() {
|
|
|
var $this = $(this);
|
|
|
var name = $this.data("field");
|
|
|
var name = $this.data("field");//a.b.2.d
|
|
|
Bll.module.contentData.data=common.util.__buildobj(name, '.', Bll.module.contentData.data, function(obj, name) {
|
|
|
obj[name] = $this.val();
|
|
|
});
|
|
|
console.log("module",Bll.module.contentData.data);
|
|
|
});
|
|
|
|
|
|
$(document).on("click", ".edit", function() {
|
|
|
var index = $(this).data("index");
|
|
|
var item = Bll.contentDatas[index];
|
|
|
console.log(Bll.contentDatas);
|
|
|
Bll.module = $.extend(true, {}, item);
|
|
|
Bll.toast(index, Bll.module);
|
|
|
});
|
...
|
...
|
@@ -371,7 +396,6 @@ var goodsgird = new common.grid({ |
|
|
}, {
|
|
|
display: "产品图片",
|
|
|
render: function (item) {
|
|
|
console.log(item);
|
|
|
if (item.images_url) {
|
|
|
item.images_url = common.util.__joinImg("goodsimg", item.images_url);
|
|
|
}
|
...
|
...
|
@@ -413,7 +437,7 @@ $(document).on("click", "#goodsSelectBtn", function () { |
|
|
button: [{
|
|
|
value: "确定",
|
|
|
callback: function () {
|
|
|
Bll.module.data = goodsgird.selected.map(function (item, index) {
|
|
|
Bll.module.contentData.data = goodsgird.selected.map(function (item, index) {
|
|
|
return {
|
|
|
src: item.images_url,
|
|
|
id: item.product_skn,
|
...
|
...
|
@@ -432,8 +456,9 @@ $(document).on("click", "#goodsSelectBtn", function () { |
|
|
});
|
|
|
//点击“添加组”按钮(添加商品组)
|
|
|
$(document).on("click", "#goodsaddBtn", function () {
|
|
|
Bll.module.data.push(Button[4].data[0]);
|
|
|
console.log(Bll.module.data);
|
|
|
if(Bll.module.contentData.data[0].list.length){
|
|
|
Bll.module.contentData.data.push(Button[4].data[0]);
|
|
|
}
|
|
|
Bll.__render("#groupsgoods", "template_dialog_remgoodsgroup", Bll.module);
|
|
|
});
|
|
|
//点击“选择标签”按钮(添加商品组)
|
...
|
...
|
@@ -447,14 +472,14 @@ $(document).on("click", ".goodsSelectBtn", function () { |
|
|
value: "确定",
|
|
|
callback: function () {
|
|
|
goodsgird.selected.forEach(function (item, i) {
|
|
|
Bll.module.data[index].list[i] = {
|
|
|
Bll.module.contentData.data[index].list[i] = {
|
|
|
src: item.images_url,
|
|
|
id: item.product_skn,
|
|
|
product_skc: item.product_skc,
|
|
|
maxSortId: item.max_sort_id
|
|
|
};
|
|
|
if (!i) {
|
|
|
Bll.module.data[index].cover = {
|
|
|
Bll.module.contentData.data[index].cover = {
|
|
|
cover: item.images_url,
|
|
|
maxSortId: item.max_sort_id
|
|
|
};
|
...
|
...
|
@@ -469,9 +494,9 @@ $(document).on("click", ".goodsSelectBtn", function () { |
|
|
});
|
|
|
//删除图片按钮
|
|
|
$(document).on("click", ".removepic", function() {
|
|
|
Bll.module.data.splice($(this).data("index"), 1);
|
|
|
Bll.module.contentData.data.splice($(this).data("index"), 1);
|
|
|
$("#goodspic").html(common.util.__template2($("#template_dialog_goodsimgs").html(), {
|
|
|
datas: Bll.module.data
|
|
|
datas: Bll.module.contentData.data
|
|
|
}));
|
|
|
});
|
|
|
|
...
|
...
|
@@ -481,7 +506,11 @@ var e = new common.edit("#panel-body", { |
|
|
bucket: "article"
|
|
|
});
|
|
|
e.init();
|
|
|
|
|
|
e.on("validate",function(){
|
|
|
if(Bll.contentDatas.length==0&&$("#url").val()==""){
|
|
|
return "内容和链接不可为空";
|
|
|
}
|
|
|
})
|
|
|
$(document).on("click", "#submit", function() {
|
|
|
e.submit($("#panel-body").attr("action"), function(option) {
|
|
|
if(param&¶m.length==1){
|
...
|
...
|
@@ -491,31 +520,23 @@ $(document).on("click", "#submit", function() { |
|
|
|
|
|
option.data.contentData = [];
|
|
|
Bll.contentDatas.forEach(function(item, index) {
|
|
|
var data = common.util.__ArrayToObj({
|
|
|
data: item.data,
|
|
|
template_name: item.template_name,
|
|
|
template_intro: item.template_intro
|
|
|
});
|
|
|
|
|
|
option.data.contentData.push({
|
|
|
"templateKey": item.template_name,
|
|
|
"contentData": data
|
|
|
});
|
|
|
|
|
|
item.contentData=common.util.__ArrayToObj(item.contentData);
|
|
|
option.data.contentData.push(item);
|
|
|
});
|
|
|
|
|
|
console.log("Bll.contentDatas", Bll.Brdata);
|
|
|
console.log("Bll.contentDatas", option.data.contentData);
|
|
|
|
|
|
option.data.contentData = JSON.stringify(option.data.contentData);
|
|
|
option.data.brands = JSON.stringify(Bll.Brdata);
|
|
|
option.data.tag = Bll.Tags.join(',');
|
|
|
|
|
|
console.log("submit", option.data);
|
|
|
|
|
|
option.success=function(res){
|
|
|
res = res.data;
|
|
|
if(res.code == "200") {
|
|
|
e.$tip("提交成功", function() {
|
|
|
//location.href="/supplier/baseproduct/index"
|
|
|
location.href="/guang/article/index"
|
|
|
}, 'growl-success');
|
|
|
}else{
|
|
|
e.$tip(res.message);
|
...
|
...
|
@@ -526,6 +547,89 @@ $(document).on("click", "#submit", function() { |
|
|
}
|
|
|
});
|
|
|
});
|
|
|
/*交互部分*/
|
|
|
|
|
|
|
|
|
|
|
|
/*选择分类 自动切换 图片类型*/
|
|
|
var TypeAToT={
|
|
|
"潮品":"1",
|
|
|
"搭配":"2",
|
|
|
"话题":"1",
|
|
|
"潮人":"2",
|
|
|
"小贴士":"1"
|
|
|
};
|
|
|
|
|
|
$(document).on("change","#maxSortId",function(){
|
|
|
var id=$(this).val();
|
|
|
var name=$(this).find("option[value='"+id+"']").text();
|
|
|
|
|
|
$(":radio[name=coverImageType]").each(function(){
|
|
|
if($(this).val()==TypeAToT[name]){
|
|
|
$(":radio[name=coverImageType]").prop("checked",false);
|
|
|
$(this).prop("checked",true);
|
|
|
$("#articleGender").val($(this).val());
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
$(document).on("click","#brandAutoBtn",function(){
|
|
|
var product_skc=[];
|
|
|
Bll.contentDatas.forEach(function(item,index){
|
|
|
if(item.templateKey=="goodsGroup"){
|
|
|
item.contentData.data.forEach(function(datas,i){
|
|
|
datas.list.forEach(function(data,j){
|
|
|
product_skc.push(data.id);
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
if(item.templateKey=="goods"){
|
|
|
item.contentData.data.forEach(function(datas,i){
|
|
|
product_skc.push(datas.id);
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
//product_skc=["51022754","51178582","50030519","51128961","51146105","51055462","51143090","51153133","51010047","51153223","51152761","51149414","51082157","51149561","51079256"];
|
|
|
if(product_skc.length>0){
|
|
|
common.util.__ajax({
|
|
|
url:'/yohosearch/search',
|
|
|
data:{
|
|
|
status:1,
|
|
|
query:product_skc.join(',')
|
|
|
}
|
|
|
},function(res){
|
|
|
if(res.code==200){
|
|
|
var map={};
|
|
|
console.log(res.data.list);
|
|
|
res.data.list.forEach(function(item,index){
|
|
|
map[item.product_skn]={
|
|
|
id:item.brand_id,
|
|
|
brandIco:item.brand_ico,
|
|
|
brandName:item.brand_name,
|
|
|
brandCategory:1
|
|
|
};
|
|
|
});
|
|
|
console.log(map);
|
|
|
var b=[];
|
|
|
product_skc.forEach(function(item,index){
|
|
|
if(map[item]){
|
|
|
b.push(map[item]);
|
|
|
}
|
|
|
});
|
|
|
//console.log(b);
|
|
|
Bll.Brdata=(ViewModel.brandList||[]).concat(b);
|
|
|
// var map2={};
|
|
|
// Bll.Brdata.forEach(function(item){
|
|
|
// map2[item.id]=item;
|
|
|
// });
|
|
|
// Bll.Brdata=[];
|
|
|
// for(var key in map2){
|
|
|
// Bll.Brdata.push(map2[key]);
|
|
|
// }
|
|
|
Bll.Brdata=Bll.renderBrandPic(Bll.Brdata);
|
|
|
}
|
|
|
},true);
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
...
|
...
|
|