<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">
|
<meta name="referrer" content="never">
|
<title>榜首管理</title>
|
<link href="css/bootstrap.min.css" rel="stylesheet">
|
<link href="css/maincontent.css" rel="stylesheet">
|
<style>
|
.search {
|
display: inline;
|
width: auto;
|
}
|
|
#hometype input[type=checkbox] {
|
height: 20px;
|
width: 20px;
|
}
|
|
#hometype ul li {
|
line-height: 30px;
|
}
|
|
#hometype ul li span {
|
height: 30px;
|
vertical-align: middle;
|
margin-left: 5px;
|
}
|
|
#hometype table td {
|
padding: 5px;
|
}
|
|
#special input[type=checkbox] {
|
height: 20px;
|
width: 20px;
|
}
|
|
#special ul li {
|
line-height: 30px;
|
}
|
|
#special ul li span {
|
height: 30px;
|
vertical-align: middle;
|
margin-left: 5px;
|
}
|
|
#special table td {
|
padding: 5px;
|
}
|
|
#hometype-sure {
|
padding: 20px;
|
display: none;
|
}
|
|
#hometype-sure span {
|
width: 100px;
|
text-align: right;
|
}
|
|
#hometype-sure input[type=text] {
|
width: 360px;
|
display: inline;
|
}
|
|
#hometype-sure div {
|
margin-bottom: 20px;
|
}
|
|
td>.center {
|
text-align: center !important;
|
line-height: 105px !important;
|
}
|
</style>
|
</head>
|
|
<body>
|
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
|
</nav>
|
<div id="mainbody">
|
<div id="sidebar">
|
<dl>
|
</dl>
|
</div>
|
<div id="neirong">
|
<div class="erjidh search-div" style="padding: 10px;">
|
|
<div class="search vt">
|
<select name="select" id="videotypes"
|
class="form-control roottype search">
|
|
</select>
|
|
</div>
|
|
</select>
|
<div class="form-group search" role="search">
|
<input type="text" class="form-control search" id="searchKey"
|
style="width: 200px;" placeholder="搜索">
|
</div>
|
<button type="button" class="btn btn-default search-button">搜索</button>
|
|
<div class="tianjia" class="search">
|
<a href="fenqu.html" class="btn btn-primary" role="button">添加 +</a>
|
</div>
|
</div>
|
<div class="zhuti">
|
<div class="liebiao">
|
<table class="table">
|
<thead>
|
<th>选择</th>
|
<th>编号</th>
|
<th>名称</th>
|
<th>类型</th>
|
<th>权重</th>
|
<th>位置</th>
|
<th>创建时间</th>
|
<th>删除</th>
|
<th>编辑</th>
|
</thead>
|
<tbody>
|
<tr>
|
<td>
|
<div class="xuanze">
|
<label> <input type="checkbox" class="check-item"
|
value="#">
|
</label>
|
</div>
|
</td>
|
<td>
|
<div class="bianhao"></div>
|
</td>
|
<td>
|
<div class="center mc"></div>
|
</td>
|
<td>
|
<div class="center lx"></div>
|
</td>
|
<td>
|
<div class="center qz"></div>
|
</td>
|
<td>
|
<div class="center wz"></div>
|
</td>
|
<td>
|
<div class="center createtime"></div>
|
</td>
|
<td>
|
<div class="anniu delete">
|
<img src="image/dustbin.png">
|
</div>
|
</td>
|
<td>
|
<div class="anniu">
|
<a 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><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>
|
</div>
|
|
|
<div id="dialog-chooselink" style="display: none;">
|
<div class="row" style="height: 690px;">
|
<div class="col-lg-3 col-md-3" style="display: inline;">
|
<select class="form-control addType">
|
|
</select>
|
</div>
|
|
<div class="col-lg-9 col-md-9" style="display: inline;">
|
<!--视频选择 -->
|
<div id="container-video">
|
<div class="search">
|
<input type="text" class="form-control" placeholder="请输入关键字"
|
style="width: 200px; display: inline;" />
|
<button class="btn btn-info">搜索</button>
|
</div>
|
<!-- 搜索结果展示区域-->
|
<div class="search-result">
|
<table class="table">
|
<thead>
|
<th>编号</th>
|
<th>名称</th>
|
<th>封面</th>
|
<th>是否显示</th>
|
<th>选择</th>
|
</thead>
|
<tbody>
|
</tbody>
|
</table>
|
</div>
|
</div>
|
</div>
|
</div>
|
<div style="float: right;">
|
<button class="btn btn-info sure">确定</button>
|
<button class="btn btn-default cancel">取消</button>
|
</div>
|
|
</div>
|
|
<script src="js/jquery-1.9.1.min.js"></script>
|
<script src="js/bootstrap.min.js"></script>
|
<script src="js/page.js"></script>
|
<script src="js/nav.js"></script>
|
<script src="layer/layer.js"></script>
|
<script>
|
var trHtml;
|
$(function() {
|
|
trHtml = $(".liebiao tbody").html();
|
$(".liebiao tbody").empty();
|
getVideoType(0, undefined);
|
|
$(".search-button").bind("click", function() {
|
getTopData(1);
|
});
|
|
$(".check-all").bind("click", function() {
|
$(".check-item").prop("checked", this.checked);
|
})
|
|
$(".pl-del").bind("click", function() {
|
|
layer.confirm('是否删除?', {
|
btn : [ '否', '是' ]
|
}, function(index) {
|
layer.close(index);
|
return false;
|
}, function() {
|
var arr = new Array();
|
$(".check-item:checked").each(function() {
|
var cid = $(this).attr("key");
|
arr.push(cid);
|
});
|
if (arr.length == 0) {
|
layer.msg("请先选中数据!");
|
return;
|
}
|
deleteTops(arr);
|
});
|
|
});
|
|
// $(".add").click(function() {
|
// addIndex = layer.open({
|
// type: 1,
|
// title: '链接选择',
|
// shadeClose: true,
|
// shade: 0.8,
|
// area: ['1200px', '800px'],
|
// content: $("#dialog-chooselink")
|
// });
|
// });
|
//
|
// $("#dialog-chooselink .cancel").click(function() {
|
// layer.close(addIndex);
|
// });
|
//
|
// $("#container-juhe .search button").click(function() {
|
// var key = $("#container-juhe .search input").val();
|
// var index = layer.load(0, {
|
// 'shade': false
|
// });
|
// $.post('api/common/searchvideo', {
|
// 'key': key
|
// }, function(data) {
|
// layer.close(index);
|
// if(data.code == 0) {
|
// $(".search-result table tbody").empty();
|
// var html = "";
|
// data.data.forEach(function(juhe) {
|
// html += "<tr><td>" + juhe.id;
|
// html += "</td><td>" + juhe.name + "</td><td><img style='width: 80px;' src=" + juhe.picture + "> </td><td>" + (juhe.show == 1 ? '显示' : '不显示') + "</td>";
|
// html += "<td><input type='checkbox' name='choose-juhe' key=" + juhe.id + " value='"+juhe.name+"'></td></tr>";
|
// });
|
// $(".search-result table tbody").html(html);
|
// }
|
//
|
// }, 'json');
|
// });
|
//
|
// $("#dialog-chooselink .sure").click(function() {
|
// alert("1");
|
// });
|
|
});
|
|
function getTopData(page) {
|
var index = layer.load(1, {
|
shade : false
|
});
|
var videotype = $("#videotypes option:selected").val();
|
var key = $("#searchKey").val();
|
$.post("api/top/getTopList", {
|
"videotype" : videotype,
|
"page" : page,
|
"pageSize" : 20,
|
"key" : key
|
}, function(data) {
|
if (data.code == 0) {
|
setTopData(data.data.list);
|
fillPage(data.data.pe, function(page) {
|
window.location.href = "topManage.html?page=" + page+"&type="+$(".vt .roottype").val();
|
});
|
}
|
layer.close(index);
|
}, 'json')
|
|
}
|
|
function getQueryString(name) {
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
var reg_rewrite = new RegExp("(^|/)" + name + "/([^/]*)(/|$)", "i");
|
var r = window.location.search.substr(1).match(reg);
|
var q = window.location.pathname.substr(1).match(reg_rewrite);
|
if (r != null) {
|
return unescape(r[2]);
|
} else if (q != null) {
|
return unescape(q[2]);
|
} else {
|
return null;
|
}
|
}
|
|
function getVideoType(pid, $parentselectitem) {
|
$
|
.post(
|
'api/class/getnextclass',
|
{
|
"pid" : pid
|
},
|
function(data) {
|
if (data.data.length > 0) {
|
if ($parentselectitem == undefined) { //第一级
|
$(".vt .roottype").empty();
|
$(".vt .roottype")
|
.append(
|
"<option value='0'>全部</option>");
|
for (var i = 0; i < data.data.length; i++) {
|
$(".vt .roottype").append(
|
"<option value='" + data.data[i].id + "'>"
|
+ data.data[i].name
|
+ "</option>");
|
$(".addType").append(
|
"<option value='" + data.data[i].id + "'>"
|
+ data.data[i].name
|
+ "</option>");
|
}
|
//获取当前页码
|
var page = getQueryString("page");
|
if (page == null || page == undefined
|
|| page == '')
|
page = 1;
|
var type = getQueryString("type");
|
if (type == null || type == undefined
|
|| type == '')
|
type = 0;
|
for (var i = 0; i < $(".vt .roottype option").length; i++) {
|
if ($(".vt .roottype option").eq(i)
|
.val() == type)
|
$(".vt .roottype option").eq(i)
|
.attr("selected", true);
|
}
|
|
getTopData(page);
|
}
|
}
|
|
}, 'json');
|
}
|
|
function setTopData(list) {
|
$(".liebiao tbody").empty();
|
for (var i = 0; i < list.length; i++) {
|
$(".liebiao tbody").append(trHtml);
|
var $curTr = $(".liebiao tbody tr").eq(i);
|
var cid = list[i].id;
|
var createtime = list[i].createtime;
|
var name = list[i].videoInfo.name;
|
var orderby = list[i].orderby;
|
var type = list[i].videoType.name;
|
var rank = list[i].rank;
|
$curTr.find(".xuanze .check-item").attr("key", cid);
|
$curTr.find(".bianhao").text(cid);
|
$curTr.find(".mc").text(name);
|
$curTr.find(".lx").text(type);
|
$curTr.find(".qz").text(orderby);
|
$curTr.find(".wz").text(rank);
|
$curTr.find(".createtime").text(getCommonTime(createtime));
|
$curTr.find(".edit").attr("href", "edit-top.html?key=" + cid);
|
$curTr.find(".delete").attr("key", cid);
|
}
|
|
$(".liebiao tbody tr .delete").bind("click", function() {
|
var $obj = $(this);
|
layer.confirm('是否删除?', {
|
btn : [ '否', '是' ]
|
}, function(index) {
|
layer.close(index);
|
return false;
|
}, function() {
|
var arr = new Array();
|
var cid = $obj.attr("key");
|
arr.push(cid);
|
deleteTops(arr);
|
});
|
});
|
|
}
|
|
function getCommonTime(timestamp) {
|
var newDate = new Date();
|
newDate.setTime(timestamp);
|
return newDate.getFullYear() + "-" + (newDate.getMonth() + 1) + "-"
|
+ (newDate.getDate()) + " " + newDate.getHours() + ":"
|
+ newDate.getMinutes();
|
}
|
|
function deleteTops(arr) {
|
$.ajax({
|
url : "api/top/deleteTop",
|
type : "POST",
|
traditional : true,
|
data : {
|
"ids" : arr
|
},
|
dataType : "json",
|
success : function(data) {
|
if (data.code == 0) {
|
alert("删除成功");
|
getTopData(1);
|
}
|
},
|
error : function() {
|
alert("删除失败");
|
}
|
});
|
}
|
</script>
|
</body>
|
|
</html>
|