$(function () {
initOther();
initSearch();
});
function initOther() {
$(".slideDown-btn").click(function () {
var display = $('.slideDown-box');
if (display.css('display') == 'block') {
display.slideUp("slow");
$(this).html('展开 ');
} else {
display.slideDown("slow");
$(this).html('收起 ');
}
});
$("#searchbutton").click(function () {
search(1);
});
$("#shaixuan").click(function () {
$("#wd").val("");
search(1);
});
$("#wd").keydown(function (e) {
if (e.keyCode == 13) {
search(1);
}
});
$(".dropdown-box").find("li").click(function () {
$("#bigType").text($(this).text());
$(".dropdown-box").attr("style", "display: none;");
getQueryHeaderInfo($("#bigType").text(), false);
});
$(".dropdown-hover").mouseover(function () {
$(".dropdown-box").attr("style", "display: block;");
});
$(".dropdown-hover").mouseout(function () {
$(".dropdown-box").attr("style", "display: none;");
});
$(".clearAll").click(function () {
$("#playvideo").find("video").attr("src", "");
$("#bigpreview").find("img").attr("src", "");
$("#playvideo").css("display", "none");
$("#bigpreview").css("display", "none");
});
}
/**
* 初始化搜索
*/
function initSearch() {
var orderField = $(".paixuul").find(".btn-warm").attr("orderField");
var order = $(".paixuul").find(".btn-warm").attr("order");
var bigType = $("#bigType").text();
$.ajax({
url: "videoInfo/getVideoInfoPage", //请求的url地址
dataType: "json", //返回格式为json
data: JSON.stringify({
"pageNo": 1,
"pageSize": 10,
"orderField": orderField,
"order": order,
"bigType": bigType
}), //参数值
type: "post", //请求方式
async: true, //请求是否异步,默认为异步,这也是ajax重要特性
contentType: "application/json;charset=utf-8",
success: function (data) {
//请求成功时处理
if (data != null && $.trim(data) != "" && data.success) {
getQueryHeaderInfo($("#bigType").text(), true);
data = data.data;
var videoInfoList = data.list;
var str = "";
if (data.size > 0) {
for (var i = 0; i < videoInfoList.length; i++) {
var videoInfo = videoInfoList[i];
str += "
" +
" " +
"";
}
$(".myui-vodlist").html(str);
$(".myui-page").pagination({
pageSize: "10",
pageNo: "1",
total: data.total,
callback: function (pageNo) {
$("#wd").val("");
search(pageNo);
}
});
initContentEvent();
}
} else {
alert(data.message);
}
},
beforeSend: function () {
//请求前的处理
$("#cover").css('display', 'block');
},
complete: function () {
//请求完成的处理
$("#cover").css('display', 'none');
},
error: function (data) {
//请求出错处理
alert('error:' + data);
}
});
}
/**
* 多条件搜索
* @param pageNo
*/
function search(pageNo) {
var genres = $(".leixingul").find(".btn-warm").text().replace("全部", "");
var cast = $(".yanyuanul").find(".btn-warm").text().replace("全部", "");
var orderField = $(".paixuul").find(".btn-warm").attr("orderField");
var order = $(".paixuul").find(".btn-warm").attr("order");
var keyword = $("#wd").val();
var bigType = $("#bigType").text();
$.ajax({
url: "videoInfo/getVideoInfoPage", //请求的url地址
dataType: "json", //返回格式为json
data: JSON.stringify({
"pageNo": pageNo,
"pageSize": 10,
"genres": genres,
"cast": cast,
"orderField": orderField,
"order": order,
"keyword": keyword,
"bigType": bigType
}), //参数值
type: "post", //请求方式
contentType: "application/json;charset=utf-8",
async: true, //请求是否异步,默认为异步,这也是ajax重要特性
success: function (data) {
//请求成功时处理
if (data != null && $.trim(data) != "" && data.success) {
data = data.data;
var videoInfoList = data.list;
var str = "";
for (var i = 0; i < videoInfoList.length; i++) {
var videoInfo = videoInfoList[i];
var date = videoInfo.issueDate;
if (orderField == 'vi.modify_time') {
date = videoInfo.modifyTime;
}
str += "" +
" " +
"";
}
$(".myui-vodlist").html(str);
if (str == "") {
$(".vodlistnone").attr("style", "padding: 50px;display: block;");
} else {
$(".vodlistnone").attr("style", "padding: 50px;display: none;");
}
$(".myui-page").pagination({
pageSize: "10",
pageNo: pageNo,
total: data.total,
callback: function (pageNo) {
$("#wd").val("");
search(pageNo);
}
});
initContentEvent();
} else {
alert(data.message);
}
},
beforeSend: function () {
//请求前的处理
$(".loading").css("display", "block");
},
complete: function () {
//请求完成的处理
$(".loading").css("display", "none");
},
error: function (data) {
//请求出错处理
alert('error:' + data);
}
});
}
/**
* 查询头信息
* @param bigType
* @param startFlag
*/
function getQueryHeaderInfo(bigType, startFlag) {
$.ajax({
url: "queryHeader/getQueryHeaderInfo", //请求的url地址
dataType: "json", //返回格式为json
data: {"bigType": bigType}, //参数值
type: "post", //请求方式
async: false, //请求是否异步,默认为异步,这也是ajax重要特性
success: function (data) {
//请求成功时处理
if (data != null && $.trim(data.data) != "" && data.success) {
data = data.data;
if ($.isEmptyObject(data)) {
$("#leixingdiv").html("");
$("#yanyuandiv").html("");
$(".vodlistnone").attr("style", "padding: 50px;display: block;");
$(".myui-vodlist").html("");
return;
}
if (data.videoCastList.length > 0) {
var videoCastList = data.videoCastList;
var str = "";
for (var i = 0; i < videoCastList.length; i++) {
var videoCast = videoCastList[i];
str += "" + videoCast.name + "";
}
$("#yanyuandiv").append(str);
}
if (data.videoGenresList.length > 0) {
var videoGenresList = data.videoGenresList;
var str = "";
for (var i = 0; i < videoGenresList.length; i++) {
var videoGenres = videoGenresList[i];
str += "" + videoGenres.name + "";
}
$("#leixingdiv").append(str);
}
if (!startFlag) {
search(1);
}
$(".searchbtn").click(function () {
$(this).closest('ul').find(".searchbtn").removeClass("btn-warm");
$(this).addClass("btn-warm");
if ($(this).attr('order') != undefined) {
var order = $(this).attr('order');
if ("desc" == order) {
$(this).attr("order", "asc");
} else if ("asc" == order) {
$(this).attr("order", "desc");
}
}
$("#wd").val("");
search(1);
});
} else {
alert(data.message);
}
},
beforeSend: function () {
//请求前的处理
},
complete: function () {
//请求完成的处理
},
error: function (data) {
//请求出错处理
alert('error:' + data);
}
});
}
/**
* 初始化主内容事件
*/
function initContentEvent() {
$(".playvideo").dblclick(function () {
if ($("#playvideo").css("display") === 'none') {
$("#playvideo").css("display", "block");
$("#playvideo").find("video").attr("src", "qibing/" + $(this).attr("videoUrl"));
$("#playvideo").find("video").prop('muted', true);
} else if ($("#playvideo").css("display") === 'block') {
$("#playvideo").css("display", "none");
$("#playvideo").find("video").attr("src", "");
}
});
$(".bigpreview").dblclick(function () {
if ($("#bigpreview").css("display") === 'none') {
$("#bigpreview").css("display", "block");
$("#bigpreview").find("img").attr("src", "qibing/" + $(this).attr("imgUrl"));
} else if ($("#bigpreview").css("display") === 'block') {
$("#bigpreview").css("display", "none");
$("#bigpreview").find("img").attr("src", "");
}
});
$(".identificationCode").dblclick(function () {
window.open("https://www.javbus.com/" + $(this).text(), "_blank");
});
}