weixinsso.js 4.9 KB

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