Main.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. MWF.xApplication.Weixin.Main = new Class({
  2. Extends: MWF.xApplication.Common.Main,
  3. Implements: [Options, Events],
  4. options: {
  5. "style": "default",
  6. "name": "Weixin",
  7. "icon": "icon.png",
  8. "width": "1200",
  9. "height": "630",
  10. "title": MWF.xApplication.Weixin.LP.title
  11. },
  12. onQueryLoad: function(){
  13. this.lp = MWF.xApplication.Weixin.LP;
  14. },
  15. loadApplication: function(callback){
  16. this.createNode();
  17. this.loadApplicationContent();
  18. if (callback) callback();
  19. },
  20. createNode: function(){
  21. this.content.setStyle("overflow", "hidden");
  22. this.node = new Element("div", {
  23. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  24. }).inject(this.content);
  25. },
  26. loadApplicationContent: function(){
  27. this.contentNode = new Element("div", {
  28. "styles": {
  29. "margin": "30px",
  30. "overflow": "hidden",
  31. "font-size": "18px"
  32. }
  33. }).inject(this.node);
  34. var html = "<table width='90%' align='center'><tr>" +
  35. "<td width='100px'>发送给</td><td><input style='width:100%' type='text' id='sendTo'/></td><td rowspan='3' style='width:160px' VALIGN='top'>" +
  36. "<img src='"+this.path+this.options.style+"/icon/zone.png"+"'/><p style='font-size: 14px; text-align:center'>微信扫描二维码<br>关注兰德纵横企业微信</p></td></tr><tr>" +
  37. "<td width='100px'>标 题</td><td><input style='width:100%' type='text' id='subject'/></td></tr><tr>" +
  38. "<td width='100px'>内 容</td><td id='contentArea'></td></tr></table>";
  39. this.contentNode.set("html", html);
  40. this.contentAreaNode = this.node.getElement("#contentArea");
  41. this.loadCkeditor();
  42. this.actionNode = new Element("div", {
  43. "styles": {
  44. "width": "220px",
  45. "margin":"auto",
  46. "overflow": "hidden",
  47. "font-size": "14px"
  48. }
  49. }).inject(this.node);
  50. this.button = new Element("button", {
  51. "text": "通过微信发送公告",
  52. "styles": {
  53. "margin": "auto",
  54. "width": "220px",
  55. "height": "40px",
  56. "font-size": "16px",
  57. "cursor": "pointer",
  58. "background-color": "#7285bb",
  59. "border": "1px solid #666",
  60. "color": "#FFF"
  61. },
  62. "events": {
  63. "click": function(){
  64. var user = this.node.getElement("#sendTo").get("value");
  65. var title = this.node.getElement("#subject").get("value");
  66. // var content = this.node.getElement("#content").get("value");
  67. // alert(this.editor.getData());
  68. var json = {
  69. "appId":"xbpm",
  70. "appPwd":"zone2009",
  71. "toUsers":user,
  72. "msgType":"5",
  73. "title":title,
  74. "busType":"通知公告",
  75. "content":this.editor.getData(),
  76. "sendDate":new Date().format("db")
  77. };
  78. var myRequest = new Request({
  79. url:"http://mvn.zoneland.net/wx/api/rest/sendmsg",
  80. method:"post",
  81. // data:{"json":jsonStr},
  82. success:function(data){
  83. this.notice("信息已发送", "success", this.appContentNode);
  84. }.bind(this)
  85. // onProgress: function(event, xhr){
  86. // var loaded = event.loaded, total = event.total;
  87. //
  88. // console.log(parseInt(loaded / total * 100, 10));
  89. // }
  90. });
  91. myRequest.send("json="+JSON.encode(json));
  92. }.bind(this)
  93. }
  94. }).inject(this.actionNode);
  95. },
  96. loadCkeditor: function(config){
  97. COMMON.AjaxModule.load("ckeditor", function(){
  98. // var editorDiv = new Element("div").inject(this.node);
  99. // var height = this.node.getSize().y;
  100. var editorConfig = {};
  101. this.editor = CKEDITOR.appendTo(this.contentAreaNode, editorConfig);
  102. // this.editor.on("loaded", function(){
  103. // this.editor.setReadOnly(true);
  104. // }, this);
  105. }.bind(this));
  106. }
  107. });