审计记录

WebContent/WEB-INF/jsp/pc/goods/goodsEdit.jsp 8.2 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 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
	<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">
			.activity-rule-box {
				padding-left: 20px;
			}
			
			#myEditor img {
				width: 80%;
			}
			
			#myEditor {
				margin: 0 !important;
			}
			
			.layui-form-select dl {
				max-height: 190px;
			}
			
			#allmap {
				top: 10px;
				width: 100%;
				height: 400px;
				overflow: hidden;
				margin: 0;
			}
			
			.layui-upload-list {
				width: 200px;
				max-height: 200px;
				overflow: hidden;
				clear: both;
				border-radius: 4px;
			}
			
			.layui-upload-list img {
				width: 100%;
				margin-top: 15px;
			}
			
			#connect-container {
				float: left;
				width: 400px
			}
			
			#connect-container div {
				padding: 5px;
			}
			
			#console-container {
				float: left;
				margin-left: 15px;
				width: 400px;
			}
			
			#console {
				border: 1px solid #CCCCCC;
				border-right-color: #999999;
				border-bottom-color: #999999;
				height: 170px;
				overflow-y: scroll;
				padding: 5px;
				width: 100%;
			}
			
			#console p {
				padding: 0;
				margin: 0;
			}
			
			#container * {
				-webkit-box-sizing: content-box;
				-moz-box-sizing: content-box;
				box-sizing: content-box;
			}
			
			#container *:before,
			.edui-container *:after {
				-webkit-box-sizing: content-box;
				-moz-box-sizing: content-box;
				box-sizing: content-box;
			}
			
			#container img {
				max-width: 80%;
			}
		</style>
		<script src="http://cdn.sockjs.org/sockjs-0.3.min.js"></script>
		<body class="wrap">
			<div class="layui-form Detailbtn" style="display: block;">
				<form action="server.php" method="post">
					<div class="layui-form-item">
						<label class="layui-form-label"><i
				style="color: red; margin-right: 5px;">*</i>商品主标题</label>
						<div class="layui-input-inline" style="width: 390px;">
							<input type="text" name="title" lay-verify="title" placeholder="商品主标题" class="layui-input">
						</div>
						<div class="layui-form-mid layui-word-aux">不超过20个汉字</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label"><i
				style="color: red; margin-right: 5px;">*</i>商品副标题</label>
						<div class="layui-input-inline" style="width: 390px;">
							<input type="text" name="subtitle" lay-verify="title" placeholder="商品副标题" class="layui-input">
						</div>
						<div class="layui-form-mid layui-word-aux">不超过20个汉字</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label"><i
				style="color: red; margin-right: 5px;">*</i>商品主图</label>
zxt@theyeasy.com committed
121

122 123 124 125 126 127 128 129 130 131 132 133 134
						<div class="layui-input-inline" style="width: 390px;">
							<div class="layui-upload">
								<button type="button" class="layui-btn" id="upload" style="margin:0 20px 0 0;float:left;">上传商品主图</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="imgurl">
									<p id="demoText"></p>
								</div>
							</div>
						</div>
						<div class="layui-form-mid layui-word-aux"></div>
					</div>
zxt@theyeasy.com committed
135

136 137 138 139 140 141 142 143
					<div class="layui-form-item">
						<label class="layui-form-label"><i
				style="color: red; margin-right: 5px;">*</i>详细信息</label>
						<div class="layui-input-block">
							<!-- 加载编辑器的容器 -->
							<script id="container" name="content" type="text/plain">
								这里写你的初始化内容
							</script>
zxt@theyeasy.com committed
144

145 146
						</div>
					</div>
zxt@theyeasy.com committed
147

148 149 150 151 152
					<div class="layui-form-item" style="margin-top: 30px;">
						<button class="layui-btn" lay-submit lay-filter="submit">提交</button>
						<button class="layui-btn layui-btn-primary resetBtn">重置</button>
					</div>
				</form>
zxt@theyeasy.com committed
153 154
			</div>

155
		</body>
zxt@theyeasy.com committed
156

157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
		<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>
			window.onload = function() {
				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;
				//UE.getEditor("container");  
				var ue = UE.getEditor('container', {
					autoHeight: false
				});
zxt@theyeasy.com committed
176

177
			}
zxt@theyeasy.com committed
178

