index.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. define(["jquery", "easy-admin", "echarts", "echarts-theme", "miniAdmin", "miniTab"], function ($, ea, echarts, undefined, miniAdmin, miniTab) {
  2. var Controller = {
  3. index: function () {
  4. var options = {
  5. iniUrl: ea.url('ajax/initAdmin'), // 初始化接口
  6. clearUrl: ea.url("ajax/clearCache"), // 缓存清理接口
  7. urlHashLocation: true, // 是否打开hash定位
  8. bgColorDefault: false, // 主题默认配置
  9. multiModule: true, // 是否开启多模块
  10. menuChildOpen: false, // 是否默认展开菜单
  11. loadingTime: 0, // 初始化加载时间
  12. pageAnim: true, // iframe窗口动画
  13. maxTabNum: 20, // 最大的tab打开数量
  14. };
  15. miniAdmin.render(options);
  16. $('.login-out').on("click", function () {
  17. ea.request.get({
  18. url: 'login/out',
  19. prefix: true,
  20. }, function (res) {
  21. ea.msg.success(res.msg, function () {
  22. window.location = ea.url('login/index');
  23. })
  24. });
  25. });
  26. },
  27. welcome: function () {
  28. miniTab.listen();
  29. /**
  30. * 查看公告信息
  31. **/
  32. $('body').on('click', '.layuimini-notice', function () {
  33. var title = $(this).children('.layuimini-notice-title').text(),
  34. noticeTime = $(this).children('.layuimini-notice-extra').text(),
  35. content = $(this).children('.layuimini-notice-content').html();
  36. var html = '<div style="padding:15px 20px; text-align:justify; line-height: 22px;border-bottom:1px solid #e2e2e2;background-color: #2f4056;color: #ffffff">\n' +
  37. '<div style="text-align: center;margin-bottom: 20px;font-weight: bold;border-bottom:1px solid #718fb5;padding-bottom: 5px"><h4 class="text-danger">' + title + '</h4></div>\n' +
  38. '<div style="font-size: 12px">' + content + '</div>\n' +
  39. '</div>\n';
  40. layer.open({
  41. type: 1,
  42. title: '系统公告' + '<span style="float: right;right: 1px;font-size: 12px;color: #b1b3b9;margin-top: 1px">' + noticeTime + '</span>',
  43. area: '300px;',
  44. shade: 0.8,
  45. id: 'layuimini-notice',
  46. btn: ['查看', '取消'],
  47. btnAlign: 'c',
  48. moveType: 1,
  49. content: html,
  50. success: function (layero) {
  51. var btn = layero.find('.layui-layer-btn');
  52. btn.find('.layui-layer-btn0').attr({
  53. href: '#',
  54. target: '_blank'
  55. });
  56. }
  57. });
  58. });
  59. /**
  60. * 报表功能
  61. */
  62. var echartsRecords = echarts.init(document.getElementById('echarts-records'), 'walden');
  63. var optionRecords = {
  64. title: {
  65. text: '访问统计'
  66. },
  67. tooltip: {
  68. trigger: 'axis'
  69. },
  70. legend: {
  71. data: ['邮件营销', '联盟广告', '视频广告', '直接访问', '搜索引擎']
  72. },
  73. grid: {
  74. left: '3%',
  75. right: '4%',
  76. bottom: '3%',
  77. containLabel: true
  78. },
  79. toolbox: {
  80. feature: {
  81. saveAsImage: {}
  82. }
  83. },
  84. xAxis: {
  85. type: 'category',
  86. boundaryGap: false,
  87. data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
  88. },
  89. yAxis: {
  90. type: 'value'
  91. },
  92. series: [
  93. {
  94. name: '邮件营销',
  95. type: 'line',
  96. stack: '总量',
  97. data: [120, 132, 101, 134, 90, 230, 210]
  98. },
  99. {
  100. name: '联盟广告',
  101. type: 'line',
  102. stack: '总量',
  103. data: [220, 182, 191, 234, 290, 330, 310]
  104. },
  105. {
  106. name: '视频广告',
  107. type: 'line',
  108. stack: '总量',
  109. data: [150, 232, 201, 154, 190, 330, 410]
  110. },
  111. {
  112. name: '直接访问',
  113. type: 'line',
  114. stack: '总量',
  115. data: [320, 332, 301, 334, 390, 330, 320]
  116. },
  117. {
  118. name: '搜索引擎',
  119. type: 'line',
  120. stack: '总量',
  121. data: [820, 932, 901, 934, 1290, 1330, 1320]
  122. }
  123. ]
  124. };
  125. echartsRecords.setOption(optionRecords);
  126. window.addEventListener("resize", function () {
  127. echartsRecords.resize();
  128. });
  129. },
  130. editAdmin: function () {
  131. ea.listen();
  132. },
  133. editPassword: function () {
  134. ea.listen();
  135. }
  136. };
  137. return Controller;
  138. });