search.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. var M = {
  2. ver : 1,
  3. os : 5,
  4. channel : "web",
  5. domain : "http://ms-api.duowan.com",
  6. //获取搜索列表
  7. getSearchList : function(key){
  8. var url = M.domain+"/home/search.do";
  9. var data = {
  10. channel: M.channel,
  11. ver: M.ver,
  12. os: M.os,
  13. keyword : key
  14. };
  15. $.ajax({
  16. url: url,
  17. dataType: 'jsonp',
  18. data: data,
  19. success: function(ret){
  20. ret.data.role = "all";
  21. V.renderGameList(ret.data,key);
  22. },
  23. error: function(ret){
  24. M.getSearchList();
  25. }
  26. });
  27. }
  28. }
  29. var V = {
  30. init : function(){
  31. commonUtil.initHezi();
  32. M.os = commonUtil.checkPlatform();
  33. M.getSearchList(commonUtil.getParam("key"));
  34. },
  35. renderGameList : function(data,key){
  36. var bannerTpl = __inline('../../tpl/simulatorGameList.tmpl');
  37. var dom = bannerTpl({
  38. data : data
  39. });
  40. key = key?key:"";
  41. $("#gameWrap").html(dom);
  42. $("#searchKey").html("搜索 “<span>"+key+"</span>” 结果");
  43. $("[name=key]").val(key);
  44. var PageTurn = new commonUtil.PageTurn({
  45. element : '[data-role='+data.role+']',
  46. showNum : 18
  47. });
  48. }
  49. }
  50. var C = {
  51. init : function(){
  52. }
  53. }
  54. V.init();
  55. C.init();