goods.html
11 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
{template 'common/header'}
{template 'common'}
<script type="text/javascript" src="resource/js/lib/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="resource/js/lib/jquery-ui-1.10.3.min.js"></script>
<ul class="nav nav-tabs">
<li {if $operation == 'post'&&$modules!='category'}class="active"{/if}><a href="{php echo $this->createWebUrl('goods', array('op' => 'post'))}">添加商品</a></li>
<li {if $operation == 'display'&&$modules!='category'}class="active"{/if}><a href="{php echo $this->createWebUrl('goods', array('op' => 'display'))}">管理商品</a></li>
<li {if $operation == 'post'&&$modules=='category'}class="active"{/if}><a href="{php echo $this->createWebUrl('category', array('op' => 'post'))}">添加商品分类</a></li>
<li {if $operation == 'display'&&$modules=='category'}class="active"{/if}><a href="{php echo $this->createWebUrl('category', array('op' => 'display'))}">管理商品分类</a></li>
</ul>
{if $operation == 'post'}
<link type="text/css" rel="stylesheet" href="../addons/wwx_fxxt/images/uploadify_t.css" />
<style type='text/css'>
.tab-pane { padding:20px 0 20px 0;}
</style>
<div class="main">
<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit="return formcheck();">
<input type="hidden" name="id" value="{$item['id']}" />
<div class="panel panel-default">
<div class="panel-heading">添加商品详细设置</div>
<div class="panel-body">
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a href="#tab_basic">基本信息</a></li>
<li><a href="#tab_des">商品描述</a></li>
<li><a href="#tab_option">商品规格</a></li>
<li><a href="#tab_param">自定义属性</a></li>
<li><a href="#tab_other">其他设置</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_basic">{template 'goods_basic'}</div>
<div class="tab-pane" id="tab_des">{template 'goods_des'}</div>
<div class="tab-pane" id="tab_param">{template 'goods_param'}</div>
<div class="tab-pane" id="tab_option">{template 'goods_option'}</div>
<div class="tab-pane" id="tab_other">{template 'goods_other'}</div>
</div>
</div>
</div>
<div class="form-group col-sm-12">
<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
<input type="hidden" name="token" value="{$_W['token']}" />
</div>
</form>
</div>
<link type="text/css" rel="stylesheet" href="resource/components/kindeditor/themes/default/default.css" />
<script type="text/javascript" src="resource/components/kindeditor/kindeditor-min.js"></script>
<script type="text/javascript" src="resource/components/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript">
var category = {php echo json_encode($children)};
require(['jquery', 'util'], function($, u){
$(function(){
u.editor($('.richtext-clone')[0]);
});
});
var category = {php echo json_encode($children)};
$(function () {
window.optionchanged = false;
$('#myTab a').click(function (e) {
e.preventDefault();//阻止a链接的跳转行为
$(this).tab('show');//显示当前选中的链接及关联的content
})
});
function formcheck(){
if($("#pcate").val()=='0'){
Tip.focus("pcate","请选择商品分类!","right");
return false;
}
if($("#goodsname").isEmpty()) {
$('#myTab a[href="#tab_basic"]').tab('show');
Tip.focus("goodsname","请输入商品名称!","right");
return false;
}
{if empty($id)}
if ($.trim($(':file[name="thumb"]').val()) == '') {
$('#myTab a[href="#tab_basic"]').tab('show');
$('#myTab a[href="#tab_basic"]').tab('show');
Tip.focus('thumb_div', '请上传缩略图.', 'right');
return false;
}
{/if}
if($("#goodsname").isEmpty()) {
$('#myTab a[href="#tab_basic"]').tab('show');
Tip.focus("goodsname","请输入商品名称!","right");
return false;
}
var full = checkoption();
if(!full){return false;}
if(optionchanged){
$('#myTab a[href="#tab_option"]').tab('show');
message('规格数据有变动,请重新点击 [刷新规格项目表] 按钮!','','error');
return false;
}
return true;
}
function checkoption(){
var full = true;
if( $("#hasoption").get(0).checked){
$(".spec_title").each(function(i){
if( $(this).isEmpty()) {
$('#myTab a[href="#tab_option"]').tab('show');
Tip.focus(".spec_title:eq(" + i + ")","请输入规格名称!","top");
full =false;
return false;
}
});
$(".spec_item_title").each(function(i){
if( $(this).isEmpty()) {
$('#myTab a[href="#tab_option"]').tab('show');
Tip.focus(".spec_item_title:eq(" + i + ")","请输入规格项名称!","top");
full =false;
return false;
}
});
}
if(!full) { return false; }
return full;
}
</script>
{elseif $operation == 'display'}
<div class="main">
<div class="panel panel-info">
<div class="panel-heading">筛选</div>
<div class="panel-body">
<form action="./index.php" method="get" class="form-horizontal" role="form">
<input type="hidden" name="c" value="site" />
<input type="hidden" name="a" value="entry" />
<input type="hidden" name="m" value="wwx_fxxt" />
<input type="hidden" name="do" value="goods" />
<div class="form-group">
<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
<div class="col-xs-12 col-sm-8 col-lg-9">
<input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}">
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">状态</label>
<div class="col-xs-12 col-sm-8 col-lg-9">
<select name="status" class='form-control'>
<option value="1" {if !empty($_GPC['status'])} selected{/if}>销售中</option>
<option value="0" {if empty($_GPC['status'])} selected{/if}>已下架</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">分类</label>
<div class="col-xs-6 col-sm-4">
<select class="form-control" style="margin-right:15px;" name="cate_1" onchange="fetchChildCategory(this.options[this.selectedIndex].value)">
<option value="0">请选择一级分类</option>
{loop $category $row}
{if $row['parentid'] == 0}
<option value="{$row['id']}" {if $row['id'] == $_GPC['cate_1']} selected="selected"{/if}>{$row['name']}</option>
{/if}
{/loop}
</select>
</div>
<div class="col-xs-6 col-sm-4">
<select class="form-control input-medium" id="cate_2" name="cate_2">
<option value="0">请选择二级分类</option>
{if !empty($_GPC['cate_1']) && !empty($children[$_GPC['cate_1']])}
{loop $children[$_GPC['cate_1']] $row}
<option value="{$row[0]}" {if $row[0] == $_GPC['cate_2']} selected="selected"{/if}>{$row[1]}</option>
{/loop}
{/if}
</select>
</div>
<div class=" col-xs-12 col-sm-2 col-lg-2">
<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
</div>
</div>
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">全部商品:<span class="label label-success"><?php echo $total;?></span> 件</div>
<div style="padding:15px;">
<table class="table table-hover">
<thead class="navbar-inner">
<tr>
<th style="width:50px;">ID</th>
<th>商品标题</th>
<th style="width:200px;">商品属性(点击可修改)</th>
<th style="width:90px;">销售价</th>
<th style="width:60px;">库存</th>
<th style="width:120px;">商品编号</th>
<!--<th style="width:10%;">商品条码</th> -->
<th style="text-align:center; width:100px;">状态(可修改)</th>
<th style="text-align:center; width:80px;">操作</th>
</tr>
</thead>
<tbody>
{loop $list $item}
<tr>
<td>{$item['id']}</td>
<td title="{if !empty($category[$item['pcate']])}[{$category[$item['pcate']]['name']}] {/if}{if !empty($children[$item['pcate']])}[{$children[$item['pcate']][$item['ccate']][1]}] {/if}{$item['title']}">{if !empty($category[$item['pcate']])}[{$category[$item['pcate']]['name']}] {/if}{if !empty($children[$item['pcate']])}[{$children[$item['pcate']][$item['ccate']][1]}] {/if}{$item['title']}</td>
<td>
<span data="{$item['istime']}" class="label label-default {if $item['istime']==1}label-info{/if}" >秒杀</span>
<span data="{$item['issendfree']}" class="label label-default {if $item['issendfree']==1}label-info{/if}" onclick="setProperty(this,{$item['id']},'sendfree')" style="cursor:pointer;">包邮</span>
<span data="{$item['isdiscount']}" class="label label-default {if $item['isdiscount']==1}label-info{/if}" onclick="setProperty(this,{$item['id']},'discount')" style="cursor:pointer;">折扣</span>
<span data="{$item['isrecommand']}" class="label label-default {if $item['isrecommand']==1}label-info{/if}" onclick="setProperty(this,{$item['id']},'recommand')" style="cursor:pointer;">推荐</span>
</td>
<td title="{$item['marketprice']}">{$item['marketprice']}</td>
<td title="{$item['total']}">{$item['total']}</td>
<td title="{$item['goodssn']}">{$item['goodssn']}</td>
<!--<td>{$item['productsn']}</td> -->
<td style="text-align:center;">{if $item['status']}<span data='{$item['status']}' onclick="setProperty1(this,{$item['id']},'status')" class="label label-default label-success" style="cursor:pointer;">销售中</span>{else}<span data='{$item['status']}' onclick="setProperty1(this,{$item['id']},'status')" class="label label-default" style="cursor:pointer;">已下架</span>{/if}</td>
<td style="text-align:center;"><a href="{php echo $this->createWebUrl('goods', array('id' => $item['id'], 'op' => 'post'))}">编辑</a> <a href="{php echo $this->createWebUrl('goods', array('id' => $item['id'], 'op' => 'delete'))}" onclick="return confirm('此操作不可恢复,确认删除?');return false;">删除</a></td>
</tr>
{/loop}
</tbody>
</table>
{$pager}
</div>
</div>
</div>
<script type="text/javascript">
var category = {php echo json_encode($children)};
function setProperty(obj,id,type){
$(obj).html($(obj).html() + "...");
$.post("{php echo $this->createWebUrl('setgoodsproperty')}",{id:id,type:type, data: obj.getAttribute("data")},function(d){
$(obj).html($(obj).html().replace("...",""));
$(obj).attr("data",d.data)
if(d.result==1){
$(obj).toggleClass("label-info");
}
},"json");
}
function setProperty1(obj,id,type){
//$(obj).html($(obj).html() + "...");
$.post("{php echo $this->createWebUrl('setgoodsproperty')}",{id:id,type:type, data: obj.getAttribute("data")},function(d){
//$(obj).html($(obj).html().replace("...",""));
$(obj).attr("data",d.data);
if(d.data==1){
obj.innerHTML = '销售中';
}
if(d.data==0){
obj.innerHTML = '已下架';
}
$(obj).toggleClass("label-success");
},"json");
}
</script>
{/if}
{template 'common/footer'}