ddsso.js 6.4 KB

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