erelevantdetails.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. $('.m_video_img').on('click',function(){ //处理视频播放图标
  2. var _video = document.getElementById("myVideo");
  3. myVideo.play(); //点击图标视频播放
  4. $('.m_video_sp').attr('controls','controls'); //点击 显示默认的控件
  5. $(this).hide();
  6. var id = $(".m_video_img").attr('data-id');
  7. $.ajax({
  8. url:'/video/plays',
  9. dataType:"json",
  10. type:'GET',
  11. data:{id:id},
  12. success:function(data){
  13. }
  14. });
  15. })
  16. // 精选楼盘 换一换
  17. var idQh = 1; //默认页数
  18. var DataN = $('.m_zaigai_title i').attr('city'); //默认ID
  19. var _number = $('.m_zaigai_title i').attr('number'); //换一换页数
  20. ajax_lp();
  21. if(_number < 2){
  22. $('.m_zaigai_title i').hide();
  23. }else{
  24. $('.m_zaigai_title i').show();
  25. $('.m_zaigai_title i').on('click',function(){
  26. idQh += 1;
  27. // console.log(idQh);
  28. if (idQh > _number) {
  29. idQh = 1;
  30. };
  31. ajax_lp();
  32. })
  33. }
  34. // 精选楼盘
  35. function ajax_lp (){
  36. var html = '';
  37. $.ajax({
  38. url: "/video/relevantpush", // 索取
  39. data:{page:idQh,city:DataN}, //传ID
  40. type: "GET",
  41. dataType: "json",
  42. success: function(data) {//请求成功完成后要执行的方法
  43. if(data.code == 200){
  44. $.each(data.data, function (i, data) {
  45. html+= '<li class="c">';
  46. html+= '<a href="/video/relevantdetails/'+data.id+'" class="c">';
  47. html+= '<div class="sell_img">';
  48. html+= '<img class="img" src="'+data.thumb+'" alt="">';
  49. html+= '<p>';
  50. html+= '<i class="time_b">00:00</i>';
  51. html+= '</p>';
  52. html+= '<img class="tb" src="/video/image/video2.png" alt="">';
  53. html+= '</div>';
  54. html+= '<div class="sell_conter_right">';
  55. var str = data.title;
  56. var _length = data.title.length;
  57. str = str.substr(0,20) + '...' ;
  58. if(_length > 20){
  59. html+= '<p class="text">'+str+'</p>';
  60. }else{
  61. html+= '<p class="text">'+data.title+'</p>';
  62. }
  63. html+= '<p class="Number">'+(data.plays * 1 + 999)+'播放 | '+data.create_at+'</p>';
  64. html+= '</div>';
  65. html+= '<video class="video_list_main" style="display:none;">';
  66. html+= '<source src="'+data.video_url+'" type="video/mp4">';
  67. html+= '</video>';
  68. html+= '</a>';
  69. html+= '</li>';
  70. });
  71. }
  72. $('.sell_conter ul').html(html);
  73. myFunction($('.sell_conter ul li'));
  74. }
  75. });
  76. }
  77. // 获取 "video" 视频元素时长
  78. function myFunction(cid){
  79. cid.each(function(){
  80. var _this=$(this)
  81. _this.find('video.video_list_main')[0].addEventListener("loadedmetadata", function(){
  82. var tol = this.duration;//获取总时长
  83. var time = parseInt(tol);
  84. var minutes = parseInt(time / 60);
  85. var seconds =( time - minutes * 60);
  86. _this.find('.time_b').html(Appendzero(minutes)+':'+Appendzero(seconds))
  87. })
  88. })
  89. }
  90. function Appendzero (obj) { //时间补零
  91. if (obj < 10) return "0" + obj; else return obj;
  92. }