审计记录

WebContent/WEB-INF/jsp/pc/goods/goodsEdit.jsp 7.6 KB
zxt@theyeasy.com committed
1 2 3 4 5
<%@ 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>

6 7 8 9 10 11 12
	<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">
		<title>商品编辑</title>
		<link rel="stylesheet" href="/zzhnc/res/plugins/layui/css/layui.css">
		<link rel="stylesheet" href="/zzhnc/res/css/basic.css">
沈姿.前端(已离职) committed
13

14
		<body class="wrap">
沈姿.前端(已离职) committed
15 16
			<form class="layui-form">
				<div class="layui-form-item">
17
					<label class="layui-form-label"><i class="redrequired">*</i>商品标题</label>
18
					<div class="layui-input-inline" style="width: 400px;">
19
						<input type="text" name="name" placeholder="商品标题" class="layui-input">
20
					</div>
沈姿.前端(已离职) committed
21 22 23
					<div class="layui-form-mid layui-word-aux">不超过20个汉字</div>
				</div>
				<div class="layui-form-item">
24
					<label class="layui-form-label"><i class="redrequired">*</i>上传主图</label>
25
					<div class="layui-input-inline" style="width: 400px;">
26 27 28 29 30 31 32 33
						<div class="layui-upload">
							<button type="button" class="layui-btn" id="upload">上传主图</button>
							<span class="layui-form-mid layui-word-aux">建议尺寸:200*200</span>
							<div class="layui-upload-list">
								<img class="layui-upload-img mainpictrue" src="">
								<input type="text" style="display:none;" name="bannerUrl">
							</div>
						</div>
34
					</div>
沈姿.前端(已离职) committed
35 36
				</div>
				<div class="layui-form-item">
37
					<label class="layui-form-label"><i class="redrequired">*</i>商品原价</label>
沈姿.前端(已离职) committed
38
					<div class="layui-input-inline" style="width: 100px;">
沈姿.前端(已离职) committed
39
						<input type="number" name="primePrice" placeholder="商品原价" class="layui-input">
沈姿.前端(已离职) committed
40 41
					</div>
					<div class="layui-form-mid"></div>
42
					<label class="layui-form-label"><i class="redrequired">*</i>商品现价</label>
沈姿.前端(已离职) committed
43
					<div class="layui-input-inline" style="width: 100px;">
沈姿.前端(已离职) committed
44
						<input type="number" name="price" placeholder="商品现价" class="layui-input">
沈姿.前端(已离职) committed
45 46 47
					</div>
					<div class="layui-form-mid"></div>
				</div>
沈姿.前端(已离职) committed
48 49 50 51 52 53 54 55 56 57
				<div class="layui-form-item">
					<label class="layui-form-label">是否首页显示</label>
					<div class="layui-input-inline" style="width: 100px;">
						<input type="checkbox" checked name="isHome" lay-skin="switch" lay-text="是|否">
					</div>
					<label class="layui-form-label">是否爆款</label>
					<div class="layui-input-inline" style="width: 100px;">
						<input type="checkbox" checked name="isHot" lay-skin="switch" lay-text="是|否">
					</div>
				</div>
沈姿.前端(已离职) committed
58
				<div class="layui-form-item">
59
					<label class="layui-form-label"><i class="redrequired">*</i>商家名称</label>
60
					<div class="layui-input-inline" style="width: 400px;">
沈姿.前端(已离职) committed
61
						<input type="text" name="sellerName" placeholder="商家名称" class="layui-input">
沈姿.前端(已离职) committed
62 63 64
					</div>
				</div>
				<div class="layui-form-item">
65
					<label class="layui-form-label"><i class="redrequired">*</i>商家店铺号</label>
66
					<div class="layui-input-inline" style="width: 400px;">
沈姿.前端(已离职) committed
67
						<input type="text" name="sellerAddress" placeholder="商家店铺号" class="layui-input">
68
					</div>
沈姿.前端(已离职) committed
69 70
				</div>
				<div class="layui-form-item">
71 72
					<label class="layui-form-label"><i class="redrequired">*</i>商家电话</label>
					<div class="layui-input-inline" style="width: 400px;">
沈姿.前端(已离职) committed
73
						<input type="text" name="sellerPhone" placeholder="商家电话" class="layui-input">
沈姿.前端(已离职) committed
74 75
					</div>
				</div>
76 77 78 79
				<div class="layui-form-item">
					<label class="layui-form-label">商品详情</label>
					<div class="layui-input-block" style="margin-left: 130px;">
						<textarea name="description" placeholder="商品详情" class="layui-textarea"></textarea>
80
					</div>
81
				</div>
沈姿.前端(已离职) committed
82 83 84 85 86 87
				<div class="layui-form-item">
					<label class="layui-form-label"></label>
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="submit">提交</button>
						<button class="layui-btn layui-btn-primary resetBtn">重置</button>
					</div>
沈姿.前端(已离职) committed
88 89
				</div>
			</form>
