onlinereg.js
10.9 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
define('admin/onlinereg', function(require, exports){
var box = require('admin/box'); // 提示框
var $ = require("jquery");
var common = require("common");
var upload = require('admin/upload');
var form_html = $("#form_pan").html()+'';
$("#form_pan").remove();
exports.index = function()
{
//全选
$("#all_check").bind("click",function()
{
if($(this).attr("checked"))
{
$.each($("input[type=checkbox]"), function(i, obj)
{
$(obj).attr("checked", 1);
});
}
else
{
$.each($("input[type=checkbox]"), function(i, obj)
{
$(obj).attr("checked", false);
});
}
});
//批量导出
$(".batch_export").bind("click",function()
{
var ids = '';
$("input[type=checkbox]").each(function()
{
if($(this).attr("checked"))
{
ids += $(this).attr("seller_id")+',';
}
});
if(ids != '')
{
window.location.href = '/admin/onlinereg/export?id='+ids;
}
else
{
alert("没有选中");
}
});
//查看数据
$(".look").bind("click",function()
{
var type = $(".nav-tabs").attr("type");
var sellerId = $(this).attr("seller_id");
var seller;
box.confirm(form_html,function()
{
var type = $(".nav-tabs").attr("type");
var params = {};
var sellerId = $("#box_confirm_ok").attr("seller_id");
var requires = [];
//参展商校验数据
var requireType0 = ['name','contact','telphone','relation','place'];
//赞助商校验数据
var requireType1 = ['name','contact','telphone'];
//媒体校验数据
var requireType2 = ['name','mobile'];
var val = '';
var keys = ['name','profession','company','contact','telphone','mobile','brand_reg_type',
'country', 'zipcode','city','introduction','email','place','website'];
var selectKeys = ['is_enter_yohobuy','is_3c','relation','brand_reg_type','sex'];
var i;
params.id = sellerId;
if(type == 0)
{
requires = requireType0;
}
else if(type == 1)
{
requires = requireType1;
}
else if(type == 2)
{
requires = requireType2;
}
for(i = 0;i< selectKeys.length; i++)
{
if($("select[name="+selectKeys[i]+"]").size()> 0)
{
params[""+selectKeys[i]+""] = $("select[name="+selectKeys[i]+"]").val();
}
}
for(i = 0; i< keys.length; i++)
{
if($("input[name="+keys[i]+"]").size() > 0)
{
val = $.trim($("input[name="+keys[i]+"]").val());
if($.inArray(keys[i], requires) !== -1 && val == '')
{
alert("带*内容不能为空");
return false;
}
params[""+keys[i]+""] = val;
}
}
$.ajax
({
type:"post",
url:"/admin/onlinereg/setseller",
data:params,
success:function(data)
{
if(data.code == 200)
{
window.location.reload();
}
else
{
alert("保存失败");
}
}
});
},{title: '查看详情', width: '750px', autoClose: false});
$.ajax
({
type:"post",
url:"/admin/onlinereg/getseller",
data:{id:sellerId},
success:function(data)
{
seller = data.data;
if(data.code == 200)
{
var files = [], html = '', filePath;
$("input[name=name]").val(seller.name);
$("select[name=is_enter_yohobuy]").val(seller.is_enter_yohobuy);
$("input[name=product_type]").val(seller.product_type);
$("input[name=profession]").val(seller.profession);
$("select[name=sex]").val(seller.sex);
$("input[name=company]").val(seller.company);
$("input[name=contact]").val(seller.contact);
$("input[name=telphone]").val(seller.telphone);
$("input[name=mobile]").val(seller.mobile);
$("select[name=relation]").val(seller.relation);
$("input[name=country]").val(seller.country);
$("input[name=zipcode]").val(seller.zipcode);
$("input[name=city]").val(seller.city);
$("input[name=introduction]").val(seller.introduction);
$("input[name=email]").val(seller.email);
$("input[name=place]").val(seller.place);
$("select[name=is_3c]").val(seller.is_3c);
$("select[name=brand_reg_type]").val(seller.brand_reg_type);
$("input[name=website]").val(seller.website);
if(seller.files != "")
{
files = seller.files.split("|");
for(var i = 0; i <files.length; i++)
{
if(files[i] !='')
{
filePath = common.getImages(files[i],'source', 'blogimg');
html+='<a href="' + filePath + '">'+files[i].split("/")[files[i].split("/").length - 1]+'</a><br/>';
}
}
}
$("#download_list").html(html);
$("#box_confirm_ok").attr("seller_id", sellerId);
}
}
});
});
};
function init_upload(id, callback, setting, post_params)
{
var defaultSetting = {
button_placeholder_id:id,
button_width : "58",
button_height : "30",
post_params: {'key':$('#'+id).attr('key'), 'format':'json'},
file_queue_limit:50,
custom_settings:
{
saveCallback:callback
}
};
if(setting)
{
$.extend(defaultSetting, setting);
}
if(post_params)
{
$.extend(defaultSetting.post_params, post_params);
}
//绑定上传背景按钮
upload.init(defaultSetting);
}
//设置下载信息
exports.download = function()
{
//设置下载信息
$(".modify, #create_download_info").bind("click", function()
{
var download_id = 0;
var type = $(".table").attr("type");
var title = type == 0 ? '设置参展商手册':'设置新闻稿';
//设置下载信息
box.confirm(form_html,function()
{
var id = parseInt($("#download_id").val());
var title = $("input[name=title]").val();
var type = $(".table").attr("type");
var file = $("#file").size() ? $("#file").attr("val") : '';
var cover = '';
var source = '';
var source_link = '';
if(title == '' || file == '')
{
alert("带*内容不能为空");
return false;
}
//封面
if(typeof($("#pic").attr("val")) !=="undefined")
{
cover = $("#pic").attr("val");
if(cover == '')
{
alert("带*内容不能为空");
return false;
}
}
//来源
if($("input[name=source]").size())
{
source = $("input[name=source]").val();
if(source == '')
{
alert("带*内容不能为空");
return false;
}
}
//来源链接
if($("input[name=source_link]").size())
{
source_link = $("input[name=source_link]").val();
if(source_link == '')
{
alert("带*内容不能为空");
return false;
}
}
$.ajax
({
type:"post",
url:"/admin/onlinereg/setdownload",
data:{title:title,cover:cover, file:file, id: id, type:type, source:source, source_link:source_link},
success:function(data)
{
if(data.code == 200)
{
window.location.reload();
}
else
{
alert("设置失败");
}
}
})
},{title: title, width: '750px', autoClose: false});
if($("#upload_pic").size())
{
//上传图片
init_upload('upload_pic', function(response, swf)
{
var thumbPath = common.getImages(response.data.file.relaPath, "0100x0100", "blogimg", "primary");
var realPath = response.data.file.relaPath;
$("#picdiv").html("<img id='pic' class='thumb_but' val='"+realPath+"' src='"+thumbPath+"' width='100' height='100' /> ");
}, {button_width:"100", button_height : "30"});
}
if($("#upload_file").size())
{
//上传文件
init_upload('upload_file', function(response, swf)
{
var filePath = response.data.file.absPath;
var realPath = response.data.file.relaPath;
var file = filePath.split("/")[filePath.split("/").length - 1];
//图片
$("#filediv").html('<a id="file" href="'+filePath+'" val="'+realPath+'">'+file+'</a>');
}, {button_width:"100", button_height : "30",file_types:"*.zip;*.xlsx;*.xls;*.docx;*.doc;*.pdf;*.ppt;*.pptx"}, {"fileType":"file"});
}
//下载ID
if(typeof($(this).attr("download_id")) !== 'undefined')
{
download_id = $(this).attr("download_id");
$("#download_id").val(download_id);
}
if(download_id > 0)
{
$.ajax
({
type:"get",
url:"/admin/onlinereg/getdownload",
data:{id:download_id},
success:function(data)
{
if(data.code == 200)
{
$("#title").val(data.data.title);
var thumbPath = common.getImages(data.data.cover, "0100x0100", "blogimg", "primary");
$("#picdiv").html("<img id='pic' class='thumb_but' val='"+data.data.cover+"' src='"+thumbPath+"' width='100' height='100' /> ");
var filePath = common.getImages(data.data.file,'source','blogimg');
var file = filePath.split("/")[filePath.split("/").length - 1];
$("#filediv").html('<a id="file" href="'+filePath+'" val="'+data.data.file+'">'+file+'</a>');
$("input[name=source]").val(data.data.source);
$("input[name=source_link]").val(data.data.source_link);
}
}
});
}
});
//删除下载
$(".del").bind("click",function()
{
if(window.confirm("你确定要删除吗?"))
{
var download_id = $(this).attr("download_id");
$.ajax
({
type:"post",
url:"/admin/onlinereg/deldownload",
data:{id:download_id},
success:function(data)
{
if(data.code == 200)
{
window.location.reload();
}
else
{
alert("删除失败");
}
}
});
}
});
};
});