Main.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. MWF.require("MWF.widget.MaskNode", null, false);
  2. o2.requireApp("AppMarketV2", "RecommendContent", null, false);
  3. MWF.xApplication.AppMarketV2.Main = new Class({
  4. Extends: MWF.xApplication.Common.Main,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "mvcStyle": "style.css",
  9. "name": "AppMarketV2",
  10. "icon": "icon.png",
  11. "width": "1000",
  12. "height": "700",
  13. "isResize": true,
  14. "isMax": true,
  15. "title": MWF.xApplication.AppMarketV2.LP.title,
  16. "minHeight": 700
  17. },
  18. onQueryLoad: function(){
  19. this.lp = MWF.xApplication.AppMarketV2.LP;
  20. this.actions = MWF.Actions.load("x_program_center");
  21. this.viewPath = this.path+this.options.style+"/view.html";
  22. this.iconPath = this.path+this.options.style+"/icon/";
  23. },
  24. mask: function(){
  25. if (!this.maskNode){
  26. this.marketnode.setStyle("overflow","hidden");
  27. this.maskNode = new MWF.widget.MaskNode(this.marketnode, {"style": "bam"});
  28. this.maskNode.load();
  29. }
  30. },
  31. unmask: function(){
  32. if (this.maskNode) this.maskNode.hide(function(){
  33. MWF.release(this.maskNode);
  34. this.maskNode = null;
  35. this.marketnode.setStyle("overflow","auto");
  36. }.bind(this));
  37. },
  38. loadApplication: function(callback){
  39. if (MWF.AC.isAdministrator()){ //this.checkO2Collect();
  40. this.content.loadHtml(this.viewPath, {"bind": {"lp": this.lp}, "module": this}, function(){
  41. if (!this.options.isRefresh){
  42. this.maxSize(function(){
  43. //检查是否在云服务器上已注册
  44. this.actions.CollectAction.login(//平台封装好的方法
  45. function( json ){ //服务调用成功的回调函数, json为服务传回的数据
  46. if (json.type && json.type=="success"){
  47. this.loadApp(callback);
  48. }
  49. }.bind(this),
  50. function( json ){ //服务调用成功的回调函数, json为服务传回的数据
  51. errtype = JSON.parse(json.response).type;
  52. if (errtype && errtype=="error"){
  53. //o2.xDesktop.notice("error", {x: "right", y:"top"}, JSON.parse(json.response).message+"请至系统配置——云服务配置——连接配置注册并连接到O2云");
  54. this.loadCloudConnectTip(callback);
  55. }
  56. }.bind(this)
  57. ,false //同步执行
  58. );
  59. }.bind(this));
  60. }else{
  61. this.loadApp(callback);
  62. }
  63. }.bind(this));
  64. }else{
  65. o2.xDesktop.notice("error", {x: "right", y:"top"}, this.lp.accessDenyNotice);
  66. }
  67. },
  68. loadApp: function(callback){
  69. //this.initNode();
  70. this.initNodeSize();
  71. this.recommondLoaded = false;
  72. this.applicationsLoaded = true;
  73. this.loadRecommondContent(function(){ this.recommondLoaded = true; this.checkAppLoaded(callback); }.bind(this));
  74. this.loadApplicationsContent(function(){ this.applicationsLoaded = true; this.checkAppLoaded(callback); }.bind(this));
  75. },
  76. loadCloudConnectTip:function(callback){
  77. this.initNodeSize();
  78. o2.requireApp("AppMarketV2", "CloudConnectTip", function(){
  79. this.cloudTip = new MWF.xApplication.AppMarketV2.CloudConnectTip(this, this.cloudConnectTipNode, {
  80. "onLoad": function(){if (callback) callback();}
  81. });
  82. }.bind(this));
  83. },
  84. checkAppLoaded: function(callback){
  85. if (this.recommondLoaded && this.applicationsLoaded){
  86. if (callback) callback();
  87. }
  88. },
  89. initNodeSize: function(){
  90. this.resizeNodeSize();
  91. this.addEvent("resize", this.resizeNodeSize.bind(this));
  92. },
  93. resizeNodeSize: function(){
  94. var size = this.content.getSize();
  95. var edge = this.marketnode.getEdgeHeight();
  96. var height = size.y - edge;
  97. if (height<this.options.minHeight) height = this.options.minHeight;
  98. this.marketnode.setStyle("height", ""+height+"px");
  99. },
  100. loadRecommondContent: function(callback){
  101. debugger;
  102. this.recommendContent = new MWF.xApplication.AppMarketV2.RecommendContent(this, this.topRecommendNode, {
  103. "onLoad": function(){if (callback) callback();}
  104. });
  105. },
  106. loadApplicationsContent: function(callback){
  107. o2.requireApp("AppMarketV2", "ApplicationsContent", function(){
  108. this.applicationsContent = new MWF.xApplication.AppMarketV2.ApplicationsContent(this, this.applicationsNode, {
  109. "onLoad": function(){if (callback) callback();}
  110. });
  111. }.bind(this));
  112. }
  113. });