123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- 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 = `<div class="noLength"></div>`;
- 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 += '<ul>'
- var dataList = data.data.list;
- if (dataList.length) {
- dataList.map(item => {
- contHtml += `<li>
- <div>
- <img src="${globalConfig.avatarHost}/upload${item.coverUrl}" alt="">
- <div class="videoImg">
- <span></span>
- </div>
- <input type="hidden" value="${item.url||''}">
- <input type="hidden" class='videoId' value="${item.id||''}">
- </div>
- <div class="txt">
- <h3>${item.name}</h3>
- <p>${item.summary}</p>
- </div>
- </li>`
- })
- }
- contHtml += '</ul>';
- $(".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("<div class='list_none'></div>");
- $('.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(
- '<li class="pageNumber active"><a href="#" value=' + i + ' >' + i + '</a></li>'
- );
- } else {
- pageArr.push(
- '<li class="pageNumber"><a href="#" value=' + i + ' >' + i + '</a></li>'
- );
- }
- };
- $('.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 = `<source src="http://118.190.205.7:8000${urls}" type="video/mp4">`;
- // $('.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 = `<source src="http://118.190.205.7:8000${urlT}" type="video/mp4">`;
- $('#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 = `<source src="http://118.190.205.7:8000${urlT}" type="video/mp4">`;
- $('#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){
- }
- })
-
- })
|