ddsso.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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.xDesktop.Layout", function(){
  13. MWF.require("MWF.xDesktop.Authentication", null, false);
  14. (function(){
  15. layout.load = function(){
  16. var uri = href.toURI();
  17. MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  18. var action = new MWF.xDesktop.Actions.RestActions("", "x_organization_assemble_authentication", "");
  19. action.getActions = function(actionCallback){
  20. this.actions = {
  21. "info": {"uri": "/jaxrs/dingding/info", "method":"POST"},
  22. "auth": {"uri": "/jaxrs/dingding/code/{code}"}
  23. };
  24. if (actionCallback) actionCallback();
  25. };
  26. action.invoke({"name": "info","async": true, "data": {"url": href},"success": function(json){
  27. var _config = json.data;
  28. //document.all.testaaa.set("value", "0");
  29. dd.config({
  30. agentId : _config.agentid,
  31. corpId : _config.corpId,
  32. timeStamp : _config.timeStamp,
  33. nonceStr : _config.nonceStr,
  34. signature : _config.signature,
  35. jsApiList : ['runtime.info']
  36. });
  37. dd.ready(function() {
  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. });
  64. }.bind(this), "failure": function(xhr, text, error){}.bind(this)});
  65. });
  66. };
  67. layout.isAuthentication = function(){
  68. layout.authentication = new MWF.xDesktop.Authentication({
  69. "onLogin": layout.load.bind(layout)
  70. });
  71. var returnValue = true;
  72. this.authentication.isAuthenticated(function(json){
  73. this.user = json.data;
  74. layout.session.user = json.data;
  75. }.bind(this), function(){
  76. this.authentication.loadLogin(this.node);
  77. returnValue = false;
  78. }.bind(this));
  79. return returnValue;
  80. };
  81. layout.notice = function(content, type, target, where, offset){
  82. if (!where) where = {"x": "right", "y": "top"};
  83. if (!target) target = this.content;
  84. if (!type) type = "ok";
  85. var noticeTarget = target || $(document.body);
  86. var off = offset;
  87. if (!off){
  88. off = {
  89. x: 10,
  90. y: where.y.toString().toLowerCase()=="bottom" ? 10 : 10
  91. };
  92. }
  93. new mBox.Notice({
  94. type: type,
  95. position: where,
  96. move: false,
  97. target: noticeTarget,
  98. delayClose: (type=="error") ? 10000 : 5000,
  99. offset: off,
  100. content: content
  101. });
  102. };
  103. MWF.getJSON("res/config/config.json", function(config){
  104. layout.config = config;
  105. MWF.xDesktop.getServiceAddress(layout.config, function(service, center){
  106. layout.serviceAddressList = service;
  107. layout.centerServer = center;
  108. layout.load();
  109. }.bind(this));
  110. //layout.getServiceAddress(function(){
  111. // layout.load();
  112. //});
  113. });
  114. })();
  115. });
  116. });
  117. });