config.zml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <#--左边区域自定义块-->
  2. <#function zhiqim_manager_topnav_left_defined()>
  3. ${zhiqim_announcement_onload()}
  4. </#function>
  5. <#--公告加载-->
  6. <#function zhiqim_announcement_onload()>
  7. <script>
  8. var ws = null;
  9. var isClose = true;
  10. var num = 0;
  11. Z.onload(function()
  12. {
  13. /*
  14. //1.首次登录如果有公告的,要求立即提醒
  15. <#if sessionUser.getValue("zoa_announcement_close") != "true" && ZoaAnnouncementDao.hasUnReadAnnouncement(request)>
  16. top.Z.alert("有未读的公告,请进入阅读,谢谢!", doClose);
  17. </#if>
  18. //2.建立WS,新公告时提醒
  19. if (window.globalWebSocket)
  20. ws = globalWebSocket.connect((location.protocol=="https:"?"wss:":"ws:")+"//"+location.hostname+":"+location.port+"/service/ws", "zoa_announcement");
  21. else
  22. ws = new WebSocket((location.protocol=="https:"?"wss:":"ws:")+"//"+location.hostname+":"+location.port+"/service/ws", "zoa_announcement");
  23. ws.onopen = function(){console.log("ws.onopen");isClose=false;};
  24. ws.onclose = function(e){console.log("ws.onclose");isClose=true;};
  25. ws.onerror = function(e){console.log("ws.onerror");isClose=true;};
  26. ws.onmessage = function(e){console.log("ws.onmessage:"+e.data);if (e.data == "zoa_announcement_new"){top.Z.alert("有新的公告发布,请在方便的时候进入阅读,谢谢!");}};
  27. Z.timer(1000, 10, null, doSend);
  28. */
  29. });
  30. function doSend()
  31. {
  32. if (ws == null || ws.readyState == 2 || ws.readyState == 3)
  33. console.log("已关闭");
  34. else if (ws.readyState == 0)
  35. console.log("未开启");
  36. else
  37. {
  38. console.log("发送");
  39. ws.send("一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十");
  40. }
  41. num++;
  42. // if (num == 5)
  43. // ws.close();
  44. }
  45. function doClose()
  46. {
  47. var ajax = new Z.Ajax();
  48. ajax.setClassName("sessionUser");
  49. ajax.setMethodName("setValue");
  50. ajax.addParam("zoa_announcement_close")
  51. ajax.addParam("true");
  52. ajax.setSuccess(function(){Z.L.href("${context.getRootPath("/zhiqimAnnouncement/announcement.htm")}", window.mainFrame);});
  53. ajax.execute();
  54. }
  55. </script>
  56. </#function>