179 180 181 182 183 184 185 186
			layui.use(['form', 'element', 'laydate', 'layer', 'laypage', 'layedit', 'upload'], function() {
				var form = layui.form(),
					element = layui.element(),
					laydate = layui.laydate,
					layer = layui.layer,
					laypage = layui.laypage;
				var $ = layui.jquery,
					upload = layui.upload;
zxt@theyeasy.com committed
187

188 189 190 191 192 193 194 195 196 197 198
				//普通图片上传
				//普通图片上传
				var uploadInst = upload.render({
					elem: '#upload',
					url: '/zzhnc/upload/UploadImg',
					done: function(data) {
						console.log(data)
						if(data.code == 0) {
							imgurl = data.data;
							$("input[name=imgurl]").val(imgurl);
							$(".mainpictrue").attr("src", imgurl);
zxt@theyeasy.com committed
199

200
						}
zxt@theyeasy.com committed
201

202 203 204 205 206 207
						//如果上传失败
						if(data.code > 0) {
							return layer.msg('上传失败');
						}
						//上传成功
					}
zxt@theyeasy.com committed
208

209
				});
zxt@theyeasy.com committed
210

211 212 213 214 215 216
				$(".resetBtn").on("click", function() {
					$("input[name=title]").val("");
					$("textarea[name=content]").val("");
					$("input[name=imgurl]").val("");
					$(".mainpictrue").attr("src", "");
					form.render();
zxt@theyeasy.com committed
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
				var id = getUrl_G("id");
				if(id > 0) {
					$.post("/zzhnc/article/getArticle", {
						id: id
					}, function(data) {
						console.log(data);
						if(data.code == 0) {
							$("input[name=title]").val(data.data.title);
							//$("textarea[name=content]").val(data.data.content);	
							//重新渲染
							UE.getEditor("container").ready(function() {
								UE.getEditor("container").setContent(unescape(data.data.content));
							})
							$("input[name=imgurl]").attr("src", data.data.imgurl);
							$(".mainpictrue").attr("src", data.data.imgurl);
							form.render();
						}
					})

				}

				form.on('submit(submit)', function(data) {
					var title = $("input[name=title]").val();
					var content = UE.getEditor('container').getContent();
					var imgurl = $("input[name=imgurl]").val();
					if(title == "") {
zxt@theyeasy.com committed
244 245
						top.layer.msg("请填写文章标题");
						return false;
246
					} else {
zxt@theyeasy.com committed
247
						if(strlen(title) > 40) {
248 249
							top.layer.msg("文章标题不超过20个汉字");
							return false;
zxt@theyeasy.com committed
250 251
						}
					}
252
					if(imgurl == "") {
zxt@theyeasy.com committed
253 254 255
						top.layer.msg("请上传主图");
						return false;
					}
256
					if(content == "") {
zxt@theyeasy.com committed
257 258 259
						top.layer.msg("请输入内容");
						return false;
					}
260 261
					console.log()
					if(id > 0) {
zxt@theyeasy.com committed
262
						//修改项目
263 264 265 266 267 268
						$.post("/zzhnc/article/updateArticle", {
							id: id,
							title: title,
							content: content,
							imgurl: imgurl
						}, function(data) {
zxt@theyeasy.com committed
269
							console.log(data);
270
							if(data.code == 0) {
zxt@theyeasy.com committed
271
								top.layer.msg("修改成功");
272 273

							} else {
zxt@theyeasy.com committed
274 275
								top.layer.msg(data.msg);
							}
276 277
						})
					} else {
zxt@theyeasy.com committed
278
						//添加项目
279 280 281 282 283
						$.post("/zzhnc/article/addArticle", {
							title: title,
							content: content,
							imgurl: imgurl
						}, function(data) {
zxt@theyeasy.com committed
284
							console.log(data);
285
							if(data.code == 0) {
zxt@theyeasy.com committed
286 287
								top.layer.msg("添加成功");
								form.render();
288
							} else {
zxt@theyeasy.com committed
289 290
								top.layer.msg(data.msg);
							}
291
						})
zxt@theyeasy.com committed
292 293 294
					}
					return false;

295
				});
zxt@theyeasy.com committed
296

297 298
			})
		</script>
zxt@theyeasy.com committed
299

300 301 302 303 304
		<!-- 配置文件 -->
		<script type="text/javascript" src="/zzhnc/res/UE/ueditor.config.js"></script>
		<!-- 编辑器源码文件 -->
		<script type="text/javascript" src="/zzhnc/res/UE/ueditor.all.js"></script>
		<!-- 实例化编辑器 -->
zxt@theyeasy.com committed
305 306

</html>