123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- seajs.use(['arale/switchable/1.0.2/slide','arale/dialog/1.3.1/dialog'], function(Slide,Dialog) {
- var M = {
- ver : 1,
- os : 5,
- channel : "web",
- domain : "http://ms-api.duowan.com",
- recommendCache : {},
- typeId : 1,
- sortType : 1,
- //banner图
- getBanner : function(){
- var url = M.domain+"/home/banner.do";
- var data = {
- channel: M.channel,
- ver: M.ver,
- os: M.os
- };
- $.ajax({
- url: url,
- dataType: 'jsonp',
- data: data,
- success: function(ret){
- V.renderBanner(ret);
- },
- error: function(ret){
- M.getBanner();
- }
- });
- },
- //获取推荐类型
- getRecommenderType : function(){
- var url = M.domain+"/home/recommenderType.do";
- var data = {
- channel: M.channel,
- ver: M.ver,
- os: M.os,
- uid: M.uid,
- token: M.token
- };
- $.ajax({
- url: url,
- dataType: 'jsonp',
- data: data,
- success: function(ret){
- M.typeId = ret.data.list[0]["id"];
- // V.renderRecommenderType(ret);
- },
- error: function(ret){
- M.getRecommenderType();
- }
- });
- },
- //由推荐类型获取推荐游戏列表
- getRecommendByCT : function(){
- var url = M.domain+"/mobileGame/byCommonType.do";
- var data = {
- typeId: M.typeId,
- channel: M.channel,
- ver: M.ver,
- os: M.os,
- uid: M.uid,
- token: M.token,
- sortType : M.sortType
- };
- var gamaFlag = "type"+M.typeId+M.sortType;
- if (M.recommendCache.hasOwnProperty(gamaFlag)) {
- V.renderRecommender(M.recommendCache[gamaFlag]);
- return;
- }
- $.ajax({
- url: url,
- dataType: 'jsonp',
- data: data,
- success: function(ret){
- M.recommendCache[gamaFlag] = ret;
- V.renderRecommender(ret);
- },
- error: function(ret){
- M.getRecommendByCT();
- }
- });
- },
- //获取游戏下载排行
- getDownloadRank : function(){
- var url = M.domain+"/home/downloadRank.do";
- var data = {
- channel: M.channel,
- ver: M.ver,
- os: M.os,
- uid: M.uid,
- token: M.token
- };
- $.ajax({
- url: url,
- dataType: 'jsonp',
- data: data,
- success: function(ret){
- V.renderDownloadRank(ret);
- },
- error: function(ret){
- M.getDownloadRank();
- }
- });
- }
- }
- var V = {
- init : function(){
- M.os = commonUtil.checkPlatform();
- M.getBanner();
- // M.getRecommenderType();
- M.getRecommendByCT(1);
- M.getDownloadRank();
- },
- renderBanner : function(ret){
- var bannerTpl = __inline('../../tpl/simulatorBannar.tmpl');
- var dom = bannerTpl({
- data : ret.data.list
- });
- $("#bannerWrap").html(dom);
- if(!ret.data.list){
- return;
- }
- var slide1 = new Slide({
- element: '[data-role="slide-banner"]',
- classPrefix: null,
- activeTriggerClass: 'is-active',
- autoplay: true,
- effect: 'scrollx'
- }).render();
- },
- renderRecommenderType : function(ret){
- var list = ret.data.list;
- var len = list.length;
- var dom = "";
- for (var i=0; i<len; i++){
- dom += '<option value="'+list[i]["id"]+'">'+list[i]["typeName"]+'</option>';
- }
- $("#recommendTypeWrap").html(dom);
- M.getRecommendByCT($("#recommendTypeWrap").val());
- },
- renderRecommender : function(ret){
- var recommendTpl = __inline('../../tpl/simulatorRecommend.tmpl');
-
- var dom = recommendTpl({
- data : ret.data.list
- });
- $("#recommendWrap").html(dom);
- },
- renderDownloadRank : function(ret){
- var rankTpl = __inline('../../tpl/simulatorDlRank.tmpl');
- var dom = rankTpl({
- data : ret.data.list
- });
- $("#dlRankWrap").html(dom);
- },
- initBanner : function(){
- var slide = new Slide({
- element: '[data-role="slide-banner"]',
- classPrefix: null,
- activeTriggerClass: 'is-active',
- autoplay: false,
- effect: 'scrollx'
- }).render();
- },
- popUp : function(){
- var popTpl = __inline('../../tpl/simulatorDialog.tmpl');
- var dom = popTpl();
- var pop = new Dialog({
- contentType:4,
- content: dom,
- width:520,
- height: 320,
- classPrefix:"pop-center"
- }).show();
- //弹框
- $(".pop-center .btn-go").click(function(){
- $(this).parent().fadeOut().siblings().fadeIn();
- });
- $(".pop-center .btn-open").click(function(){
- pop.hide();
- });
- }
- }
- var C = {
- init : function(){
- //排行榜
- $("#dlRankWrap").on("mousemove",".item-rank",function(){
- $(this).addClass("active").siblings().removeClass("active");
- });
- //推荐位游戏
- var select = new commonUtil.Select({
- element : ".select-wrap",
- callback : function(val){
- M.sortType = val;
- M.getRecommendByCT();
- }
- });
- }
- }
- function initPop() {
- var timeout = setTimeout(function(){
- if(window.doneFlag) {
- if (window.popStatus==1) {
- V.popUp();
- }
- } else {
- initPop();
- }
- },200);
- }
- C.init();
- V.init();
- initPop();
- });
-
|