审计记录

WebContent/WEB-INF/jsp/pc/goods/goodsList.jsp 5.3 KB
zxt@theyeasy.com committed
1 2 3 4 5 6 7 8
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
9
		<title>商品列表</title>
zxt@theyeasy.com committed
10 11 12
		<link rel="stylesheet" href="/zzhnc/res/plugins/layui/css/layui.css">
		<link rel="stylesheet" href="/zzhnc/res/css/basic.css">
	</head>
沈姿.前端(已离职) committed
13

zxt@theyeasy.com committed
14 15 16
	<body class="wrap">
		<div class="layui-form">
			<div class="layui-form-item searchbox" style="margin-bottom: 0px;">
沈姿.前端(已离职) committed
17
				<div class="layui-input-inline">
18
					<input type="text" class="layui-input" name="key" placeholder="关键字" />
zxt@theyeasy.com committed
19 20 21
				</div>
				<button class="layui-btn" lay-submit lay-filter="querybtn">查询</button>
				<button class="layui-btn layui-btn-primary resetBtn">重置</button>
沈姿.前端(已离职) committed
22
				<a class="layui-btn layui-btn-warm createBtn" href="#"><i class="layui-icon">&#xe61f;</i> 添加商品</a>
zxt@theyeasy.com committed
23 24
			</div>
		</div>
25

沈姿.前端(已离职) committed
26
		<table class="layui-table layui-form">
zxt@theyeasy.com committed
27 28
			<thead>
				<tr>
沈姿.前端(已离职) committed
29 30 31 32
					<th>No</th>
					<th>商品主图</th>
					<th>商品标题</th>
					<th>商品副标题</th>
33 34 35 36
					<th>原价</th>
					<th>现价</th>
					<th>商家名称</th>
					<th>商家地址</th>
沈姿.前端(已离职) committed
37 38
					<th>商家电话</th>
					<th>是否首页显示</th>
沈姿.前端(已离职) committed
39
					<th>操作</th>
zxt@theyeasy.com committed
40 41
				</tr>
			</thead>
42

zxt@theyeasy.com committed
43
			<tbody id="tablelist">
沈姿.前端(已离职) committed
44

zxt@theyeasy.com committed
45 46
			</tbody>
		</table>
47
		<div class="nodata">暂无数据</div>
zxt@theyeasy.com committed
48
		<div id="page"></div>
49

zxt@theyeasy.com committed
50 51 52 53 54 55
	</body>

	<script src='/zzhnc/res/js/jquery.min.js'></script>
	<script src="/zzhnc/res/plugins/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="/zzhnc/res/js/me.js"></script>
	<script>