90 91 92 93 94
		</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>
95
			layui.use(['form', 'element', 'layer', 'upload'], function() {
沈姿.前端(已离职) committed
96 97
				var form = layui.form,
					element = layui.element,
98 99
					layer = layui.layer,
					upload = layui.upload;
沈姿.前端(已离职) committed
100

101 102 103
				var goodsid = getUrl_G("id");

				function initData() {
沈姿.前端(已离职) committed
104 105 106
					$.get("/zzhnc/goods/search", {
						id: goodsid
					}, function(data) {
107
						console.log(data)
沈姿.前端(已离职) committed
108 109
						if(data.code == 0) {
							if(data.data.rows.length > 0) {
110 111 112
								var data = data.data.rows[0];
								$("[name=name]").val(data.name);
								$("[name=description]").val(data.description);
113 114
								$(".mainpictrue").attr("src", data.bannerUrl).css("margin-top", "15px");
								$("[name=bannerUrl]").val(data.bannerUrl);
115 116
								$("[name=primePrice]").val(data.primePrice);
								$("[name=price]").val(data.price);
沈姿.前端(已离职) committed
117 118 119 120 121 122 123 124 125 126
								if(data.isHome) {
									$("[name=isHome]").checked = true;
								} else {
									$("[name=isHome]").checked = false;
								}
								if(data.isHot) {
									$("[name=isHot]").checked = true;
								} else {
									$("[name=isHot]").checked = false;
								}
127 128
								$("[name=sellerName]").val(data.sellerName);
								$("[name=sellerAddress]").val(data.sellerAddress);
沈姿.前端(已离职) committed
129 130
								$("[name=sellerPhone]").val(data.sellerPhone);
								form.render();
131
							}
132 133
						} else {
							layer.msg("获取信息失败");
134
						}
沈姿.前端(已离职) committed
135

136 137 138 139
					})
				}

				//初始化数据
140 141
				if(goodsid > 0) {
					initData();
沈姿.前端(已离职) committed
142
				}
zxt@theyeasy.com committed
143

144
				//上传操作
沈姿.前端(已离职) committed
145
				upload.render({
146 147 148 149 150
					elem: '#upload',
					url: '/zzhnc/upload/UploadImg',
					done: function(data) {
						console.log(data)
						if(data.code == 0) {
沈姿.前端(已离职) committed
151
							layer.msg("上传成功");
152 153
							$("[name=bannerUrl]").val(data.data.imgurl);
							$(".mainpictrue").attr("src", data.data.imgurl).css("margin-top", "15px");
沈姿.前端(已离职) committed
154 155
						} else {
							layer.msg('上传失败');
156 157 158
						}
					}
				});
159

沈姿.前端(已离职) committed
160
				//提交
161
				form.on("submit(submit)", function(data) {
162
					var isHome, isHot = false;
163
					if(data.field.isHome == "on") {
164
						isHome = true
沈姿.前端(已离职) committed
165
					}
166
					if(data.field.isHot == "on") {
167
						isHot = true
沈姿.前端(已离职) committed
168
					}
169
					var submitData = {
170
						id: parseInt(goodsid, 10),
171 172
						name: data.field.name,
						description: data.field.description,
173 174
						bannerUrl: $("[name=bannerUrl]").val(),
						imgUrl: $("[name=bannerUrl]").val(),
175 176 177 178 179 180 181 182 183 184
						isHome: isHome,
						isHot: isHot,
						primePrice: data.field.primePrice,
						price: data.field.price,
						sellerId: 0,
						sellerName: data.field.sellerName,
						sellerAddress: data.field.sellerAddress,
						sellerPhone: data.field.sellerPhone
					};
					$.ajax({
185 186 187 188 189 190 191 192 193 194 195 196
						type: 'POST',
						url: '/zzhnc/goods/update',
						dataType: 'json',
						async: true,
						contentType: "application/json;charset=UTF-8",
						data: JSON.stringify(submitData),
						success: function(data) {
							layer.msg('操作成功');
						},
						error: function(xhr, type) {
							layer.msg('操作失败');
						}
197
					});
沈姿.前端(已离职) committed
198 199 200
					return false;
				})
				
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
				//重置
				$(".resetBtn").on("click", function() {
					$("[name=name]").val("");
					$("[name=description]").val("");
					$("[name=bannerUrl]").val("");
					$(".mainpictrue").attr("src", "").css("margin-top", "0");
					$("[name=isHome]").val("on");
					$("[name=isHot]").val("on");
					$("[name=primePrice]").val("");
					$("[name=price]").val("");
					$("[name=sellerName]").val("");
					$("[name=sellerAddress]").val("");
					$("[name=sellerPhone]").val("");
					form.render();
				})
沈姿.前端(已离职) committed
216 217
				
				
zxt@theyeasy.com committed
218

219 220
			})
		</script>
zxt@theyeasy.com committed
221 222

</html>