审计记录

WebContent/WEB-INF/jsp/pc/goods/goodsEdit.jsp 8.1 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 13
	<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">
		<style type="text/css">
沈姿.前端(已离职) committed
14 15 16
			.red {
				color: red;
				margin-right: 5px;
17
			}
18 19
			
			.layui-form-label {
沈姿.前端(已离职) committed
20 21
				width: 100px;
			}
22 23
			
			#container {
沈姿.前端(已离职) committed
24 25
				margin-left: 20px;
			}
沈姿.前端(已离职) committed
26 27
			
			.bannerUrl {
28 29 30
				width: 200px;
				height: 200px;
			}
31
		</style>
沈姿.前端(已离职) committed
32

33
		<body class="wrap">
沈姿.前端(已离职) committed
34 35 36
			<form class="layui-form">
				<div class="layui-form-item">
					<label class="layui-form-label"><i class="red">*</i>商品主标题</label>
37
					<div class="layui-input-inline" style="width: 400px;">
沈姿.前端(已离职) committed
38
						<input type="text" name="name" placeholder="商品主标题" class="layui-input">
39
					</div>
沈姿.前端(已离职) committed
40 41 42 43
					<div class="layui-form-mid layui-word-aux">不超过20个汉字</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label"><i class="red">*</i>商品副标题</label>
44
					<div class="layui-input-inline" style="width: 400px;">
沈姿.前端(已离职) committed
45
						<input type="text" name="description" placeholder="商品副标题" class="layui-input">
46
					</div>
沈姿.前端(已离职) committed
47 48 49
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label"><i class="red">*</i>商品主图</label>
50 51 52
					<div class="layui-input-block">
						<img class="bannerUrl" />
						<button type="button" class="layui-btn" id="upload">上传商品主图</button>
53
					</div>
沈姿.前端(已离职) committed
54 55
				</div>
				<div class="layui-form-item">
沈姿.前端(已离职) committed
56 57
					<label class="layui-form-label"><i class="red">*</i>商品原价</label>
					<div class="layui-input-inline" style="width: 100px;">
沈姿.前端(已离职) committed
58
						<input type="number" name="primePrice" placeholder="商品原价" class="layui-input">
沈姿.前端(已离职) committed
59 60 61 62
					</div>
					<div class="layui-form-mid"></div>
					<label class="layui-form-label"><i class="red">*</i>商品现价</label>
					<div class="layui-input-inline" style="width: 100px;">
沈姿.前端(已离职) committed
63
						<input type="number" name="price" placeholder="商品现价" class="layui-input">
沈姿.前端(已离职) committed
64 65 66
					</div>
					<div class="layui-form-mid"></div>
				</div>
沈姿.前端(已离职) committed
67 68 69 70 71 72 73 74 75 76
				<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
77 78
				<div class="layui-form-item">
					<label class="layui-form-label"><i class="red">*</i>商家名称</label>
79
					<div class="layui-input-inline" style="width: 400px;">
沈姿.前端(已离职) committed
80
						<input type="text" name="sellerName" placeholder="商家名称" class="layui-input">
沈姿.前端(已离职) committed
81 82 83 84
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label"><i class="red">*</i>商家店铺号</label>
85
					<div class="layui-input-inline" style="width: 400px;">
沈姿.前端(已离职) committed
86
						<input type="text" name="sellerAddress" placeholder="商家店铺号" class="layui-input">
87
					</div>
沈姿.前端(已离职) committed
88 89
				</div>
				<div class="layui-form-item">
沈姿.前端(已离职) committed
90 91
					<label class="layui-form-label"><i class="red">*</i>商家电话</label>
					<div class="layui-input-inline" style="width: 390px;">
沈姿.前端(已离职) committed
92
						<input type="text" name="sellerPhone" placeholder="商家电话" class="layui-input">
沈姿.前端(已离职) committed
93 94
					</div>
				</div>
沈姿.前端(已离职) committed
95
				<!--<div class="layui-form-item">
沈姿.前端(已离职) committed
96 97 98 99 100
					<label class="layui-form-label"><i class="red">*</i>详细信息</label>
					<div class="layui-input-block">
						<script id="container" name="content" type="text/plain">
							这里写你的初始化内容
						</script>
101
					</div>
沈姿.前端(已离职) committed
102 103 104 105 106 107 108
				</div> -->
				<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
109 110
				</div>
			</form>
111 112 113 114
		</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>
沈姿.前端(已离职) committed
115 116
		<!--<script type="text/javascript" src="/zzhnc/res/UE/ueditor.config.js"></script>
		<script type="text/javascript" src="/zzhnc/res/UE/ueditor.all.js"></script>-->
