审计记录

WebContent/WEB-INF/jsp/pc/activity/activityEdit.jsp 6.4 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"><i class="redrequired">*</i>文章标题</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
					<label class="layui-form-label"><i class="redrequired">*</i>上传主图</label>
沈姿.前端(已离职) committed
44
					<div class="layui-input-inline" style="width: 400px;">
45 46 47 48 49
						<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="">
50
								<input type="text" style="display:none;" name="imgurl" lay-verify="required">
51 52
							</div>
						</div>
沈姿.前端(已离职) committed
53
					</div>
zxt@theyeasy.com committed
54
				</div>
沈姿.前端(已离职) committed
55
				<div class="layui-form-item">
56 57 58
					<label class="layui-form-label"><i class="redrequired">*</i>文章内容</label>
					<div class="layui-input-block" style="margin-left: 130px;"> 
						<!-- 加载编辑器的容器 -->
沈姿.前端(已离职) committed
59
						<script id="container" name="content" type="text/plain">
60

沈姿.前端(已离职) committed
61 62
						</script>
					</div>
63
				</div>
沈姿.前端(已离职) committed
64 65 66 67 68 69 70
				<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>
71
			</div>
沈姿.前端(已离职) committed
72
		</body>
73

沈姿.前端(已离职) committed
74 75 76 77
		<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>
78
			window.onload = function() {
沈姿.前端(已离职) committed
79 80 81 82 83 84
				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);
85
					}
zxt@theyeasy.com committed
86
				}
沈姿.前端(已离职) committed
87 88 89 90 91
				window.UEDITOR_CONFIG.initialFrameWidth = 900;
				window.UEDITOR_CONFIG.initialFrameHeight = 600;
				var ue = UE.getEditor('container', {
					autoHeight: false
				});
92 93

			}
沈姿.前端(已离职) committed
94 95 96 97 98 99 100

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

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

103
				//初始化函数
沈姿.前端(已离职) committed
104
				function initData() {
105 106
					$.get("/zzhnc/article/getArticle", {
						id: id
沈姿.前端(已离职) committed
107
					}, function(data) {
108
						console.log(data);
沈姿.前端(已离职) committed
109
						if(data.code == 0) {
110 111 112 113 114 115 116
							$("[name=title]").val(data.data.title);
							UE.getEditor("container").ready(function() {
								UE.getEditor("container").setContent(unescape(data.data.content));
							})
							$("[name=imgurl]").val(data.data.imgurl);
							$(".mainpictrue").attr("src", data.data.imgurl).css("margin-top", "15px");
							form.render();
zxt@theyeasy.com committed
117
						}
沈姿.前端(已离职) committed
118
					})
zxt@theyeasy.com committed
119
				}
120

121 122 123
				//初始化操作
				if(id > 0) {
					initData()
zxt@theyeasy.com committed
124
				}
沈姿.前端(已离职) committed
125

126
				//上传操作
沈姿.前端(已离职) committed
127 128 129 130 131 132
				upload.render({
					elem: '#upload',
					url: '/zzhnc/upload/UploadImg',
					done: function(data) {
						console.log(data)
						if(data.code == 0) {
133 134
							$("[name=imgurl]").val(data.data.imgurl);
							$(".mainpictrue").attr("src", data.data.imgurl).css("margin-top", "15px");
沈姿.前端(已离职) committed
135
						} else {
136
							return layer.msg('上传失败');
zxt@theyeasy.com committed
137 138
						}
					}
沈姿.前端(已离职) committed
139
				});
140

沈姿.前端(已离职) committed
141
				//提交
142 143 144 145 146 147 148 149 150 151 152 153
				form.on('submit(submit)', function(data) {
					var title = $("[name=title]").val();
					var content = UE.getEditor('container').getContent();
					var imgurl = $("[name=imgurl]").val();
					if(title == "") {
						top.layer.msg("请填写文章标题");
						return false;
					} else {
						if(strlen(title) > 40) {
							top.layer.msg("文章标题不超过20个汉字");
							return false;
						}
154
					}
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
					if(imgurl == "") {
						top.layer.msg("请上传主图");
						return false;
					}
					if(content == "") {
						top.layer.msg("请输入内容");
						return false;
					}
					if(id > 0) {
						//修改项目
						$.post("/zzhnc/article/updateArticle", {
							id: id,
							title: title,
							content: content,
							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,
							content: content,
							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
193 194
					}
					return false;
195 196 197 198 199 200 201 202 203
				});

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

沈姿.前端(已离职) committed
206 207
			})
		</script>
zxt@theyeasy.com committed
208

209 210 211 212 213 214
		<!-- 配置文件 -->
		<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
215
</html>