审计记录

WebContent/WEB-INF/jsp/pc/banner/bannerList.jsp 3.2 KB
1 2 3 4 5 6 7 8
<%@ 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">
沈姿.前端(已离职) committed
9
		<title>内页广告位</title>
10 11
		<link rel="stylesheet" href="/zzhnc/res/plugins/layui/css/layui.css">
		<link rel="stylesheet" href="/zzhnc/res/css/basic.css">
12 13 14
		<style>
			.bannerShow .item {
				width: 300px;
沈姿.前端(已离职) committed
15
				height: auto;
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
				position: relative;
				display: inline-block;
				margin-right: 16px;
				margin-bottom: 16px;
			}
			
			.bannerShow .item img {
				width: 100%;
				height: 100%;
			}
			
			.bannerShow .item:hover #deleteBtn {
				display: inline-block;
			}
			
			.bannerShow .item #deleteBtn {
				position: absolute;
				right: -20px;
				top: -20px;
				font-size: 50px;
				color: red;
				display: none;
			}
		</style>
40 41 42
	</head>

	<body class="wrap">
沈姿.前端(已离职) committed
43 44
		<blockquote class="layui-elem-quote">说明:图片尺寸建议为:750*578</blockquote>
		<button class="layui-btn uploadImg"><i class="layui-icon">&#xe61f;</i> 上传图片</button>
45
		<fieldset class="layui-elem-field layui-field-title">
沈姿.前端(已离职) committed
46
			<legend>图片展示</legend>
47 48
		</fieldset>
		<div class="bannerShow">
沈姿.前端(已离职) committed
49

50
		</div>
沈姿.前端(已离职) committed
51
		<div class="nodata">暂无图片,请上传图片。</div>
52
	</body>
53
	<script src='/zzhnc/res/js/jquery.min.js'></script>
54 55
	<script src="/zzhnc/res/plugins/layui/layui.js"></script>
	<script src="/zzhnc/res/js/me.js"></script>
56
	<script>
57
		layui.use(['table', 'upload', 'layer'], function() {
58
			var table = layui.table,
59 60
				upload = layui.upload,
				layer = layui.layer;
61

沈姿.前端(已离职) committed
62 63 64
			//初始化数据
			function initData() {
				$.get("/zzhnc/banner/list", {
沈姿.前端(已离职) committed
65
					url: null
沈姿.前端(已离职) committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
				}, function(res) {
					console.log(res)
					if(res.code == 0) {
						if(res.data.length > 0) {
							$(".nodata").hide()
							$(".bannerShow").html("");
							var str = "";
							for(var i = 0; i < res.data.length; i++) {
								str += '<div class="item" >' +
									'<img src="' + res.data[i].imageUrl + '" />' +
									'<i class="layui-icon" data-id="' + res.data[i].id + '" id="deleteBtn">&#x1007;</i>' +
									'</div>';
							}
							$(".bannerShow").html(str);
						} else {
							$(".nodata").show()
						}

					}
				})
			}

			initData();

90 91 92 93 94 95
			//上传图片
			upload.render({
				url: '/zzhnc/upload/UploadImg',
				elem: '.uploadImg',
				method: 'post',
				done: function(res) {
96
					console.log(res)
97
					if(res.code == 0) {
沈姿.前端(已离职) committed
98
						$.post("/zzhnc/banner/add", {
99
							url: res.data.imgurl
沈姿.前端(已离职) committed
100
						}, function(res) {
101
							console.log(res)
沈姿.前端(已离职) committed
102
							if(res.code == 0) {
103
								layer.msg("添加成功")
沈姿.前端(已离职) committed
104
								initData()
105 106
							}else{
								layer.msg("添加失败")
107 108
							}
						})
109
					}
110 111
				}
			});
沈姿.前端(已离职) committed
112

113 114
			//删除banner图
			$(document).on("click", "#deleteBtn", function() {
115
				var id = $(this).data("id");
沈姿.前端(已离职) committed
116
				$.get("/zzhnc/banner/" + id + "/delete", "", function(res) {
117
					console.log(res)
沈姿.前端(已离职) committed
118 119 120 121 122
					if(res.code == 0) {
						layer.msg('删除成功!');
						initData()
					} else {
						layer.msg('删除失败!');
123 124
					}
				})
125
			})
126 127 128 129 130

		})
	</script>

</html>