审计记录

WebContent/WEB-INF/jsp/pc/poster/poster.jsp 11.5 KB
zxt@theyeasy.com committed
1 2 3 4 5 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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 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 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 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 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
<%@ 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>

	<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="http://at.alicdn.com/t/font_9lmlt21w1lv26gvi.css">
		<link rel="stylesheet" href="/zzhnc/res/css/basic.css">
		<style>
			.layui-form-label {
				width: 100px !important;
			}

			.layui-input-block {
				margin-left: 130px !important;
			}

			.layui-input-block,
			.layui-input-inline {
				width: 140px !important;
			}

			.layui-input-inline input {
				padding: 0 5px;
			}

			body {
				margin: 0;
				padding: 0;
				-moz-user-select: none;
				/*鐏嫄*/
				-webkit-user-select: none;
				/*webkit娴忚鍣�*/
				-ms-user-select: none;
				/*IE10*/
				-khtml-user-select: none;
				/*鏃╂湡娴忚鍣�*/
				user-select: none;
			}
		</style>
	</head>

	<body style="min-width:1070px;">
		<div class="hint">提示:上传海报后,拖拽拉伸左边海报上的二维码设置二维码在海报上的位置和大小,建议二维码宽高不小于120px,以免无法识别。</div>
		<div style="margin-bottom:20px;overflow:hidden;">
			<div class="haibaofl">
				<div class="haibao-box">
					<!-- <img src="/zzhnc/res/images/pg_top.jpg" class="ph_top"/>  -->
					<div class="haibao-viewbox">
						<div class="haibao-view">
							<img src="/zzhnc/res/images/moren.jpg" alt="">
							<div id="box" class="box">
								<div id="coor" class="coor">
									<span class="iconfont icon-suofang"></span>
								</div>
							</div>
						</div>
					</div>
					<!--  <img src="/zzhnc/res/images/pg_bottom.jpg" class="ph_ft"/>  -->
				</div>
			</div>
			<div class="haibaofr" style="margin-top:40px;">
				<div class="layui-form">
					<div class="layui-form-item">
						<label class="layui-form-label">
							<i style="color:red;margin-right:5px;">*</i>海报名称</label>
						<div class="layui-input-inline">
							<input type="text" name="name" lay-verify="name" placeholder="" autocomplete="off" 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">
							<select name="posttype">
								<option value="0">请选择</option>
								<option value="1">项目海报</option>
								<option value="2">销售助手首页</option>
								<option value="3">万小二首页</option>
							</select>
						</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">
							<input type="text" name="imgurl" placeholder="请上传一张海报" class="layui-input" style="display:none;">
						</div>
						<div id="upload" style="display:inline-block;">
							<span class="layui-btn" style="float:left;margin-right:10px;"> 上传海报</span>
						</div>

						<div class="layui-form-mid layui-word-aux" style="margin-left:130px;">海报宽度应不小于640px,以免海报显示不清晰</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">
							<input type="text" readonly name="width" placeholder="宽度" autocomplete="off" class="layui-input" value="120" style="background-color:#f5f5f5;color:#666;">
						</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">
							<input type="text" readonly name="height" placeholder="高度" autocomplete="off" class="layui-input" value="120" style="background-color:#f5f5f5;color:#666;">
						</div>

					</div>
					<div class="layui-form-item" style="margin-bottom:0;">
						<label class="layui-form-label">
							<i style="color:red;margin-right:5px;">*</i>二维码位置</label>
						<div class="layui-input-block">
							<input type="text" readonly name="x" placeholder="X坐标" autocomplete="off" class="layui-input" style="margin-bottom:15px;background-color:#f5f5f5;color:#666;"
							 value="0">
							<input type="text" readonly name="y" placeholder="Y坐标" autocomplete="off" class="layui-input" style="margin-bottom:15px;background-color:#f5f5f5;color:#666;"
							 value="0">
						</div>
					</div>




					<div class="layui-form-item" style="margin-left:130px;">
						<button class="layui-btn submit">提交</button>
						<button class="layui-btn layui-btn-primary resetBtn">重置</button>
					</div>
				</div>
			</div>
		</div>

		<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>
			var imgurl = "";
			var height = window.parent.height || 120
			var width = window.parent.width || 120
			var x = window.parent.x || 0
			var y = window.parent.y || 0
			$("#box").css({ "width": width, "height": height, "top": y, "left": x })
			$(".haibao-view img").attr("src", $("input[name=postertemplet]", window.parent.document).val() || "/zzhnc/res/images/moren.jpg")

			$(function () {
				$(document).mousemove(function (e) {

					if (!!this.move) {

						var posix = !document.move_target ? { 'x': 0, 'y': 0 } : document.move_target.posix

						var callback = document.call_down || function () {

							if (this.move_target.id == "box") {
								e.pageX = e.pageX - 10
								e.pageY = e.pageY - 50
								y = Math.max(e.pageY - posix.y, 0)
								y = Math.min(y, $(".haibao-view").height() - height)
								x = Math.max(e.pageX - posix.x, 0)
								x = Math.min(x, $(".haibao-view").width() - width)

								$("#box").css({
									'top': y,
									'left': x
								});

								$("input[name=x]").val(decimal(x, 0));
								$("input[name=y]").val(decimal(y, 0));
							}

						};

						callback.call(this, e, posix);
					}
				}).mouseup(function (e) {

					if (!!this.move) {
						var callback = document.call_up || function () { };
						callback.call(this, e);
						$.extend(this, {
							'move': false,
							'move_target': null,
							'call_down': false,
							'call_up': false
						});
					}

				});

				var $box = $('#box').mousedown(function (e) {
					var offset = $(this).offset();

					this.posix = { 'x': e.pageX - offset.left, 'y': e.pageY - offset.top };

					$.extend(document, { 'move': true, 'move_target': this });

				}).on('mousedown', '#coor', function (e) {
					var posix = {
						'w': $box.width(),
						'h': $box.height(),
						'x': e.pageX,
						'y': e.pageY
					};

					$.extend(document, {
						'move': true, 'call_down': function (e) {
							width = Math.max(30, e.pageX - posix.x + posix.w)
							width = Math.min(width, $(".haibao-view").width() - x)
							height = Math.max(30, e.pageY - posix.y + posix.h)
							height = Math.min(height, $(".haibao-view").height() - y)

							height = Math.min(width, height)
							width = Math.min(width, height)
							$box.css({
								'width': width,
								'height': height
							});
							$("input[name=width]").val(decimal(width, 0));
							$("input[name=height]").val(decimal(height, 0));
						}

					});

					return false;
				});


			});
			layui.use(['form', 'element', 'laydate', 'layer', 'laypage', 'upload'], function () {
				var form = layui.form(),
					element = layui.element(),
					laydate = layui.laydate,
					layer = layui.layer,
					laypage = layui.laypage;
				var $ = layui.jquery
					, upload = layui.upload;
				var id = getUrl_G("id");
				if (id > 0) {
					$.post("/zzhnc/poster/getPoster", { id: id }, function (data) {
						$("input[name=name]").val(data.data.name);
						$("select[name=posttype]").val(data.data.postertype);
						height = data.data.height
						width = data.data.width
						x = data.data.x
						y = data.data.y
						$("input[name=width]").val(width);
						$("input[name=height]").val(height);
						$("input[name=x]").val(x);
						$("input[name=y]").val(y);
						$("input[name=imgurl]").val(data.data.imgurl);
						$(".haibao-view img").attr("src", data.data.imgurl);
						$("#box").css({ "width": data.data.width, "height": data.data.height, "top": data.data.y, "left": data.data.x })
						form.render();
					})
				}
				//普通图片上传
				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);
							$(".haibao-view img").attr("src", imgurl);

						}

						//如果上传失败
						if (data.code > 0) {
							return layer.msg('上传失败');
						}
						//上传成功
					}

				});

				$(".resetBtn").on("click", function () {
					$("input[name=name]").val("");
					$("select[name=posttype]").val("");
					form.render();
				})
				//提交
				$(".submit").on("click", function () {
					var x = $("input[name=x]").val();
					var y = $("input[name=y]").val();
					var width = $("input[name=width]").val();
					var height = $("input[name=height]").val();
					var name = $("input[name=name]").val();
					var posttype = $("select[name=posttype]").val();
					var imgurl = $("input[name=imgurl]").val();
					if (name == "") {
						top.layer.msg("请填写海报名称");
						return false;
					} else {
						if (strlen(name) > 40) {
							top.layer.msg("海报名称不超过20个汉字");
							return false;
						}
					}
					//表单验证

					if (posttype == "" || posttype == "0") {
						top.layer.msg("请选择海报类别");
						return false;
					}
					if (imgurl == "") {
						top.layer.msg("请上传海报");
						return false;
					}
					if (id > 0) {
						$.post("/zzhnc/poster/updatetemplet", {
							id: id,
							name: name,
							posttype: posttype,
							imgurl: imgurl,
							x: x,
							y: y,
							width: width,
							height: height
						}, function (data) {
							console.log(data);
							if (data.code == 0) {
								top.layer.msg("修改成功");
								$.post("/zzhnc/wxmini/cleanProgramMedia?code=nmdzpsmhs", function(res){
									console.log(res);
								})
							}
						})
					} else {
						$.post("/zzhnc/poster/addtemplet", {
							name: name,
							posttype: posttype,
							imgurl: imgurl,
							x: x,
							y: y,
							width: width,
							height: height
						}, function (data) {
							console.log(data);
							if (data.code == 0) {
								top.layer.msg("添加成功");
								$.post("/zzhnc/wxmini/cleanProgramMedia?code=nmdzpsmhs", function(res){
									console.log(res);
								})
							}
						})
					}


				})
				/*  $(".returnBtn").on("click",function(){
					 if(parent.tab.exists("海报模板")>0){
						 var tabid=parent.tab.getTabId("海报模板");
						 parent.tab.deleteTab(tabid);
					 }
					 parent.tab.tabAdd({
						 href: "/zzhnc/poster/posterlist",
						 icon: "fa-cubes",
						 title: "海报模板" 
					 });
				 }) */


			});
			//对数字进行四舍五入
			function decimal(num, v) {
				var vv = Math.pow(10, v);
				return Math.round(num * vv) / vv;
			}



		</script>
	</body>



	</html>