infohome.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. var curPage = 0;
  2. var pageLen = 6;
  3. var totalLen = $("#new-video li").length;
  4. var V = {
  5. init : function(){
  6. V.scrollNews();
  7. V.triggerTab("hotVd-tab");
  8. },
  9. scrollNews : function() { // 新闻翻滚
  10. var $scrollNews = $('#scrollNews');
  11. if (!$scrollNews) return;
  12. var news = $scrollNews.children(),
  13. len = news.length,
  14. cHeight = $scrollNews.height(),
  15. perHeight = cHeight / len,
  16. interval = 2000,
  17. index = 0,//初始记录
  18. timer = setInterval(function () {
  19. $scrollNews.animate({
  20. top: - (perHeight * index) + "px"
  21. }, interval / 3)
  22. if (index === len - 1)
  23. index = 0;
  24. else
  25. index++;
  26. }, interval);
  27. },
  28. triggerTab : function(id){ //tab切换
  29. $ul=$("#"+id);
  30. $ul.on("click","li",function(){
  31. var index = $(this).index();
  32. $(this).addClass("active").siblings().removeClass("active");
  33. $($(this).attr("data-id")).show().siblings("ul").hide();
  34. $ul.parent().find(".more").eq(index).show().siblings(".more").hide();
  35. })
  36. }
  37. }
  38. var C = {
  39. init : function(){
  40. C.initFullAd()
  41. C.initYYLiveAd()
  42. // 最新视频刷新
  43. $(".col-right").on("click",".refresh",function(){
  44. ++curPage;
  45. if(curPage >= totalLen/pageLen){
  46. curPage = 0;
  47. }
  48. $("#new-video li").addClass("u-hide");
  49. for(var i=0; i<pageLen; i++){
  50. var $curLi = $("#new-video li").eq(curPage*pageLen+i);
  51. var $curImg = $curLi.find("img");
  52. var original = $curImg.attr("data-original");
  53. if(original){
  54. $curImg.removeAttr("data-original").attr("src",original);
  55. }
  56. $curLi.removeClass("u-hide");
  57. }
  58. });
  59. },
  60. initFullAd : function() {
  61. /** 广告时间判断 S */
  62. // var date = new Date();
  63. // var month = date.getMonth();
  64. // var day = date.getDate();
  65. // var hour = date.getHours();
  66. // var isTime = false;
  67. // if(month == 7 && day >= 22 && day <= 24) {
  68. // if(hour >= 15 || hour <= 10) {
  69. // isTime = true;
  70. // }
  71. // } else if(month == 7 && day >= 25 && day <= 26) {
  72. // isTime = true;
  73. // }
  74. // if(isTime == false) {
  75. // return;
  76. // }
  77. /** 广告时间判断 E */
  78. var isInitFullDa = $.cookie("isInitFullDa");
  79. var hasDa = $(".mod-da-full img").length;
  80. if(isInitFullDa != 1 && hasDa > 0) {
  81. $(".o-wrap").append("<div class='fullDa-wrap'><div class='fullDa-mask'></div><div class='fullDa-inner'><em></em></div></div>")
  82. $(".fullDa-inner").append($(".mod-da-full").html())
  83. $(".o-wrap").on("click", ".fullDa-wrap em", function() {
  84. $(".fullDa-wrap").remove();
  85. })
  86. $.cookie("isInitFullDa", 1, {
  87. expires : 1,
  88. path : "/"
  89. })
  90. }
  91. },
  92. initYYLiveAd : function() {
  93. $.ajax({
  94. url: 'http://da.duowan.com/loc/158',
  95. type: 'GET',
  96. dataType: 'jsonp',
  97. success: function(ret) {
  98. var locid = ret.locid
  99. var pid = ret.pid
  100. var item = ret.extraJson.list[0]
  101. var dom = '<li><a class="da-block-wrapper" href="'+item.url+'" target="_blank" locid="'+locid+'" pid="'+pid+'"><span class="video-img"><img src="'+item.img+'"></span></a><h2><a href="'+item.url+'" target="_blank">'+item.name+' '+item.desc+'</a></h2></li> '
  102. $("#new-video li").eq(5).replaceWith(dom)
  103. }
  104. })
  105. }
  106. }
  107. C.init();
  108. V.init();