addtop.vm
12 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
<script src="/assets/js/jquery.js"></script>
<script src="/assets/js/riotjs/riotjs.js"></script>
<script type="text/javascript" src="http://static.1n4j.com/static/newStatic/common/js/base/sea.js"></script>
<script type="text/javascript" src="http://static.1n4j.com/static/newStatic/pnr/js/javascript/common/config.js"></script>
<link rel="stylesheet" type="text/css" href="http://static.1n4j.com/static/newStatic/pnr/backstage/css/fancy.css">
<DIV id="navBar" title="productSearchSort">
<li><a href="$!{contextPath}/">首页</a><span class="divider">></span>
<a href="$!{contextPath}/titan/sctop">市场置顶排序</a>></span>
<a href="$!{contextPath}/titan/sctop/sortlist?cateId=$!{cateId}">市场排序商品</a></li>
</DIV>
<form name="productSearchCateForm" action="/titan/productSearchCate" method="POST">
<a id="contentID" class="act-fancy" href="#fancyalter" onclick="openProductPopData($!{cateId},1)"></a>
<a class="btn btn-sm btn-primary" style="float:right" onclick="clickadd($!{cateId},1)">添加排序商品</a>
</form>
<style>
.fancysearch a:focus {color:#fff}
.fancybox-close {right:40px}
</style>
<!-- 表格数据 -->
<table class="table table-striped table-bordered table-condensed grid">
<thead>
<tr>
<th #sorting($!{productSearchSort} "pName")>商品名称</th>
<th #sorting($!{productSearchSort} "cate")>商品分类</th>
<th #sorting($!{productSearchSort} "ctime")>添加时间</th>
<th #sorting($!{productSearchSort} "SearchSort")>排序</th>
<th>操作</th>
</tr>
</thead>
<tbody>
#foreach(${item} in ${page.result})
<tr>
<td style="width:25%;text-align:center;vertical-align:middle;"><a href="javascript:void(0)" onclick="window.open('http://www.1n4j.com/product/$!{item.pid}.html')">$!{item.pName}</td>
<td style="width:25%;text-align:center;vertical-align:middle;">$!{item.categoryName}</td>
<td style="width:15%;text-align:center;vertical-align:middle;">$!{dateFormatUtils.format($!{item.ctime},'yyyy-MM-dd HH:mm')}</td>
<td style="width:15%;text-align:center;vertical-align:middle;"><input type="text" class="ipt numInput" value="$!{item.SearchSort}" id="searchSortId${item.id}" onblur="changeSearchSort($!{cateId},$!{item.id},$!{item.searchSort})" style="width:60px;text-align: center;"/></td>
<td class="textC" style="width:20%;text-align:center;vertical-align:middle;">
<div class="btn-group">
<a href="javascript:void(0)" onclick="deleteSearchSort($!{item.id},$!{item.cateId})"><i class="icon-pencil"></i> 删除</a>
</div>
</td>
</tr>
#end
</tbody>
</table>
<div class="fancyalter" id="fancyalter">
<h2 class="alterhd">添加排序商品</h2>
<div class="alterbd">
<div class="fancysearch">
<span>
商品编号:
<input type="text" class="ipt numInput" name="pid" maxlength="15" style="width: 100px;"/>
</span>
<span style="margin-left:10px">
商品标题:
<input type="text" class="ipt" name="name" maxlength="50" style="width: 100px;"/>
</span>
<span style="margin-left:10px">
店铺名称:
<input type="text" class="ipt" name="shopName" maxlength="50" style="width: 100px;"/>
</span>
<span style="margin-left:10px">
<input type="hidden" id="isSearch" value="0"/>
<a href="javascript:void(0)" class="searchlink" onClick="searchPop($!{cateId},1)">搜索</a>
</span>
</div>
<table cellpadding="0" cellspacing="0" class="fancytab">
<thead>
<tr>
<td>商品编号</td>
<td>商品标题</td>
<td>单价</td>
<td>卖家</td>
<td>操作</td>
</tr>
</thead>
<tbody id="productPopTableDateId">
</tbody>
</table>
<div class="paging" id="pageId">
</div>
<div class="completethis">
<a href="javascript:void(0)" class="addsucc" onclick="saveProductSearch($!{cateId})">添加已完成</a>
</div>
</div>
</div>
<!-- 分页栏 -->
###showPage($!{page})
<script>
var pids = new Array();
function clickadd(cateId,pageId){
var pid,name;
$.ajax({
type : "post",
dataType : "json",
url : "/titan/sctop/queryProductPopData",
data : {cateId : cateId, pageId : pageId, pid : pid, name : name},
success : function(data){
if(data.success){
$("#productPopTableDateId").html("");
$("#pageId").html("");
var result = data.allResult.page.result;
if(result == null || result == '' || result.length ==0){
XUI.window.alert("没有可添加的商品!");
}else{
$("#contentID").click();
}
}
}
});
}
function queryProductPopData(cateId,pageId){
var pid = "";
var name = "";
var shopName = "";
if($("#isSearch").val() == 1){
pid = $("input[name='pid']").val();
name = $("input[name='name']").val();
shopName = $("input[name='shopName']").val();
}
if(pid != ""){
var regex=/^[0-9]+$/;
if (!regex.test(pid) || pid.length > 15) {
XUI.window.alert("请输入合法的商品ID!");
return false;
}
}
if(name !=""){
var regex=/^[0-9a-zA-Z\u4e00-\u9fa5/()()&《》【】\+=\]\[]+$/g;
var message="请输入合法的商品名称(中文汉字、英文字母(含大小写)、数字、“/,(),&,《》,【】,[],=,+”)";
if (!regex.test(name)) {
XUI.window.alert(message);
return false;
}
}
if(shopName !=""){
var regex=/^[0-9a-zA-Z\u4e00-\u9fa5/()()&《》【】\+=\]\[]+$/g;
var message="请输入合法的店铺名称(中文汉字、英文字母(含大小写)、数字、“/,(),&,《》,【】,[],=,+”)";
if (!regex.test(shopName)) {
XUI.window.alert(message);
return false;
}
}
$.ajax({
type : "post",
dataType : "json",
url : "/titan/sctop/queryProductPopData",
data : {cateId : cateId, pageId : pageId, pid : pid, name : name,shopName:shopName},
success : function(data){
if(data.success){
$("#productPopTableDateId").html("");
$("#pageId").html("");
var result = data.allResult.page.result;
if(result != null && result != '' && result.length >0){
for(var i = 0;i<result.length;i++){
var tr = "<tr><td>"+result[i].pid+"</td><td><a href='javascript:void(0)' onclick=\"window.open('http://www.1n4j.com/product/"+result[i].pid+".html')\" class='goodtitle'>"+result[i].name+"</a></td>";
if(result[i].minPrice == result[i].maxPrice){
tr = tr+"<td>"+(result[i].minPrice/100).toFixed(2)+"元</td><td><span class='goodtitle'>"+result[i].shopName+"</span></td><td>";
}else{
tr = tr+"<td>"+(result[i].minPrice/100).toFixed(2)+"-"+(result[i].maxPrice/100).toFixed(2)+"元</td><td><span class='goodtitle'>"+result[i].shopName+"</span></td><td>";
}
var sign = 0;
for(var j=0;j<pids.length;j++){
if(result[i].pid == pids[j]){
tr = tr + "<input type='checkbox' class='addpid' id='"+result[i].pid+"' checked='true' /></td></tr>";
sign = 1;
break;
}
}
if(sign == 0){
tr = tr + "<input class='addpid' type='checkbox' id='"+result[i].pid+"' /></td></tr>";
}
$("#productPopTableDateId").append(tr);
}
}
var current = data.allResult.page.currentPage;
var up = 1;
var down = 1;
if(current == 1){
up = 1;
}else{
up = current - 1;
}
if(current < data.allResult.page.pageCount){
down = current + 1;
}else{
down = current;
}
var pageHtml = "<a href='javascript:void(0)' onclick='queryProductPopData("+cateId+",1)'>首页</a>"+
"<a href='javascript:void(0)' style='margin-left: 10px;' onclick='queryProductPopData("+cateId+","+up+")'>上一页</a>"+
"<a href='javascript:void(0)' style='margin-left: 10px;' onclick='queryProductPopData("+cateId+","+down+")'>下一页</a>"+
"<a href='javascript:void(0)' style='margin-left: 10px;' onclick='queryProductPopData("+cateId+","+data.allResult.page.pageCount+")'>尾 页</a>";
$("#pageId").html(pageHtml);
$.fancybox.update();
$(".addpid").bind("change",function(){
var pid = $(this).attr("id");
if($(this).is(':checked')){
pids.push(pid);
}else{
if(pids.length>0){
for(var i = 0 ;i<pids.length;i++){
if(pids[i]==pid){
pids.splice(i,1);
}
}
}
}
});
}else{
XUI.window.alert(data.result);
}
},
error : function(){
XUI.window.alert("网络错误,请稍后重试");
}
});
}
function searchPop(cateId,pageId){
$("#isSearch").val(1);
pids = new Array();
this.queryProductPopData(cateId,pageId);
}
function openProductPopData(cateId,pageId){
$("#isSearch").val(0);
$("input[name='pid']").val("");
$("input[name='name']").val("");
$("input[name='shopName']").val("");
pids = new Array();
this.queryProductPopData(cateId,pageId);
}
function saveProductSearch(cateId){
if(pids.length == 0){
window.location.href="/titan/sctop/sortlist?cateId="+cateId;
return;
}
$.ajax({
type : "post",
dataType : "json",
url : "/titan/sctop/savesort",
data : {cateId:cateId, pids:JSON.stringify(pids)},
success : function(data){
if(data.code != "success"){
XUI.window.alert(data.result);
}else{
pids = new Array();
window.location.href="/titan/sctop/sortlist?cateId="+cateId;
}
},
error : function(){
XUI.window.alert("网络错误,请稍后重试");
window.location.href="/titan/cdtop/sortlist?cateId="+cateId;
}
});
}
function changeSearchSort(cateId,id,oldSearchSort){
var newSearchSort = $("#searchSortId"+id).val();
if(newSearchSort <= 0 || newSearchSort >= 99999 ){
XUI.window.alert("排序的数据只能取0-99999之间!");
$("#searchSortId"+id).val(oldSearchSort);
return;
}
var ss = /\D|^0/g;
if(ss.test(newSearchSort)){
XUI.window.alert("排序的数据只能取0-99999之间!");
$("#searchSortId"+id).val(oldSearchSort);
return;
}
if(oldSearchSort == newSearchSort){
return;
}
$.ajax({
type : "post",
dataType : "json",
url : "/titan/sctop/changesort",
data : {id:id, cateId : cateId, searchSort:newSearchSort},
success : function(data){
if(data.code != "success"){
XUI.window.alert("数据操作失败!");
$("#searchSortId"+id).val(oldSearchSort);
}else{
window.location.href="/titan/sctop/sortlist?cateId="+cateId;
}
},
error : function(){
XUI.window.alert("网络错误,请稍后重试");
}
});
}
function deleteSearchSort(id,cid){
XUI.window.confirm("确定要删除该排序商品吗?", "删除排序商品", function(){
$.ajax({
type : "post",
dataType : "json",
url : "/titan/sctop/deletesort",
data : {id : id , cateId : cid},
success : function(data){
if(data.code == "success"){
//XUI.window.alert(" 排序分类已成功删除,若以后还需要对该分类商品进行排序,请重新添加排序分类!");
window.location.href="/titan/sctop/sortlist?cateId="+cid;
}else{
XUI.window.alert(data.result);
}
},
error : function(){
XUI.window.alert("网络错误,请稍后重试");
}
});
});
}
seajs.use(['fancybox'], function(fancybox){
$(".act-fancy").fancybox({
scrolling: 'visible',
autoSize:false,
width:680,
afterClose: function(){
pids=new Array();
// $("#productCategoryId select:first option:first").change();
}
});
});
</script>