detail.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. seajs.use(['arale/switchable/1.0.2/carousel','arale/qrcode/1.0.3/qrcode','arale/dialog/1.3.1/dialog'], function(Carousel,Qrcode,Dialog) {
  2. var M = {
  3. ver : 1,
  4. os : 5,
  5. channel : "web",
  6. domain : "http://ms-api.duowan.com",
  7. installList : [],
  8. //获取游戏详情
  9. getDetail : function(gameId){
  10. var url = M.domain+"/mobileGame/detail.do";
  11. var data = {
  12. channel: M.channel,
  13. ver: M.ver,
  14. os: M.os,
  15. gameId: gameId
  16. };
  17. $.ajax({
  18. url: url,
  19. dataType: 'jsonp',
  20. data: data,
  21. success: function(ret){
  22. var detail = ret.data;
  23. detail.isInstall = false;
  24. if(M.installList){
  25. for(var i=0; i<M.installList.length; i++) {
  26. if(detail.packageName == M.installList[i]["packageName"]){
  27. detail.isInstall = true;
  28. }
  29. }
  30. }
  31. V.renderDetail(detail);
  32. },
  33. error: function(ret){
  34. M.getDetail(gameId);
  35. }
  36. });
  37. },
  38. //浏览数据上报
  39. gameBrowse : function(gameId){
  40. var url = M.domain+"/mobileGame/browse.do";
  41. var data = {
  42. channel: M.channel,
  43. ver: M.ver,
  44. os: M.os,
  45. gameId: gameId
  46. };
  47. $.ajax({
  48. url: url,
  49. dataType: 'jsonp',
  50. data: data,
  51. success: function(ret){
  52. },
  53. error: function(ret){
  54. M.gameBrowse(gameId);
  55. }
  56. });
  57. }
  58. }
  59. var V = {
  60. init : function(){
  61. M.os = commonUtil.checkPlatform();
  62. M.gameBrowse(commonUtil.getParam("gameId"));
  63. var info = $.parseJSON(window.installInfo);
  64. if (info) {
  65. if (info.data) {
  66. M.installList = info.data.list;
  67. } else {
  68. M.installList = [];
  69. }
  70. } else {
  71. M.installList = [];
  72. }
  73. M.getDetail(commonUtil.getParam("gameId"));
  74. $(".page-detail").niceScroll({
  75. cursorcolor: "#d9d9d9",
  76. cursorwidth: "6",
  77. cursorborder: 'none'
  78. });
  79. },
  80. renderDetail : function(data){
  81. var detailTpl = __inline('../../tpl/simulatorDetail.tmpl');
  82. var dom = detailTpl({
  83. data : data
  84. });
  85. $(".page-detail").html(dom);
  86. var carousel1 = new Carousel({
  87. element: '[data-role="carousel-banner"]',
  88. classPrefix: null,
  89. disabledBtnClass: 'is-disabled',
  90. hasTriggers: false, //隐藏触发器
  91. effect: 'scrollx',
  92. step: 3,
  93. viewSize: [326],
  94. circular: false, //禁用循环切换
  95. autoplay: false
  96. }).render();
  97. }
  98. }
  99. var C = {
  100. init : function() {
  101. var pop;
  102. var popFlag = false;
  103. var qrcode;
  104. $(document).on("click",".btn-phone",function(){
  105. var url = $(this).attr("data-url");
  106. var qrcode = new Qrcode({
  107. text: url,
  108. width: 160,
  109. height: 160
  110. });
  111. if (!popFlag) {
  112. pop = new Dialog({
  113. contentType:4,
  114. content: '<div id="qcWrap"></div><p>打开手机扫一扫</p>',
  115. width:200,
  116. classPrefix:"pop-qrcode"
  117. });
  118. qrcode = new Qrcode({
  119. text: url,
  120. width: 160,
  121. height: 160
  122. });
  123. pop.show();
  124. $("#qcWrap").html(qrcode);
  125. popFlag = true;
  126. } else {
  127. pop.show();
  128. }
  129. });
  130. }
  131. }
  132. function initData() {
  133. var timeout = setTimeout(function(){
  134. if(window.doneFlag) {
  135. V.init();
  136. } else {
  137. initData();
  138. }
  139. },200);
  140. }
  141. C.init();
  142. initData();
  143. });