123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- $('.m_video_img').on('click',function(){ //处理视频播放图标
- var _video = document.getElementById("myVideo");
- myVideo.play(); //点击图标视频播放
- $('.m_video_sp').attr('controls','controls'); //点击 显示默认的控件
- $(this).hide();
- var id = $(".m_video_img").attr('data-id');
- $.ajax({
- url:'/video/plays',
- dataType:"json",
- type:'GET',
- data:{id:id},
- success:function(data){
- }
- });
- })
- // 精选楼盘 换一换
- var idQh = 1; //默认页数
- var DataN = $('.m_zaigai_title i').attr('city'); //默认ID
- var _number = $('.m_zaigai_title i').attr('number'); //换一换页数
- ajax_lp();
- if(_number < 2){
- $('.m_zaigai_title i').hide();
- }else{
- $('.m_zaigai_title i').show();
- $('.m_zaigai_title i').on('click',function(){
- idQh += 1;
- // console.log(idQh);
- if (idQh > _number) {
- idQh = 1;
- };
-
- ajax_lp();
- })
- }
- // 精选楼盘
- function ajax_lp (){
- var html = '';
- $.ajax({
- url: "/video/relevantpush", // 索取
- data:{page:idQh,city:DataN}, //传ID
- type: "GET",
- dataType: "json",
- success: function(data) {//请求成功完成后要执行的方法
- if(data.code == 200){
- $.each(data.data, function (i, data) {
- html+= '<li class="c">';
- html+= '<a href="/video/relevantdetails/'+data.id+'" class="c">';
- html+= '<div class="sell_img">';
- html+= '<img class="img" src="'+data.thumb+'" alt="">';
- html+= '<p>';
- html+= '<i class="time_b">00:00</i>';
- html+= '</p>';
- html+= '<img class="tb" src="/video/image/video2.png" alt="">';
- html+= '</div>';
- html+= '<div class="sell_conter_right">';
-
- var str = data.title;
- var _length = data.title.length;
- str = str.substr(0,20) + '...' ;
- if(_length > 20){
- html+= '<p class="text">'+str+'</p>';
- }else{
- html+= '<p class="text">'+data.title+'</p>';
- }
- html+= '<p class="Number">'+(data.plays * 1 + 999)+'播放 | '+data.create_at+'</p>';
- html+= '</div>';
- html+= '<video class="video_list_main" style="display:none;">';
- html+= '<source src="'+data.video_url+'" type="video/mp4">';
- html+= '</video>';
- html+= '</a>';
- html+= '</li>';
- });
- }
- $('.sell_conter ul').html(html);
- myFunction($('.sell_conter ul li'));
- }
- });
- }
- // 获取 "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;
- }
|