import '../css/bootstrap.less'; import 'css/newMenu/public.css'; import 'css/newMenu/header.css' import 'css/search.css'; import '../css/video.css'; import './public.js'; $(function () { var pageSize = 10, thePageNo = 1, nutt = 0, videoHtml = '', name='', thePageLength = 1, noLength = `
`; init(); //获取参数 function getRequest() { var url = window.location.search; //获取url中"?"符后的字串 var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1), strs = str.split("&"); for (var i = 0; i < strs.length; i++) { theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]); } } return theRequest; }; function init() { if(getRequest().name){ name=unescape(getRequest().name); $('.demandSearch').val(name) }; pages(); inpFun(); loadDate(); search(); }; //当前页面搜 function search() { $('.searchBtn').click(function () { let val = $('.demandSearch').val(); name = val; thePageNo = 1; loadDate(); }) }; function loadDate(pageNo) { $('footer #bottom').show(); $.ajax({ method: "get", dataType: "json", url: globalConfig.context + "/portal/getVideoList", /// data: { pageNo: pageNo || 1, pageSize: 10, name: name, status: 1, transcoding:2 }, success: function (data) { if (data.error && data.error.length) { msg(data.error[0].message); } else if (data.data.list.length) { var contHtml = ""; contHtml += ''; $(".contImg").html(contHtml); } else { $(".contImg").html(noLength); return false; } //分页部分的处理 $('.pagination_box').css('display', 'block'); $('.inp').css('display', 'block'); if (data.data.list.length === 0) { $('.achievementHot .hotList').html("
"); $('.pagination_box').css('display', 'none') $('.inp').css('display', 'none'); }; thePageLength = data.data.totalCount ? Math.ceil(data.data.totalCount / pageSize) : 1; $('.totalCount').html(`共${data.data.totalCount}条数据 ${thePageLength}页`) var pageArr = [], firstNo = 1, endNo = 5; if (thePageNo > 3) { firstNo = thePageNo - 2; endNo = Math.min((Number(thePageNo) + 2), thePageLength); } else { endNo = Math.min(thePageLength, 5); }; for (let i = firstNo; i <= endNo; i++) { if (i == thePageNo) { pageArr.push( '
  • ' + i + '
  • ' ); } else { pageArr.push( '
  • ' + i + '
  • ' ); } }; $('.pageNumber').remove(); $('.pagePre').after(pageArr.join('')); jumpFun(); } }); } //标题点击事件 function jumpFun() { videoHtml = ''; $(".contImg ul li").on("click", function () { let loginTxt = $('.head_login')[0]; if (loginTxt && ($(loginTxt).text()) == '登录') { $('.head_login').click(); window.location.hash = 'jump'; return false; } nutt = $(this).index(); let urls = $(this).find('.videoId').val(); window.location.href=globalConfig.context+'/protal/videoDetail?id='+urls; //let urls = $(this).find('input').val(); // videoHtml = ``; // $('.videoPlay').show(100); // $('.videoPlay').addClass('active'); // $('#videoAt').html(videoHtml); // let videoNew = document.getElementById('videoAt'); // videoNew.load(); }) } videoCz(); //视频操作 function videoCz() { //关闭按钮 $('.videoTopM .glyphicon-remove').click(function () { let video = document.getElementById('videoAt'); $('.videoPlay').hide(100); $('.videoPlay').removeClass('active'); video.pause(); nutt=0; }); //点击上一个,下一个 $('.videoPre').click(function () { nutt-=1; if (nutt < 0) { msg('已经到第一个了.'); nutt = 0; return false; }; let video = document.getElementById('videoAt'); video.pause(); let urlT = $('.contImg ul li').eq(nutt).find('input').val(); videoHtml = ``; $('#videoAt').html(videoHtml); let videoNew = document.getElementById('videoAt'); videoNew.load(); }); $('.videoNext').click(function () { nutt+=1; if (nutt > $('.contImg ul li').length - 1) { nutt = $('.contImg ul li').length - 1; msg('已经到最后一个了.'); return false; } let video = document.getElementById('videoAt'); video.pause(); let urlT = $('.contImg ul li').eq(nutt).find('input').val(); videoHtml = ``; $('#videoAt').html(videoHtml); let videoNew = document.getElementById('videoAt'); videoNew.load(); }) } //f分页 function pages() { $('.pagination').on('click', 'li', function (e) { e.preventDefault(); if (this.className === 'pagePre') { if (thePageNo > 1) { thePageNo = 1; loadDate(thePageNo); } } else if (this.className === 'pageNext') { if (thePageNo < thePageLength) { thePageNo = thePageLength; loadDate(thePageNo); } } else { var nextPageNo = $(this).children()[0].text; if (thePageNo != nextPageNo) { $(this).siblings("li").removeClass("active"); $(this).addClass("active"); thePageNo = nextPageNo; loadDate(thePageNo); }; }; }); } //输入跳转 function inpFun() { $('.inp .btn').on('click', function () { let val = $(this).siblings().val(); if (!isNaN(val) && val <= thePageLength && val > 0) { thePageNo = val; loadDate(thePageNo); } else { msg('请输入正确页码') } }) } /* 提示 */ //提示框渐隐函数 function msg(txt) { if ($('.smg').hasClass('active')) { return; } $('.smg').addClass('active'); var lit = $('#msg').val(txt); setTimeout(function () { $('.smg').removeClass('active'); $('#msg').val(''); }, 2000) } //防止下载 $('#videoAt').hover(function(){ document.oncontextmenu=function(e){ return false } },function(){ document.oncontextmenu=function(e){ } }) })