117
		<script>
沈姿.前端(已离职) committed
118
			/*window.onload = function() {
119 120 121 122 123 124 125 126 127 128 129 130 131
				UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
				UE.Editor.prototype.getActionUrl = function(action) {
					if(action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadimage') {
						return '/zzhnc/upload/NewUploadImg';
					} else {
						return this._bkGetActionUrl.call(this, action);
					}
				}
				window.UEDITOR_CONFIG.initialFrameWidth = 900;
				window.UEDITOR_CONFIG.initialFrameHeight = 600;
				var ue = UE.getEditor('container', {
					autoHeight: false
				});
沈姿.前端(已离职) committed
132
			}*/
zxt@theyeasy.com committed
133

134
			layui.use(['form', 'element', 'layer', 'upload'], function() {
沈姿.前端(已离职) committed
135 136
				var form = layui.form,
					element = layui.element,
137 138
					layer = layui.layer,
					upload = layui.upload;
沈姿.前端(已离职) committed
139

140 141 142
				var goodsid = getUrl_G("id");

				function initData() {
沈姿.前端(已离职) committed
143 144 145
					$.get("/zzhnc/goods/search", {
						id: goodsid
					}, function(data) {
146
						console.log(data)
沈姿.前端(已离职) committed
147 148
						if(data.code == 0) {
							if(data.data.rows.length > 0) {
149 150 151 152 153 154
								var data = data.data.rows[0];
								$("[name=name]").val(data.name);
								$("[name=description]").val(data.description);
								$(".bannerUrl").attr("src", data.bannerUrl);
								$("[name=primePrice]").val(data.primePrice);
								$("[name=price]").val(data.price);
沈姿.前端(已离职) committed
155 156 157 158 159 160 161 162 163 164
								if(data.isHome) {
									$("[name=isHome]").checked = true;
								} else {
									$("[name=isHome]").checked = false;
								}
								if(data.isHot) {
									$("[name=isHot]").checked = true;
								} else {
									$("[name=isHot]").checked = false;
								}
165 166
								$("[name=sellerName]").val(data.sellerName);
								$("[name=sellerAddress]").val(data.sellerAddress);
沈姿.前端(已离职) committed
167 168 169 170 171
								$("[name=sellerPhone]").val(data.sellerPhone);

								form.render();

								/*UE.getEditor("container").ready(function() {
172
									UE.getEditor("container").setContent(unescape(data.description));
沈姿.前端(已离职) committed
173 174
								})*/

175 176
							}
						}
沈姿.前端(已离职) committed
177

178 179 180 181
					})
				}

				//初始化数据
沈姿.前端(已离职) committed
182 183 184
				if(goodsid > 0){
					initData();	
				}
zxt@theyeasy.com committed
185

186
				//普通图片上传
沈姿.前端(已离职) committed
187
				upload.render({
188 189 190 191 192
					elem: '#upload',
					url: '/zzhnc/upload/UploadImg',
					done: function(data) {
						console.log(data)
						if(data.code == 0) {
沈姿.前端(已离职) committed
193 194
							layer.msg("上传成功");
							$(".bannerUrl").attr("src", data.data.imgurl);
沈姿.前端(已离职) committed
195 196
						} else {
							layer.msg('上传失败');
197 198 199
						}
					}
				});
沈姿.前端(已离职) committed
200 201
				
				//提交
202 203
				form.on("submit(submit)", function(data){
					var isHome, isHot = false;
沈姿.前端(已离职) committed
204
					if(data.field.isHome == "on"){
205
						isHome = true
沈姿.前端(已离职) committed
206 207
					}
					if(data.field.isHot == "on"){
208
						isHot = true
沈姿.前端(已离职) committed
209
					}
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
					var submitData = {
						id: parseInt(goodsid,10),
						name: data.field.name,
						description: data.field.description,
						bannerUrl: $(".bannerUrl").attr("src"),
						imgUrl: $(".bannerUrl").attr("src"),
						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
					};
沈姿.前端(已离职) committed
225
					//data.field.content = UE.getEditor('container').getContent();
226 227 228 229 230 231 232 233 234 235 236 237 238 239
					$.ajax({
					    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('操作失败');
					    }
					});
沈姿.前端(已离职) committed
240 241 242 243 244
					return false;
				})
				
				//修改方法
				function updateGoods(data){
245
					
沈姿.前端(已离职) committed
246
				}
zxt@theyeasy.com committed
247

248 249
			})
		</script>
zxt@theyeasy.com committed
250 251

</html>