ddsso.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. var redirect = uri.getData("redirect");
  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. if (redirect){
  58. redirect.toURI().go();
  59. }else{
  60. "appMobile.html?app=process.TaskCenter".toURI().go();
  61. }
  62. }.bind(this), "failure": function(xhr, text, error){
  63. "appMobile.html?app=process.TaskCenter".toURI().go();
  64. }.bind(this)});
  65. }.bind(this),
  66. onFail : function(err) {}
  67. });
  68. }.bind(this), "failure": function(xhr, text, error){}.bind(this)});
  69. });
  70. };
  71. layout.isAuthentication = function(){
  72. layout.authentication = new MWF.xDesktop.Authentication({
  73. "onLogin": layout.load.bind(layout)
  74. });
  75. var returnValue = true;
  76. this.authentication.isAuthenticated(function(json){
  77. this.user = json.data;
  78. layout.session.user = json.data;
  79. }.bind(this), function(){
  80. this.authentication.loadLogin(this.node);
  81. returnValue = false;
  82. }.bind(this));
  83. return returnValue;
  84. };
  85. layout.notice = function(content, type, target, where, offset){
  86. if (!where) where = {"x": "right", "y": "top"};
  87. if (!target) target = this.content;
  88. if (!type) type = "ok";
  89. var noticeTarget = target || $(document.body);
  90. var off = offset;
  91. if (!off){
  92. off = {
  93. x: 10,
  94. y: where.y.toString().toLowerCase()=="bottom" ? 10 : 10
  95. };
  96. }
  97. new mBox.Notice({
  98. type: type,
  99. position: where,
  100. move: false,
  101. target: noticeTarget,
  102. delayClose: (type=="error") ? 10000 : 5000,
  103. offset: off,
  104. content: content
  105. });
  106. };
  107. MWF.getJSON("res/config/config.json", function(config){
  108. layout.config = config;
  109. MWF.xDesktop.getServiceAddress(layout.config, function(service, center){
  110. layout.serviceAddressList = service;
  111. layout.centerServer = center;
  112. layout.load();
  113. }.bind(this));
  114. //layout.getServiceAddress(function(){
  115. // layout.load();
  116. //});
  117. });
  118. })();
  119. });
  120. });
  121. });