$(function () { initOther(); initDetail(); }); /** * 初始化其他操作 */ function initOther() { $(".commentdiv").eq(1).css("display", "none"); $(".imgdiv").eq(1).css("display", "none"); $("#commentul").find("a").click(function () { $("#commentul").find("a").parent().removeClass("active") $(this).parent().addClass("active"); $(".commentdiv").css("display", "none"); var datadiv = $(this).attr("data-div"); $("#".concat(datadiv)).parents(".commentdiv").css("display", "block"); }); $("#imgtul").find("a").click(function () { $("#imgtul").find("a").parent().removeClass("active") $(this).parent().addClass("active"); $(".imgdiv").css("display", "none"); var datadiv = $(this).attr("data-div"); $("#".concat(datadiv)).css("display", "block"); }); } function initWaterfall(imgTitle) { $('#sample-waterfall-gf').magnificPopup({ delegate: 'a', type: 'image', closeOnContentClick: false, closeBtnInside: false, mainClass: 'mfp-with-zoom mfp-img-mobile', image: { verticalFit: true, titleSrc: function (item) { return imgTitle + "" + item.src.substring(item.src.lastIndexOf("/") + 1); } }, gallery: { enabled: true }, zoom: { enabled: true, duration: 300, opener: function (element) { return element.find('img'); } } }); $('#sample-waterfall-sy').magnificPopup({ delegate: 'a', type: 'image', closeOnContentClick: false, closeBtnInside: false, mainClass: 'mfp-with-zoom mfp-img-mobile', image: { verticalFit: true, titleSrc: function (item) { return item.src.substring(item.src.lastIndexOf("/") + 1); } }, gallery: { enabled: true }, zoom: { enabled: true, duration: 300, opener: function (element) { return element.find('img'); } } }); } function getUrlParam(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } /** * 初始化详情 * @param pageNo */ function initDetail() { var type = getUrlParam('type'); var code = getUrlParam('code'); if ('qibing' == type) { $("#videoType").text('骑兵'); } else if ('bubing' == type) { $("#videoType").text('步兵'); } else if ('liuchu' == type) { $("#videoType").text('流出'); } else if ('machi' == type) { $("#videoType").text('码池'); } $.ajax({ url: "videoDetail/getVideoInfoDetail", //请求的url地址 dataType: "json", //返回格式为json data: {"type": type, "code": code}, //参数值 type: "post", //请求方式 async: true, //请求是否异步,默认为异步,这也是ajax重要特性 success: function (data) { //请求成功时处理 if (data != null && $.trim(data) != "" && data.success) { data = data.data; // score var score = data.score; $("#scorespan").text(score); if (score == 0) { $("#ratewords").text("暂无评分") } else { var count; if (score >= 5) { count = 5; } else if (score >= 4) { count = 4; } else if (score >= 3) { count = 3; } else if (score >= 2) { count = 2; } else if (score >= 1) { count = 1; } else { count = 1; } var scoreli = $("ul.rating").find("li:lt(" + count + ")").children("i"); $(scoreli).removeClass("fa-star-o"); $(scoreli).addClass("fa-star"); $("#ratewords").text($("ul.rating").find("li").eq(count - 1).attr("title")); } $("#videoInfoCover").attr("src", "apics/".concat(data.imgUrl)); $("#videoName").text(data.name); $("#identificationCode").text(data.identificationCode); $("#issueDate").text(data.issueDate); $("#length").text(data.length); $("#director").text(data.director); $("#maker").text(data.maker); $("#issuer").text(data.issuer); if (data.genres == undefined || data.genres === '') { $("#genres").html('--'); } else { $("#genres").html(data.genres.replaceAll(",", "   ")); } if (data.cast == undefined || data.cast === '') { $("#cast").html('--'); } else { $("#cast").html(data.cast.replaceAll(",", "   ")); } $("#commentfirstspan").html(data.commentFirst); $("#commentspan").html(data.comment); var imgTitle = data.identificationCode + " " + data.name; if (data.imgGFList.length > 0) { var imgGFList = data.imgGFList; var str = ""; for (var i = 0; i < imgGFList.length; i++) { var imgGF = imgGFList[i]; str += '' + '
' + '' + '
'; } $("#sample-waterfall-gf").html(str); } if (data.imgSYList.length > 0) { var imgSYList = data.imgSYList; var str = ""; for (var i = 0; i < imgSYList.length; i++) { var imgSY = imgSYList[i]; str += '' + '
' + '' + '
'; } $("#sample-waterfall-sy").html(str); } initWaterfall(imgTitle); console.log(data); $("#cover").css("display", "none"); show(); } else { alert(data.message); } }, beforeSend: function () { //请求前的处理 $("#cover").css("display", "block"); }, complete: function () { // $("#cover").css("display", "none"); // show(); }, error: function (data) { //请求出错处理 alert('error:' + data); } }); } function show() { var my = $("#my,.myui-foot"); $.each(my, function (index, value) { if (value.className.indexOf("dynamic_hide") > -1) { value.classList.remove("dynamic_hide"); } else { value.classList.add("dynamic_hide"); } }); }