ddsso.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. dd.ready(function() {
  9. o2.addReady(function(){
  10. o2.load(["../o2_lib/mootools/plugin/mBox.Notice.js", "../o2_lib/mootools/plugin/mBox.Tooltip.js"], {"sequence": true}, function(){
  11. //MWF.defaultPath = "/x_desktop"+MWF.defaultPath;
  12. MWF.loadLP("zh-cn");
  13. MWF.require("MWF.xDesktop.Layout", function(){
  14. MWF.require("MWF.xDesktop.Authentication", null, false);
  15. (function(){
  16. layout.load = function(){
  17. var uri = href.toURI();
  18. MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  19. var action = new MWF.xDesktop.Actions.RestActions("", "x_organization_assemble_authentication", "");
  20. action.getActions = function(actionCallback){
  21. this.actions = {
  22. "info": {"uri": "/jaxrs/dingding/info", "method":"POST"},
  23. "auth": {"uri": "/jaxrs/dingding/code/{code}"}
  24. };
  25. if (actionCallback) actionCallback();
  26. };
  27. action.invoke({"name": "info","async": true, "data": {"url": href},"success": function(json){
  28. var _config = json.data;
  29. //document.all.testaaa.set("value", "0");
  30. dd.config({
  31. agentId : _config.agentid,
  32. corpId : _config.corpId,
  33. timeStamp : _config.timeStamp,
  34. nonceStr : _config.nonceStr,
  35. signature : _config.signature,
  36. jsApiList : ['runtime.info']
  37. });
  38. //document.all.testaaa.set("value", "1");
  39. dd.biz.navigation.setTitle({
  40. title: ''
  41. });
  42. // dd.runtime.info({
  43. // onSuccess : function(info) {
  44. // logger.e('runtime info: ' + JSON.stringify(info));
  45. // },
  46. // onFail : function(err) {
  47. // logger.e('fail: ' + JSON.stringify(err));
  48. // }
  49. // });
  50. //document.all.testaaa.set("value", "before");
  51. dd.runtime.permission.requestAuthCode({
  52. corpId : _config.corpId,
  53. onSuccess : function(info) {
  54. action.invoke({"name": "auth","async": true, "parameter": {"code": info.code},"success": function(json){
  55. //document.all.testaaa.set("value", "auth");
  56. "appMobile.html?app=process.TaskCenter".toURI().go();
  57. }.bind(this), "failure": function(xhr, text, error){
  58. "appMobile.html?app=process.TaskCenter".toURI().go();
  59. }.bind(this)});
  60. }.bind(this),
  61. onFail : function(err) {}
  62. });
  63. }.bind(this), "failure": function(xhr, text, error){}.bind(this)});
  64. });
  65. };
  66. layout.isAuthentication = function(){
  67. layout.authentication = new MWF.xDesktop.Authentication({
  68. "onLogin": layout.load.bind(layout)
  69. });
  70. var returnValue = true;
  71. this.authentication.isAuthenticated(function(json){
  72. this.user = json.data;
  73. layout.session.user = json.data;
  74. }.bind(this), function(){
  75. this.authentication.loadLogin(this.node);
  76. returnValue = false;
  77. }.bind(this));
  78. return returnValue;
  79. };
  80. layout.notice = function(content, type, target, where, offset){
  81. if (!where) where = {"x": "right", "y": "top"};
  82. if (!target) target = this.content;
  83. if (!type) type = "ok";
  84. var noticeTarget = target || $(document.body);
  85. var off = offset;
  86. if (!off){
  87. off = {
  88. x: 10,
  89. y: where.y.toString().toLowerCase()=="bottom" ? 10 : 10
  90. };
  91. }
  92. new mBox.Notice({
  93. type: type,
  94. position: where,
  95. move: false,
  96. target: noticeTarget,
  97. delayClose: (type=="error") ? 10000 : 5000,
  98. offset: off,
  99. content: content
  100. });
  101. };
  102. MWF.getJSON("res/config/config.json", function(config){
  103. layout.config = config;
  104. MWF.xDesktop.getServiceAddress(layout.config, function(service, center){
  105. layout.serviceAddressList = service;
  106. layout.centerServer = center;
  107. layout.load();
  108. }.bind(this));
  109. //layout.getServiceAddress(function(){
  110. // layout.load();
  111. //});
  112. });
  113. })();
  114. });
  115. });
  116. });
  117. });