<html lang="zh-cn">
|
|
<head>
|
<meta charset="utf-8">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<title>推荐-Banner</title>
|
<link href="css/bootstrap.min.css" rel="stylesheet">
|
<link href="css/maincontent.css" rel="stylesheet">
|
<style>
|
.search {
|
display: inline;
|
width: auto;
|
}
|
</style>
|
|
</head>
|
|
<body>
|
<nav class="navbar navbar-default navbar-fixed-top">
|
|
</nav>
|
<div id="mainbody">
|
<div id="sidebar">
|
|
</div>
|
<div id="neirong">
|
<div class="erjidh search-div" style="padding: 10px;">
|
|
<select name="select" class="form-control search select-detailsystem">
|
|
</select>
|
|
<div class="form-group search" role="search">
|
<input type="text" class="form-control search" id="kw" style="width: 200px;" placeholder="搜索">
|
</div>
|
<button type="button" class="btn btn-default search-button">搜索</button>
|
|
<div class="tianjia" class="search">
|
<a href="add-banner.html" class="btn btn-primary" role="button">添加内容 +</a>
|
</div>
|
|
</div>
|
<div class="bottom">
|
<div class="qx">
|
<div class="checkbox">
|
<label>
|
<input type="checkbox" class="check-all" value="#">
|
全选</label>
|
</div>
|
</div>
|
<button class="btn btn-warning pl-del" type="button">批量删除</button>
|
<div class="page">
|
<ul class="pagination">
|
<li class="disabled pre">
|
<a href="#">«</a>
|
</li>
|
<li class="active">
|
<a href="#">1</a>
|
</li>
|
<li>
|
<a href="#">2</a>
|
</li>
|
<li>
|
<a href="#" class="next">»</a>
|
</li>
|
</ul>
|
<div class="form-group">
|
<div class="tzan">
|
<button type="button" class="btn btn-primary">跳转</button>
|
</div>
|
<div class="tz">
|
<input class="form-control" type="text" placeholder="页数">
|
</div>
|
</div>
|
</div>
|
|
</div>
|
<div class="zhuti">
|
<div class="zhutisousuo">
|
<table class="table">
|
<thead>
|
<th width="7%">选择</th>
|
<th width="7%">编号</th>
|
<th width="20%">封面</th>
|
<th width="22%">APP名称</th>
|
<th width="15%">排序值</th>
|
<th width="15%">创建时间</th>
|
<th width="7%">删除</th>
|
<th width="7%">编辑</th>
|
</thead>
|
|
<tbody>
|
<tr style="display: none;">
|
<td>
|
<div class="xuanze">
|
<label>
|
<input type="checkbox" class="check-item"
|
value="#">
|
</label>
|
</div>
|
</td>
|
<td>
|
<div class="bianhao homeadid">623</div>
|
</td>
|
<td>
|
<div class="bianhao picture">
|
<img style="width: 200px;" />
|
</div>
|
</td>
|
|
<td class="apps">
|
|
</td>
|
<td style="text-align:center;line-height:105px;" class="orderby"></td>
|
<td style="text-align:center;line-height:105px;" class="createtime"></td>
|
<td>
|
<div class="anniu"><img src="image/dustbin.png" class="delete">
|
</div>
|
</td>
|
<td>
|
<div class="anniu">
|
<a key="370" href="javascript:void(0)" class="edit"><img src="image/bianji.png"></a>
|
</div>
|
</td>
|
</tr>
|
</tbody>
|
|
</table>
|
</div>
|
</div>
|
<div class="bottom">
|
<div class="qx">
|
<div class="checkbox">
|
<label>
|
<input type="checkbox" class="check-all" value="#">
|
全选</label>
|
</div>
|
</div>
|
<button class="btn btn-warning pl-del" type="button">批量删除</button>
|
<div class="page">
|
<ul class="pagination">
|
<li class="disabled pre">
|
<a href="#">«</a>
|
</li>
|
<li class="active">
|
<a href="#">1</a>
|
</li>
|
<li>
|
<a href="#">2</a>
|
</li>
|
<li>
|
<a href="#" class="next">»</a>
|
</li>
|
</ul>
|
<div class="form-group">
|
<div class="tzan">
|
<button type="button" class="btn btn-primary">跳转</button>
|
</div>
|
<div class="tz">
|
<input class="form-control" type="text" placeholder="页数">
|
</div>
|
</div>
|
</div>
|
|
</div>
|
</div>
|
<script src="//cdn.bootcss.com/jquery/1.10.1/jquery.min.js"></script>
|
<script src="js/bootstrap.min.js"></script>
|
<script src="js/page.js"></script>
|
<script src="js/nav.js"></script>
|
<script src="js/common.js"></script>
|
<script src="layer/layer.js"></script>
|
<script>
|
function getCommonTime(timestamp) {
|
var newDate = new Date();
|
newDate.setTime(timestamp);
|
return newDate.getFullYear() + "-" + (newDate.getMonth() + 1) + "-" + (newDate.getDay() + 1) + " " + newDate.getHours() + ":" + newDate.getMinutes();
|
}
|
|
$(function() {
|
var htmlSrc = "<tr>" + $(".zhuti .table tbody tr").eq(0).html() + "</tr>";
|
|
function getData(page) {
|
var index = layer.load(1, {
|
shade: false
|
})
|
$.post('../new/api/homebanner/gethomeadlistadmin', {
|
"page": page,
|
"detailsystem": $(".search-div .select-detailsystem").val(),
|
"key": $("#kw").val()
|
}, function(data) {
|
layer.close(index);
|
if(data.code != 0)
|
return;
|
|
fillPage(data.data.pageEntity, function(pageIndex) {
|
getData(pageIndex);
|
});
|
//填充数据
|
|
$(".zhuti .table tbody").empty();
|
for(var i = 0; i < data.data.data.length; i++) {
|
var da = data.data.data[i];
|
var appHtml = "";
|
da.detailSystemList.forEach(function(ds) {
|
console.log(ds.selected);
|
appHtml += "<div class='appname'><div class='checkbox'><label><input type='checkbox' value='" + ds.detailSystem.id + "' key='" + da.homeAd.id + "' " + (ds.selected == true ? "checked" : '') + ">";
|
appHtml += " " + ds.detailSystem.appName + "</label>";
|
appHtml += "</div></div>";
|
});
|
|
$(".zhuti .table tbody").append(htmlSrc);
|
var fk = $(".zhuti .table tbody tr").eq(i);
|
fk.find(".check-item").attr("key", da.homeAd.id);
|
fk.find(".homeadid").html(da.homeAd.id);
|
fk.find(".picture img").attr("src",da.homeAd.picture);
|
fk.find(".apps").html(appHtml);
|
fk.find(".orderby").html(da.homeAd.orderby);
|
fk.find(".createtime").html(getCommonTime(da.homeAd.createtime));
|
fk.find(".edit").attr("key", da.homeAd.id);
|
fk.find(".delete").attr("key", da.homeAd.id);
|
fk.css("display", "table-row");
|
fk.find(".apps").find(".appname input[type=checkbox]").bind("change", function() {
|
var detailsystemid = $(this).val();
|
var homeadid = $(this).attr("key");
|
if($(this).is(":checked")) {
|
$.post('../new/api/homebanner/addsuperhomead', {
|
'id': homeadid,
|
'detailsystem': detailsystemid
|
}, function(data) {
|
layer.msg(data.msg);
|
}, 'json');
|
} else {
|
$.post('../new/api/homebanner/deletesuperhomead', {
|
'id': homeadid,
|
'detailsystem': detailsystemid
|
}, function(data) {
|
layer.msg(data.msg);
|
}, 'json');
|
}
|
});
|
|
}
|
|
$(".table .anniu .delete").bind("click", function() {
|
var id = $(this).attr("key");
|
var $deleteElement = $(this);
|
var index = layer.confirm('是否删除该条目?', {
|
btn: ['是', '否'] //按钮
|
}, function() {
|
$.post('../new/api/homebanner/deletehomead', {
|
'ids': id
|
}, function(data) {
|
layer.msg(data.msg);
|
layer.close(index);
|
if(data.code == 0) {
|
$deleteElement.parent().parent().parent().remove();
|
}
|
}, 'json');
|
}, function() {
|
|
});
|
|
});
|
|
$(".table .anniu .edit").bind("click", function() {
|
window.location.href = "edit-banner.html?id=" + $(this).attr("key");
|
});
|
|
}, 'json');
|
}
|
|
$(".search-div .search-button").click(function() {
|
getData(1);
|
});
|
|
setTimeout(function() {
|
getData(1);
|
}, 2000);
|
|
});
|
</script>
|
|
<script>
|
$(function() {
|
function getCheckedItems() {
|
var ids = "";
|
for(var i = 0; i < $(".check-item").length; i++) {
|
if($(".check-item").eq(i).is(':checked')) {
|
ids += $(".check-item").eq(i).attr("key") + ",";
|
}
|
}
|
if(ids.length > 0)
|
ids = ids.substr(0, ids.length - 1);
|
return ids;
|
}
|
|
$(".pl-del").click(function() {
|
var ids = getCheckedItems();
|
if(ids.length < 1) {
|
layer.msg("请选择栏目");
|
return;
|
}
|
|
$.post('../new/api/homebanner/deletehomead', {
|
'ids': ids
|
}, function(data) {
|
layer.msg(data.msg);
|
if(data.code == 0) {
|
|
}
|
}, 'json');
|
|
});
|
|
});
|
</script>
|
</body>
|
|
</html>
|