审计记录

WebContent/WEB-INF/jsp/pc/activity/activityEdit.jsp 7.1 KB
沈姿.前端(已离职) committed
1 2
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
zxt@theyeasy.com committed
3 4
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
5

zxt@theyeasy.com committed
6 7 8 9
	<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">
沈姿.前端(已离职) committed
10
		<title>文章编辑</title>
zxt@theyeasy.com committed
11 12
		<link rel="stylesheet" href="/zzhnc/res/plugins/layui/css/layui.css">
		<link rel="stylesheet" href="/zzhnc/res/css/basic.css">
沈姿.前端(已离职) committed
13
		<style type="text/css">
14 15 16 17
			#container * {
				-webkit-box-sizing: content-box;
				-moz-box-sizing: content-box;
				box-sizing: content-box;
沈姿.前端(已离职) committed
18 19
			}
			
20 21 22 23 24
			#container *:before,
			.edui-container *:after {
				-webkit-box-sizing: content-box;
				-moz-box-sizing: content-box;
				box-sizing: content-box;
沈姿.前端(已离职) committed
25 26
			}
			
27 28
			#container img {
				max-width: 80%;
沈姿.前端(已离职) committed
29 30
			}
		</style>
31
		<script src="http://cdn.sockjs.org/sockjs-0.3.min.js"></script>
沈姿.前端(已离职) committed
32 33

		<body class="wrap">
34
			<div class="layui-form">
沈姿.前端(已离职) committed
35
				<div class="layui-form-item">
36
					<label class="layui-form-label">文章标题</label>
沈姿.前端(已离职) committed
37
					<div class="layui-input-inline" style="width: 400px;">
38
						<input type="text" name="title" lay-verify="required|title" placeholder="文章标题" class="layui-input">
沈姿.前端(已离职) committed
39 40
					</div>
					<div class="layui-form-mid layui-word-aux">不超过20个汉字</div>
41
				</div>
沈姿.前端(已离职) committed
42
				<div class="layui-form-item">
43 44 45 46 47 48 49 50 51 52
					<label class="layui-form-label"><i class="redrequired">*</i>专区类型</label>
					<div class="layui-input-inline" style="width: 400px;">
						<select name="type" lay-verify="required">
							<option value="">请选择</option>
							<option value="1">活动预告</option>
							<option value="2">福利专区</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
53
					<label class="layui-form-label"><i class="redrequired">*</i>上传主图</label>
沈姿.前端(已离职) committed
54
					<div class="layui-input-inline" style="width: 400px;">
55 56 57 58 59
						<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="">
60
								<input type="text" style="display:none;" name="imgurl" lay-verify="required">
61 62
							</div>
						</div>
沈姿.前端(已离职) committed
63
					</div>
zxt@theyeasy.com committed
64
				</div>
65 66
				<div class="layui-form-item" style="display: none">
					<label class="layui-form-label">文章内容</label>
67 68
					<div class="layui-input-block" style="margin-left: 130px;"> 
						<!-- 加载编辑器的容器 -->
沈姿.前端(已离职) committed
69
						<script id="container" name="content" type="text/plain">
70

沈姿.前端(已离职) committed
71 72
						</script>
					</div>
73
				</div>
沈姿.前端(已离职) committed
74 75 76 77 78 79 80
				<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>
				</div>
81
			</div>
沈姿.前端(已离职) committed
82
		</body>
83

沈姿.前端(已离职) committed
84 85 86 87
		<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>
88
			/*window.onload = function() {
沈姿.前端(已离职) committed
89 90 91 92 93 94
				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);
95
					}
zxt@theyeasy.com committed
96
				}
沈姿.前端(已离职) committed
97 98 99 100 101
				window.UEDITOR_CONFIG.initialFrameWidth = 900;
				window.UEDITOR_CONFIG.initialFrameHeight = 600;
				var ue = UE.getEditor('container', {
					autoHeight: false
				});
102
			}*/
