123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- // 2018-10-11 轮播图
- var mySwiper1= new Swiper("#m_swiper",{
- loop : true,
- loopedSlides:4,
- // autoplay:5500,
- // centeredSlides: true, //居中展示
- spaceBetween:10, //间距20px
- autoplayDisableOnInteraction : false,
- // 如果需要分页器
- pagination: '.swiper-pagination',
- slidesPerView :"auto",
- });
- //获取url中的参数
- function getUrlParam(name){
- //构造一个含有目标参数的正则表达式对象
- var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
- //匹配目标参数
- var r = window.location.search.substr(1).match(reg);
- //alert(r);
- //返回参数值
- if (r!=null) return decodeURI(r[2]);
- return null;
- }
- // 筛选 选中效果
- var _city = getUrlParam('city'); //价格
- if (_city) {
- var _index = $('.videoclick li[country="'+_city+'"]').index();
- };
- //demo示例六 通过id调取 底部菜单插件
- $('#demo06').navbarscroll({
- defaultSelect:_index,
- scrollerWidth:6,
- fingerClick:1,
- endClickScroll:function(obj){
- // console.log(obj.text())
- }
- });
- // ---------------------------------------------------
- function getParams(url) {
- var theRequest = new Object();
- if (!url)
- url = location.href;
- if (url.indexOf("?") !== -1)
- {
- var str = url.substr(url.indexOf("?") + 1) + "&";
- var strs = str.split("&");
- for (var i = 0; i < strs.length - 1; i++)
- {
- var key = strs[i].substring(0, strs[i].indexOf("="));
- var val = strs[i].substring(strs[i].indexOf("=") + 1);
- theRequest[key] = val;
- }
- }
- return theRequest;
- }
- var objUrl = {}; //获取get参数
- var url = window.location.href;
- var searchParams = ''; //最后拼接的参数
- var urlParams = '';
- // 页数
- var page = 1;
- // 每页展示5个
- var size = 10;
- var params = getParams(url); //获取get请求的参数
- if(!$.isEmptyObject(params)){
- $.each(params,function(key,val){
- if(key == 'city') feng_cityTel = val;
- objUrl[key] = val;
- urlParams += key+'='+val+'&';
- })
- urlParams = urlParams.substring(0,urlParams.length - 1);
- searchParams = '&'+ urlParams;
- }
- var country = $('.videoclick li').eq(0).attr('country');
- $('.videoclick li').on('click',function(){
- var _this = $(this);
- country = $(this).attr('country');
- var ParamsArr = ['city']; //搜索字段
- var atrName = _this.attr('name');
- var _val = _this.attr('country');
- var urlParams = '';
- for (var k in ParamsArr){
- if(ParamsArr[k] == atrName){
- objUrl[atrName] = _val;
- delete objUrl.page;
- }
- }
- $.each(objUrl,function(key,val){
- if(key == 'py') return true; //跳出当前循环
- urlParams += key+'='+val+'&';
- })
- var cityUrl = '';
- urlParams = urlParams.substring(0,urlParams.length - 1);
- if(typeof objUrl.py == 'string'){
- cityUrl = 'py='+objUrl.py+'&';
- }
- if(urlParams == '' && cityUrl != '')
- {
- cityUrl = cityUrl.substring(0,cityUrl.length - 1);
- }
- window.location.href = '/video/homerelevant?'+ cityUrl+urlParams;
- })
- $(function(){
- $('.m_videolist_box').dropload({
- scrollArea : window,
- domDown : {
- domClass : 'dropload-down',
- domRefresh : '<div class="dropload-refresh">↑上拉加载更多</div>',
- domLoad : '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
- domNoData : '<div class="dropload-noData">我也是有底线的...</div>'
- },
- loadDownFn : function(me,da){
- page++;
- // 拼接HTML
- var result = '';
- $.ajax({
- type: 'GET',
- url: '/video/relevantdata?page='+page+'&limit='+size+searchParams+'&hid='+country,
- dataType: 'json',
- async:false,
- success: function(data){
- var data = data.data;
- // console.log(data);
- if(data != null){
- $.each(data,function (key,val) {
- result+= '<li class="m_hxt_imglist item">';
- result+= '<a href="/video/relevantdetails/'+val.id+'">';
- result+= '<div class="m_videolist_img">';
- result+= '<img class="img" src="'+val.thumb+'" alt="">';
- result+= '<i><img src="/video/image/video5.png" alt="">'+val.up_city+'·'+val.city_name+'</i>';
- result+= '<div class="m_videolist_text">';
- result+= '<p>';
- result+= '<span class="time_b">00:00</span>';
- result+= '</p>';
- result+= '</div>';
- result+= '</div>';
- result+= ' <div class="text">';
- var str = val.title;
- var _length = val.title.length;
- str = str.substr(0,36) + '...' ;
- if(_length > 36){
- result+= '<p class="title">'+str+'</p>';
- }else{
- result+= '<p class="title">'+val.title+'</p>';
- }
- result+= '<p class="dj c"><span><img src="/video/image/video6.png" alt="">'+(val.plays * 1 + 999)+'观看</span></p>';
- result+= '</div>';
- result+= '<video class="video_list_main" style="display:none;">';
- result+= '<source src="'+val.video_url+'" type="video/mp4">';
- result+= '</video>';
- result+= '</a>';
- result+= '</li>';
- })
- // console.log(result[1]);
- $('.m_videolist').append(result);
- myFunction($('.m_videolist_box ul li'));
- // 如果没有数据
- }else{
- // 锁定
- me.lock();
- // 无数据
- me.noData();
- }
- me.resetload();
- // 为了测试,延迟1秒加载
- // setTimeout(function(){
- // // 插入数据到页面,放到最后面
- // $('.y_hotnews_list ul').append(result);
- // // 每次数据插入,必须重置
- // me.resetload();
- // },100);
- },
- error: function(xhr, type){
- // alert('Ajax error!');
- // 即使加载出错,也得重置
- me.resetload();
- }
- });
- }
- });
- });
- // 获取 "video" 视频元素时长
- function myFunction(cid){
- cid.each(function(){
- var _this=$(this)
- _this.find('video.video_list_main')[0].addEventListener("loadedmetadata", function(){
- var tol = this.duration;//获取总时长
- var time = parseInt(tol);
- var minutes = parseInt(time / 60);
- var seconds =( time - minutes * 60);
- _this.find('.time_b').html(Appendzero(minutes)+':'+Appendzero(seconds))
- })
- })
- }
- function Appendzero (obj) { //时间补零
- if (obj < 10) return "0" + obj; else return obj;
- }
- $(document).keydown(function(event){
- if(event.keyCode==13){
- var txt = $('.y_lplist_inp').val();
- if (txt != '') {
- window.location.href = '/video/homerelevant?name='+ txt;
- };
- }
- });
|