search.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. var M = {
  2. ver : 1,
  3. os : 5,
  4. channel : "web",
  5. domain : "http://test.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. M.os = commonUtil.checkPlatform();
  32. M.getSearchList(commonUtil.getParam("key"));
  33. },
  34. renderGameList : function(data,key){
  35. var bannerTpl = __inline('../../tpl/simulatorGameList.tmpl');
  36. var dom = bannerTpl({
  37. data : data
  38. });
  39. key = key?key:"";
  40. $("#gameWrap").html(dom);
  41. $("#searchKey").html("搜索 “<span>"+key+"</span>” 结果");
  42. $("[name=key]").val(key);
  43. var PageTurn = new commonUtil.PageTurn({
  44. element : '[data-role='+data.role+']',
  45. showNum : 18
  46. });
  47. }
  48. }
  49. var C = {
  50. init : function(){
  51. }
  52. }
  53. V.init();
  54. C.init();