weixinsso.js 4.1 KB

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