weixinsso.js 5.0 KB

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