沈姿.前端(已离职) committed
103 104 105 106 107 108 109

			layui.use(['form', 'element', 'layer', 'upload'], function() {
				var form = layui.form,
					element = layui.element,
					layer = layui.layer,
					upload = layui.upload;

110
				var id = getUrl_G("id");
沈姿.前端(已离职) committed
111

112
				//初始化函数
沈姿.前端(已离职) committed
113
				function initData() {
114 115
					$.get("/zzhnc/article/getArticle", {
						id: id
沈姿.前端(已离职) committed
116
					}, function(data) {
117
						console.log(data);
沈姿.前端(已离职) committed
118
						if(data.code == 0) {
119
							$("[name=title]").val(data.data.title);
120
							/*UE.getEditor("container").ready(function() {
121
								UE.getEditor("container").setContent(unescape(data.data.content));
122 123
							})*/
							$("[name=type]").val(data.data.type);
124 125 126
							$("[name=imgurl]").val(data.data.imgurl);
							$(".mainpictrue").attr("src", data.data.imgurl).css("margin-top", "15px");
							form.render();
zxt@theyeasy.com committed
127
						}
沈姿.前端(已离职) committed
128
					})
zxt@theyeasy.com committed
129
				}
130

131 132 133
				//初始化操作
				if(id > 0) {
					initData()
zxt@theyeasy.com committed
134
				}
沈姿.前端(已离职) committed
135

136
				//上传操作
沈姿.前端(已离职) committed
137 138 139 140 141 142
				upload.render({
					elem: '#upload',
					url: '/zzhnc/upload/UploadImg',
					done: function(data) {
						console.log(data)
						if(data.code == 0) {
143 144
							$("[name=imgurl]").val(data.data.imgurl);
							$(".mainpictrue").attr("src", data.data.imgurl).css("margin-top", "15px");
沈姿.前端(已离职) committed
145
						} else {
146
							return layer.msg('上传失败');
zxt@theyeasy.com committed
147 148
						}
					}
沈姿.前端(已离职) committed
149
				});
150

沈姿.前端(已离职) committed
151
				//提交
152 153
				form.on('submit(submit)', function(data) {
					var title = $("[name=title]").val();
154
					//var content = UE.getEditor('container').getContent();
155
					var imgurl = $("[name=imgurl]").val();
156 157
					var type = $("[name=type]").val();
					/*if(title == "") {
158 159 160 161 162 163 164
						top.layer.msg("请填写文章标题");
						return false;
					} else {
						if(strlen(title) > 40) {
							top.layer.msg("文章标题不超过20个汉字");
							return false;
						}
165 166 167 168 169 170 171 172
					}*/
					if(strlen(title) > 40) {
						top.layer.msg("文章标题不超过20个汉字");
						return false;
					}
					if(type < 1){
						top.layer.msg("请选择专区类型");
						return false;
173
					}
174 175 176 177
					if(imgurl == "") {
						top.layer.msg("请上传主图");
						return false;
					}
178
					/*if(content == "") {
179 180
						top.layer.msg("请输入内容");
						return false;
181
					}*/
182 183 184 185 186
					if(id > 0) {
						//修改项目
						$.post("/zzhnc/article/updateArticle", {
							id: id,
							title: title,
187 188
							//content: content,
							type: type,
189 190 191 192 193 194 195 196 197 198 199 200 201
							imgurl: imgurl
						}, function(data) {
							console.log(data);
							if(data.code == 0) {
								top.layer.msg("修改成功");
							} else {
								top.layer.msg(data.msg);
							}
						})
					} else {
						//添加项目
						$.post("/zzhnc/article/addArticle", {
							title: title,
202 203
							//content: content,
							type: type,
204 205 206 207 208 209 210 211 212 213
							imgurl: imgurl
						}, function(data) {
							console.log(data);
							if(data.code == 0) {
								top.layer.msg("添加成功");
								form.render();
							} else {
								top.layer.msg(data.msg);
							}
						})
zxt@theyeasy.com committed
214 215
					}
					return false;
216 217 218 219 220
				});

				//重置
				$(".resetBtn").on("click", function() {
					$("[name=title]").val("");
221 222
					//$("[name=content]").val("");
					$("[name=type]").val("");
223 224 225
					$("[name=imgurl]").val("");
					$(".mainpictrue").attr("src", "").css("margin-top", "0");
					form.render();
沈姿.前端(已离职) committed
226
				})
227

沈姿.前端(已离职) committed
228 229
			})
		</script>
zxt@theyeasy.com committed
230

231 232 233 234 235 236
		<!-- 配置文件 -->
		<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
237
</html>