weixinsso.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. layout = window.layout || {};
  2. var locate = window.location;
  3. layout.protocol = locate.protocol;
  4. var href = locate.href;
  5. if (href.indexOf("debugger")!=-1) layout.debugger = true;
  6. layout.desktop = layout;
  7. layout.session = layout.session || {};
  8. COMMON.DOM.addReady(function(){
  9. COMMON.AjaxModule.load("/x_desktop/res/framework/mootools/plugin/mBox.Notice.js", null, false);
  10. COMMON.AjaxModule.load("/x_desktop/res/framework/mootools/plugin/mBox.Tooltip.js", null, false);
  11. COMMON.setContentPath("/x_desktop");
  12. COMMON.AjaxModule.load("mwf", function(){
  13. MWF.defaultPath = "/x_desktop"+MWF.defaultPath;
  14. MWF.loadLP("zh-cn");
  15. // MWF.require("MWF.widget.Mask", null, false);
  16. // layout.mask = new MWF.widget.Mask({"style": "desktop"});
  17. // layout.mask.load();
  18. MWF.require("MWF.xDesktop.Layout", function(){
  19. MWF.require("MWF.xDesktop.Authentication", null, false);
  20. (function(){
  21. layout.load = function(){
  22. var uri = href.toURI();
  23. MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  24. var action = new MWF.xDesktop.Actions.RestActions("", "x_organization_assemble_authentication", "");
  25. action.getActions = function(actionCallback){
  26. this.actions = {"sso": {"uri": "/jaxrs/qiyeweixin/code/{code}", "method":"GET"}};
  27. if (actionCallback) actionCallback();
  28. };
  29. action.invoke({"name": "sso","async": true, "parameter": {"code": uri.getData("code")},"success": function(json){
  30. "appMobile.html?app=process.TaskCenter".toURI().go();
  31. //window.loaction = "app.html?app=process.TaskCenter";
  32. }.bind(this), "failure": function(xhr, text, error){
  33. "appMobile.html?app=process.TaskCenter".toURI().go();
  34. //window.loaction = "app.html?app=process.TaskCenter";
  35. }.bind(this)});
  36. });
  37. };
  38. layout.isAuthentication = function(){
  39. layout.authentication = new MWF.xDesktop.Authentication({
  40. "onLogin": layout.load.bind(layout)
  41. });
  42. var returnValue = true;
  43. this.authentication.isAuthenticated(function(json){
  44. this.user = json.data;
  45. layout.session.user = json.data;
  46. }.bind(this), function(){
  47. this.authentication.loadLogin(this.node);
  48. returnValue = false;
  49. }.bind(this));
  50. return returnValue;
  51. };
  52. layout.notice = function(content, type, target, where, offset){
  53. if (!where) where = {"x": "right", "y": "top"};
  54. if (!target) target = this.content;
  55. if (!type) type = "ok";
  56. var noticeTarget = target || $(document.body);
  57. var off = offset;
  58. if (!off){
  59. off = {
  60. x: 10,
  61. y: where.y.toString().toLowerCase()=="bottom" ? 10 : 10
  62. };
  63. }
  64. new mBox.Notice({
  65. type: type,
  66. position: where,
  67. move: false,
  68. target: noticeTarget,
  69. delayClose: (type=="error") ? 10000 : 5000,
  70. offset: off,
  71. content: content
  72. });
  73. };
  74. MWF.getJSON("res/config/config.json", function(config){
  75. layout.config = config;
  76. MWF.xDesktop.getServiceAddress(layout.config, function(service, center){
  77. layout.serviceAddressList = service;
  78. layout.centerServer = center;
  79. layout.load();
  80. }.bind(this));
  81. //layout.getServiceAddress(function(){
  82. // layout.load();
  83. //});
  84. });
  85. })();
  86. });
  87. });
  88. });