审计记录

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
		<link rel="stylesheet" href="/zzhnc/res/plugins/layui/css/layui.css">
		<link rel="stylesheet" href="/zzhnc/res/css/basic.css">
沈姿.前端(已离职) committed
12
		<style>
沈姿.前端(已离职) committed
13
			.imgUrl {
沈姿.前端(已离职) committed
14 15 16 17 18
				width: 50px;
				height: 50px;
				display: block;
			}
		</style>
zxt@theyeasy.com committed
19
	</head>
沈姿.前端(已离职) committed
20

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

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

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

zxt@theyeasy.com committed
52 53
			</tbody>
		</table>
54
		<div class="nodata">暂无数据</div>
zxt@theyeasy.com committed
55
		<div id="page"></div>
56

zxt@theyeasy.com committed
57 58 59 60 61 62 63
	</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>
		layui.use(['form', 'element', 'laydate', 'layer', 'laypage'], function() {
64 65
			var form = layui.form,
				element = layui.element,
zxt@theyeasy.com committed
66 67 68
				laydate = layui.laydate,
				layer = layui.layer,
				laypage = layui.laypage;
69 70 71

			var queryObj = {
				page: 1,
沈姿.前端(已离职) committed
72 73
				size: 10,
				sellerId: 0
74
			};
沈姿.前端(已离职) committed
75

沈姿.前端(已离职) committed
76 77
			function initData(queryObj) {
				$.get("/zzhnc/goods/search", queryObj, function(data) {
78
					data = data.data;
zxt@theyeasy.com committed
79
					console.log(data)
沈姿.前端(已离职) committed
80

81 82
					var str = "";
					if(data.rows.length < 1) {
83
						$(".nodata").show();
84
					} else {
85
						$(".nodata").hide();
86 87 88
						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
89 90 91
								'<td><img class="imgUrl" src="' + data.rows[i].bannerUrl + '"  /></td>' +
								'<td>' + data.rows[i].name + '</td>' +
								'<td>' + data.rows[i].description + '</td>' +
92 93 94 95
								'<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
96 97 98 99
								'<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>' +
100 101
								'</td>' +
								'</tr>';
zxt@theyeasy.com committed
102 103
						}
					}
104

zxt@theyeasy.com committed
105
					$("#tablelist").html(str);
沈姿.前端(已离职) committed
106

zxt@theyeasy.com committed
107
					toNull_G();
沈姿.前端(已离职) committed
108 109
					form.render();

沈姿.前端(已离职) committed
110 111
					laypage.render({
						elem: 'page',
沈姿.前端(已离职) committed
112
						count: data.totalPages,
沈姿.前端(已离职) committed
113 114 115 116 117 118 119 120
						curr: queryObj.page,
						jump: function(obj, first) {
							if(!first) {
								queryObj.page = obj.curr
								initData(queryObj);
							}
						}
					});
zxt@theyeasy.com committed
121 122
				})
			}
123

沈姿.前端(已离职) committed
124 125
			//初始化数据
			initData(queryObj);
沈姿.前端(已离职) committed
126 127 128 129 130

			//查询
			form.on('submit(querybtn)', function(data) {
				queryObj.keyword = $("[name=keyword]").val();
				queryObj.page = 1;
沈姿.前端(已离职) committed
131
				initData(queryObj)
沈姿.前端(已离职) committed
132
			});
沈姿.前端(已离职) committed
133

沈姿.前端(已离职) committed
134
			//重置
沈姿.前端(已离职) committed
135
			$(".resetBtn").on("click", function() {
沈姿.前端(已离职) committed
136 137 138 139
				$("[name=keyword]").val("");
				queryObj.page = 1;
				queryObj.sellerId = 0;
				initData(queryObj)
沈姿.前端(已离职) committed
140 141 142
				return false
			})

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

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

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

				}, function(index, layero) {
					layer.close(index);
				});
zxt@theyeasy.com committed
192 193 194 195 196 197
			});

		})
	</script>

</html>