56
		layui.use(['form', 'element', 'layer', 'laypage'], function() {
57 58
			var form = layui.form,
				element = layui.element,
zxt@theyeasy.com committed
59 60
				layer = layui.layer,
				laypage = layui.laypage;
61 62 63

			var queryObj = {
				page: 1,
沈姿.前端(已离职) committed
64
				size: 10,
65 66
				sellerId: 0,
				key: null
67
			};
沈姿.前端(已离职) committed
68

沈姿.前端(已离职) committed
69 70
			function initData(queryObj) {
				$.get("/zzhnc/goods/search", queryObj, function(data) {
71
					data = data.data;
zxt@theyeasy.com committed
72
					console.log(data)
沈姿.前端(已离职) committed
73

74
					$("#tablelist").html("");
75 76
					var str = "";
					if(data.rows.length < 1) {
77
						$(".nodata").show();
78
						$("#page").hide();
79
					} else {
80
						$(".nodata").hide();
81
						$("#page").show();
82 83 84
						for(var i = 0; i < data.rows.length; i++) {
							str += '<tr data-id=' + data.rows[i].id + '>' +
								'<td>' + ((data.page - 1) * data.pageSize + i + 1) + '</td>' +
沈姿.前端(已离职) committed
85 86 87
								'<td><img class="imgUrl" src="' + data.rows[i].bannerUrl + '"  /></td>' +
								'<td>' + data.rows[i].name + '</td>' +
								'<td>' + data.rows[i].description + '</td>' +
88 89 90 91
								'<td>' + data.rows[i].primePrice + '</td>' +
								'<td>' + data.rows[i].price + '</td>' +
								'<td>' + data.rows[i].sellerName + '</td>' +
								'<td>' + data.rows[i].sellerAddress + '</td>' +
沈姿.前端(已离职) committed
92 93 94 95
								'<td>' + data.rows[i].sellerPhone + '</td>' +
								'<td>' + ' <input type="checkbox" disabled  ' + (data.rows[i].isHome ? "checked" : "") + ' lay-skin="switch" lay-text="是|否"></td>' +
								'<td><a href="#" class="layui-btn layui-btn-sm updataBtn">修改</a>' +
								'<a href="#" class="layui-btn layui-btn-sm deleteBtn">删除</a>' +
96 97
								'</td>' +
								'</tr>';
zxt@theyeasy.com committed
98
						}
99 100 101
						$("#tablelist").html(str);
						toNull_G();
						form.render();
zxt@theyeasy.com committed
102
					}
103

沈姿.前端(已离职) committed
104 105
					laypage.render({
						elem: 'page',
沈姿.前端(已离职) committed
106
						count: data.totalPages,
沈姿.前端(已离职) committed
107 108 109 110 111 112 113 114
						curr: queryObj.page,
						jump: function(obj, first) {
							if(!first) {
								queryObj.page = obj.curr
								initData(queryObj);
							}
						}
					});
zxt@theyeasy.com committed
115 116
				})
			}
117

沈姿.前端(已离职) committed
118 119
			//初始化数据
			initData(queryObj);
沈姿.前端(已离职) committed
120 121 122

			//查询
			form.on('submit(querybtn)', function(data) {
123
				queryObj.key = $("[name=key]").val();
沈姿.前端(已离职) committed
124
				queryObj.page = 1;
沈姿.前端(已离职) committed
125
				initData(queryObj)
沈姿.前端(已离职) committed
126
			});
沈姿.前端(已离职) committed
127

沈姿.前端(已离职) committed
128
			//重置
沈姿.前端(已离职) committed
129
			$(".resetBtn").on("click", function() {
130
				$("[name=key]").val("");
沈姿.前端(已离职) committed
131
				queryObj.page = 1;
132
				queryObj.key = null;
沈姿.前端(已离职) committed
133
				initData(queryObj)
沈姿.前端(已离职) committed
134 135 136
				return false
			})

沈姿.前端(已离职) committed
137
			//添加商品
138
			$(document).on("click", ".createBtn", function() {
沈姿.前端(已离职) committed
139 140
				if(parent.tab.exists("添加商品") > 0) {
					var tabid = parent.tab.getTabId("添加商品");
zxt@theyeasy.com committed
141 142 143
					parent.tab.deleteTab(tabid);
				}
				parent.tab.tabAdd({
沈姿.前端(已离职) committed
144
					href: "/zzhnc/goods/goodsEdit?id=0",
zxt@theyeasy.com committed
145
					icon: "fa-cubes",
沈姿.前端(已离职) committed
146
					title: "添加商品"
zxt@theyeasy.com committed
147 148
				});
			})
沈姿.前端(已离职) committed
149

沈姿.前端(已离职) committed
150
			//修改商品
151 152
			$(document).on("click", ".updataBtn", function() {
				var id = $(this).parents("tr").attr("data-id");
沈姿.前端(已离职) committed
153 154
				if(parent.tab.exists("修改商品") > 0) {
					var tabid = parent.tab.getTabId("修改商品");
zxt@theyeasy.com committed
155 156 157
					parent.tab.deleteTab(tabid);
				}
				parent.tab.tabAdd({
沈姿.前端(已离职) committed
158
					href: "/zzhnc/goods/goodsEdit?id=" + id,
zxt@theyeasy.com committed
159
					icon: "fa-cubes",
沈姿.前端(已离职) committed
160
					title: "修改商品"
161
				});
zxt@theyeasy.com committed
162
			})
沈姿.前端(已离职) committed
163

沈姿.前端(已离职) committed
164
			//删除商品
zxt@theyeasy.com committed
165
			$(document).on("click", ".deleteBtn", function() {
166
				var id = $(this).parents("tr").attr("data-id");
沈姿.前端(已离职) committed
167
				layer.confirm('您确定要删除该爆款商品吗?', {
沈姿.前端(已离职) committed
168
					btn: ['确定', '取消']
zxt@theyeasy.com committed
169
				}, function(index, layero) {
170
					$.post("/zzhnc/goods/delete", {
171 172
						id: id
					}, function(data) {
zxt@theyeasy.com committed
173 174
						console.log(data)
						if(data.code == 0) {
175
							layer.msg("删除成功");
沈姿.前端(已离职) committed
176
							initData(queryObj);
zxt@theyeasy.com committed
177
							layer.close(index);
178
						} else {
179
							layer.msg(data.msg);
zxt@theyeasy.com committed
180 181
						}
					})
182 183 184 185

				}, function(index, layero) {
					layer.close(index);
				});
zxt@theyeasy.com committed
186 187 188 189 190 191
			});

		})
	</script>

</html>