|
@@ -0,0 +1,123 @@
|
|
|
+var seaLoader = require('sealoader');
|
|
|
+var _ = require('underscore');
|
|
|
+
|
|
|
+var carousel; // 旋转木马组件
|
|
|
+var carouselGame; //游戏标题tag旋转
|
|
|
+
|
|
|
+var V = {
|
|
|
+ init : function(seajs){
|
|
|
+ seajs.use(['arale/switchable/1.0.2/tabs'], function(Tabs) {
|
|
|
+ var tabs2 = new Tabs({
|
|
|
+ element: '[data-role="tab-newgame"]',
|
|
|
+ classPrefix: null,
|
|
|
+ triggerType: 'click',
|
|
|
+ activeTriggerClass: 'is-active'
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ // seajs.use(['arale/switchable/1.0.2/carousel'], function(carouselTool) {
|
|
|
+ // carousel = carouselTool;
|
|
|
+ // V.newCarousel();
|
|
|
+ // });
|
|
|
+
|
|
|
+
|
|
|
+ // M.getAd(function(videoInfo) {
|
|
|
+ // if(videoInfo) {
|
|
|
+ // var tplList = __inline('../../tpl/ilike.tmpl')
|
|
|
+ // var dom = tplList({data : [videoInfo]});
|
|
|
+ // $(".mod-hotgame .g-col-gItem").eq(3).replaceWith(dom)
|
|
|
+ // }
|
|
|
+
|
|
|
+ // })
|
|
|
+ },
|
|
|
+ newCarousel : function(){
|
|
|
+ var viewSize,step;
|
|
|
+
|
|
|
+ if($(window).width() < 1420) {
|
|
|
+ viewSize = 340;
|
|
|
+ step = 4;
|
|
|
+ } else {
|
|
|
+ viewSize = 510;
|
|
|
+ step = 6;
|
|
|
+ }
|
|
|
+ carouselGame = new carousel({
|
|
|
+ element: '[data-role="carousel-hotgame"]',
|
|
|
+ classPrefix: null,
|
|
|
+ autoplay: false,
|
|
|
+ effect: 'scrollx',
|
|
|
+ step: step,
|
|
|
+ viewSize: [viewSize],
|
|
|
+ activeIndex: 0
|
|
|
+ }).render();
|
|
|
+ },
|
|
|
+ destroyCarousel : function(){
|
|
|
+ carouselGame.destroy();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+var C = {
|
|
|
+ init : function(){
|
|
|
+ //匹配大小屏旋转木马
|
|
|
+ $(window).on("resize", _.debounce(function() {
|
|
|
+ V.destroyCarousel();
|
|
|
+ setTimeout(function() {
|
|
|
+ V.newCarousel();
|
|
|
+ }, 100);
|
|
|
+ }, 100));
|
|
|
+
|
|
|
+ //游戏标签切换内容
|
|
|
+ $(".mod-newgame").on("mouseover", ".ui-carousel__item", function() {
|
|
|
+ var $this = $(this);
|
|
|
+ var index = $this.index();
|
|
|
+ var $curEle = $(".mod-newgame .g-col-880 .g-col-bd .g-col-tabPanel").eq(index);//对应的显示区域
|
|
|
+
|
|
|
+ $this.addClass("is-active").siblings().removeClass("is-active");
|
|
|
+ $curEle.removeClass("u-hide").siblings().addClass("u-hide");
|
|
|
+
|
|
|
+ //将data-src属性赋值给src
|
|
|
+ $curEle.find('img[data-src]').each(function(index,ele){
|
|
|
+ $(ele).attr('src',$(ele).attr('data-src'));
|
|
|
+ $(ele).removeAttr('data-src');
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+var M = {
|
|
|
+ getAd : function(callback) {
|
|
|
+ $.ajax({
|
|
|
+ url : "//gt.duowan.com/api/g?loc=youxiqushipintuijan",
|
|
|
+ dataType : 'jsonp',
|
|
|
+ jsonp: 'jsonpilike',
|
|
|
+ jsonpCallback: "jsonpilike",
|
|
|
+ success : function(ret) {
|
|
|
+ var link = ret.ad_link.split("play/")[1];
|
|
|
+ var vid = link.split(".")[0];
|
|
|
+ if(vid) {
|
|
|
+ $.ajax({
|
|
|
+ url : "http://video.duowan.com/jsapi/getVideoInfo/?vids=" + vid,
|
|
|
+ dataType : 'jsonp',
|
|
|
+ success : function(videoInfo) {
|
|
|
+ var obj = videoInfo[vid];
|
|
|
+ obj['rsid'] = ret.rsid;
|
|
|
+ obj['adid'] = ret.adid;
|
|
|
+ callback && callback(obj);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ callback && callback(0);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error : function() {
|
|
|
+ callback && callback(0);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+C.init();
|
|
|
+seaLoader(function(seajs) {
|
|
|
+ V.init(seajs);
|
|
|
+});
|