contentEdit.js
4.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
var $ = require('jquery'),
common = require('../common/common');
var ENUM={};
// common.util.__ajax({
// url:'/guang/article/getEnumList',
// async:false
// },function(res){
// ENUM=res.data;
// });
console.log(ENUM);
var Bll={
Brands:[],
Brands1:{},
Brdata:[],
getBrands:function(){
var Brand={};
$.get("/ajax/yohosearch",function(res){
console.log(res.data);
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){
Bll.Brands.push({name:i,items:Brand[i]});
}
console.log("执行成功");
});
},
renderBrandPic:function(Brdata){
var Brands2=[];
Brdata.forEach(function(item,index){
var a=Bll.Brands1[item]
//图片的绝对路径是多少
a.brand_ico=common.util.__joinImg(a.brand_ico)
Brands2.push(a);
});
$("#addBrands").parent("div").parent("li").prevAll().remove();
$("#addPic").prepend(common.util.__template2($("#template3").html(),{Brands:Brands2}));
}
}
//获取品牌
Bll.getBrands();
$("#panel-body").html(common.util.__template2($("#tempalte1").html(),ENUM));
new common.dropDown({el:"#authorId",ajax:"guangGetAuthorList"});
new common.dropDown({el:"#maxSortId",ajax:"guangGetSortList",params:function(){
return {pid:0};
}});
new common.dropDown({el:"#minSortId",ajax:"guangGetSortList",params:function(){
return {pid:$("#maxSortId").val()};
}});
var g= new common.grid({
el:"#gird",
columns:[
{display:"选择","type":"checkbox"},
{display:"标签名",name:"tagName"}
]
});
$(document).on("click","#addUrl",function(){
common.dialog.confirm("添加链接",common.util.__template2($("#template2").html(),{}),function(){
$("#url").val(JSON.stringify({
action:'go.'+$("#goTo").val(),
url:$("#goToUrl").val()
}));
});
});
$(document).on("click","#TagsSelectBtn",function(){
common.dialog.confirm("选择标签","<div id='gird'></div>",function(){
$("#taglist").html(common.util.__template2($("#template4").html(),{tags:g.selected}));
});
g.init('/guang/tags/getList');
});
$(document).on("click",".tag a",function(){
g.selected.splice($(this).data("index"),1);
$("#taglist").html(common.util.__template2($("#template4").html(),{tags:g.selected}));
return false;
});
$(document).on("click","#addBrands",function(){
///goods/brands/queryBrandsByStatus
var e=new common.edit("#brandForm");
common.dialog.confirm("选择品牌",common.util.__template2($("#template5").html(),{Brands:Bll.Brands,Brdata:Bll.Brdata.join('|')}),function(){
//todo
Bll.Brdata=$("#brandCheckBox").val().split('|');
Bll.renderBrandPic(Bll.Brdata);
});
e.init();
});
$(document).on("click",".remove1",function(){
Bll.Brdata.splice($(this).data("index"),1);
Bll.renderBrandPic(Bll.Brdata);
});
var e=new common.edit("#panel-body",{bucket:"article"});
e.init();
$(document).on("click","#submit",function(){
e.submit($("#panel-body").attr("action"),function(option){
console.log(option.data);
option.data.brands=JSON.stringify(Bll.Brdata);
option.debug=true;
});
});
var contentDatas=[];
var Button=[
{
text:"文本",
template:"template_content_text",
dialog:"template_dialog_text",
data:{text:""},
template_name:"text"
},
{
text:"一张大图",
template:"template_1",
dialog:"dialog_1"
},
{
text:"两张小图",
template:"template_1",
dialog:"dialog_1"
},
{
text:"添加商品",
template:"template_1",
dialog:"dialog_1"
},
{
text:"推荐商品组",
template:"template_1",
dialog:"dialog_1"
},
{
text:"一个连接",
template:"template_1",
dialog:"dialog_1"
}
];
$("#content_btns").html(common.util.__template2($("#template_content_btns").html(),{btns:Button}));
var module=null;
$(document).on("click",".add_btn",function(){
var item=Button[$(this).data("index")];
item.index=contentDatas.length;
item=$.extend({},item);
module=item.data;
var d=new common.dialog({
title:item.text,
content:common.util.__template2($("#"+item.dialog).html(),item),
width:'80%',
button:[
{
value: "保存",
callback: function(){
contentDatas.push(module);
$("#taglist").html(common.util.__template2($("#template_dialog_text").html(),{modules:contentDatas}));
},
css: "btn-primary"
}
]
});
});
$(document).on("click",".del",function(){
contentDatas.splice($(this).data("index"),1);
$("#taglist").html(common.util.__template2($("#template_dialog_text").html(),contentDatas));
});
$(document).on("change",".observe",function(){
var index=$(this).data("index");
var name=$(this).data("field");
module[name]=$(this).val();
});