weixinsso.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. var redirect = uri.getData("redirect");
  21. MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  22. var action = new MWF.xDesktop.Actions.RestActions("", "x_organization_assemble_authentication", "");
  23. action.getActions = function(actionCallback){
  24. this.actions = {"sso": {"uri": "/jaxrs/qiyeweixin/code/{code}", "method":"GET"}};
  25. if (actionCallback) actionCallback();
  26. };
  27. action.invoke({"name": "sso","async": true, "parameter": {"code": uri.getData("code")},"success": function(json){
  28. if (redirect){
  29. redirect.toURI().go();
  30. }else{
  31. "appMobile.html?app=process.TaskCenter".toURI().go();
  32. }
  33. //"appMobile.html?app=process.TaskCenter".toURI().go();
  34. //window.loaction = "app.html?app=process.TaskCenter";
  35. }.bind(this), "failure": function(xhr, text, error){
  36. document.id("layout").set("html", "<div></div>")
  37. //"appMobile.html?app=process.TaskCenter".toURI().go();
  38. //window.loaction = "app.html?app=process.TaskCenter";
  39. }.bind(this)});
  40. });
  41. };
  42. layout.isAuthentication = function(){
  43. layout.authentication = new MWF.xDesktop.Authentication({
  44. "onLogin": layout.load.bind(layout)
  45. });
  46. var returnValue = true;
  47. this.authentication.isAuthenticated(function(json){
  48. this.user = json.data;
  49. layout.session.user = json.data;
  50. }.bind(this), function(){
  51. this.authentication.loadLogin(this.node);
  52. returnValue = false;
  53. }.bind(this));
  54. return returnValue;
  55. };
  56. layout.notice = function(content, type, target, where, offset){
  57. if (!where) where = {"x": "right", "y": "top"};
  58. if (!target) target = this.content;
  59. if (!type) type = "ok";
  60. var noticeTarget = target || $(document.body);
  61. var off = offset;
  62. if (!off){
  63. off = {
  64. x: 10,
  65. y: where.y.toString().toLowerCase()=="bottom" ? 10 : 10
  66. };
  67. }
  68. new mBox.Notice({
  69. type: type,
  70. position: where,
  71. move: false,
  72. target: noticeTarget,
  73. delayClose: (type=="error") ? 10000 : 5000,
  74. offset: off,
  75. content: content
  76. });
  77. };
  78. MWF.getJSON("res/config/config.json", function(config){
  79. layout.config = config;
  80. MWF.xDesktop.getServiceAddress(layout.config, function(service, center){
  81. layout.serviceAddressList = service;
  82. layout.centerServer = center;
  83. layout.load();
  84. }.bind(this));
  85. //layout.getServiceAddress(function(){
  86. // layout.load();
  87. //});
  88. });
  89. })();
  90. });
  91. });
  92. });