home.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. var M = {
  2. ver : 1,
  3. os : 5,
  4. channel : "web",
  5. domain : "http://ms-api.duowan.com",
  6. gameList : [],
  7. getDetailByPn : function(packageName){
  8. var url = M.domain+"/mobileGame/byPackageName.do";
  9. var data = {
  10. channel: M.channel,
  11. ver: M.ver,
  12. os: M.os,
  13. packageName: packageName
  14. };
  15. $.ajax({
  16. url: url,
  17. dataType: 'jsonp',
  18. data: data,
  19. success: function(ret){
  20. M.gameList.push(ret.data.list[0]);
  21. if (M.gameList.length == M.installList.length) {
  22. V.initDom(3,M.gameList);
  23. }
  24. },
  25. error: function(ret){
  26. }
  27. });
  28. }
  29. }
  30. var V = {
  31. init : function(){
  32. M.os = commonUtil.checkPlatform();
  33. var info = $.parseJSON(window.installInfo);
  34. if (info) {
  35. if (info.data) {
  36. M.installList = info.data.list;
  37. for (var i=0; i<M.installList.length; i++) {
  38. M.getDetailByPn(M.installList[i]["packageName"]);
  39. }
  40. } else {
  41. V.initDom(2);
  42. }
  43. } else {
  44. V.initDom(1);
  45. }
  46. },
  47. //type:1无模拟器无游戏,2有模拟器无游戏,3有模拟器有游戏
  48. initDom : function(type,data){
  49. var bannerTpl = __inline('../../tpl/simulatorMyGame.tmpl');
  50. var dom = bannerTpl({
  51. type : type,
  52. data : data
  53. });
  54. $("#gameWrap").html(dom);
  55. var PageTurn = new commonUtil.PageTurn({
  56. showNum : 18
  57. });
  58. }
  59. }
  60. function initData() {
  61. var timeout = setTimeout(function(){
  62. if(window.doneFlag) {
  63. V.init();
  64. } else {
  65. initData();
  66. }
  67. },200);
  68. }
  69. initData();