RecommendContent.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. MWF.xApplication.AppMarketV2.RecommendContent = new Class({
  2. Implements: [Options, Events],
  3. options: {
  4. "view": "recommendContent.html"
  5. },
  6. initialize: function(app, container, options){
  7. this.setOptions(options);
  8. this.app = app;
  9. this.container = container;
  10. this.viewPath = this.app.path+this.app.options.style+"/"+this.options.view;
  11. debugger;
  12. this.load();
  13. },
  14. load: function(){
  15. debugger;
  16. this.container.loadHtml(this.viewPath, {"bind": {"lp": this.app.lp}, "module": this}, function(){
  17. this.loadRecommend(function(){
  18. this.fireEvent("load");
  19. }.bind(this));
  20. }.bind(this));
  21. },
  22. loadRecommend: function(callback){
  23. debugger;
  24. if (!this.isLoading){
  25. if (!this.topRecommendContentV){
  26. this.topRecommendContentV = new MWF.xApplication.AppMarketV2.RecommendContent.Recommend(this, {
  27. "onLoad": function(){ if (callback) callback(); }
  28. });
  29. }else{
  30. this.topRecommendContentV.load();
  31. }
  32. }
  33. }
  34. });
  35. MWF.xApplication.AppMarketV2.RecommendContent.Recommend= new Class({
  36. Implements: [Options, Events],
  37. options: {
  38. "type": "recommend"
  39. },
  40. initialize: function(content, options){
  41. this.setOptions(options);
  42. this.content = content;
  43. this.app = this.content.app;
  44. this.actions = this.app.actions;
  45. this.container = this.content.container;
  46. this.page = 1;
  47. this.pageSize = 3;
  48. this.querydata = {"orderBy":"recommend","isAsc":"true"};
  49. this.load();
  50. },
  51. load: function(){
  52. debugger;
  53. this.loadItemsRes();
  54. },
  55. loadItemsRes: function(){
  56. debugger;
  57. this.actions.MarketAction.listPaging(this.page, this.pageSize, this.querydata,function(json){
  58. if (json.data && json.data.length){
  59. this.loadItems(json.data);
  60. }else{
  61. this.emptyLoadContent();
  62. }
  63. this.fireEvent("load");
  64. }.bind(this));
  65. },
  66. reload: function(){
  67. if (!this.content.isLoading) {
  68. this.loadItemsRes();
  69. }
  70. },
  71. emptyLoadContent: function(){
  72. this.container.empty();
  73. this.container.removeClass("o2_homepage_area_content_loading").removeClass("icon_loading");
  74. //this.itemContentNode.addClass("o2_homepage_task_area_content_empty").addClass("icon_notask");
  75. this.content.noItemNode = new Element("div.o2_appMarket_content_empty_node", {"text": this.app.lp.noRecommend}).inject(this.container);
  76. var m = (this.content.contentHeight- this.content.noItemNode.getSize().y)/2;
  77. this.content.noItemNode.setStyle("margin-top", ""+m+"px");
  78. this.content.isLoading = false;
  79. },
  80. loadItems: function(data){
  81. debugger;
  82. var recommendWidth = this.content.topRecommendContent.clientWidth;
  83. var recommendLeftWidth = (recommendWidth - 80-10)*0.65;
  84. var recommendRightWidth = (recommendWidth - 80-10)*0.35;
  85. this.content.leftCoverNode.setStyle("width",recommendLeftWidth+"px");
  86. this.content.rightCoverNode.setStyle("width",recommendRightWidth+"px");
  87. data.each(function(d, i){
  88. this.loadItem(d, i);
  89. }.bind(this));
  90. },
  91. loadItem: function(d, i){
  92. var app;
  93. var apppar;
  94. debugger;
  95. if (i==0){
  96. app = this.content.recommendBiggestPic;
  97. apptext = this.content.recommendBiggestTitle;
  98. apppar = this.content.leftCoverNode;
  99. }
  100. if (i==1){
  101. app = this.content.recommendRightTopPic;
  102. apptext = this.content.recommendRightTopTitle;
  103. apppar = this.content.rightTopCoverNode;
  104. }
  105. if (i==2){
  106. app = this.content.recommendRightBottomPic;
  107. apptext = this.content.recommendRightBottomTitle;
  108. apppar = this.content.rightBottomCoverNode;
  109. }
  110. //获取对应indexPic图片
  111. this.actions.MarketAction.getCoverPic(d.id,function(json){
  112. debugger;
  113. if (json.data && json.data.value){
  114. app.setStyle("background-image", "url(data:image/png;base64,"+json.data.value+")");
  115. }
  116. }.bind(this));
  117. apptext.set("text",d.name);
  118. var _self = this;
  119. apppar.store("data", d);
  120. apppar.addEvents({
  121. "mouseover": function(){
  122. },
  123. "mouseout": function(){
  124. },
  125. "click": function(e){
  126. var d = this.retrieve("data");
  127. if (d) {
  128. _self.open(e, d);
  129. }
  130. }
  131. })
  132. },
  133. open: function(e, d){
  134. debugger;
  135. var apppar = {};
  136. apppar["appid"] = d.id;
  137. layout.openApplication(e, "AppMarketV2.Application", apppar);
  138. },
  139. });