index.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. define(["jquery", "easy-admin", "echarts", "echarts-theme", "miniAdmin", "miniTheme", "miniTab", "swiper"], function ($, ea, echarts, undefined, miniAdmin, miniTheme, miniTab) {
  2. return {
  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. new Swiper('.mySwiper', {
  30. pagination: {
  31. el: '.swiper-pagination',
  32. clickable: true,
  33. },
  34. })
  35. /**
  36. * 查看公告信息
  37. **/
  38. $('body').on('click', '.layuimini-notice', function () {
  39. var title = $(this).children('.layuimini-notice-title').text(),
  40. noticeTime = $(this).children('.layuimini-notice-extra').text(),
  41. content = $(this).children('.layuimini-notice-content').html();
  42. var html = '<div style="padding:15px 20px; text-align:justify; line-height: 22px;border-bottom:1px solid #e2e2e2;background-color: #2f4056;color: #ffffff">\n' +
  43. '<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' +
  44. '<div style="font-size: 12px">' + content + '</div>\n' +
  45. '</div>\n';
  46. layer.open({
  47. type: 1,
  48. title: '系统公告' + '<span style="float: right;right: 1px;font-size: 12px;color: #b1b3b9;margin-top: 1px">' + noticeTime + '</span>',
  49. area: '300px;',
  50. shade: 0.8,
  51. id: 'layuimini-notice',
  52. btn: ['查看', '取消'],
  53. btnAlign: 'c',
  54. moveType: 1,
  55. content: html,
  56. success: function (layero) {
  57. var btn = layero.find('.layui-layer-btn');
  58. btn.find('.layui-layer-btn0').attr({
  59. href: 'https://gitee.com/zhongshaofa/layuimini',
  60. target: '_blank'
  61. });
  62. }
  63. });
  64. });
  65. /**
  66. * 报表功能
  67. */
  68. $(function () {
  69. $('#layui-version').text('v' + layui.v);
  70. let echartsRecords = echarts.init(document.getElementById('echarts-records'), 'walden');
  71. let optionRecords = {
  72. title: {
  73. text: '访问统计'
  74. },
  75. tooltip: {
  76. trigger: 'axis'
  77. },
  78. legend: {
  79. data: ['邮件营销', '联盟广告', '视频广告', '直接访问', '搜索引擎']
  80. },
  81. grid: {
  82. left: '3%',
  83. right: '4%',
  84. bottom: '3%',
  85. containLabel: true
  86. },
  87. toolbox: {
  88. feature: {
  89. saveAsImage: {}
  90. }
  91. },
  92. xAxis: {
  93. type: 'category',
  94. boundaryGap: false,
  95. data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
  96. },
  97. yAxis: {
  98. type: 'value'
  99. },
  100. series: [
  101. {
  102. name: '邮件营销',
  103. type: 'line',
  104. stack: '总量',
  105. data: [120, 132, 101, 134, 90, 230, 210]
  106. },
  107. {
  108. name: '联盟广告',
  109. type: 'line',
  110. stack: '总量',
  111. data: [220, 182, 191, 234, 290, 330, 310]
  112. },
  113. {
  114. name: '视频广告',
  115. type: 'line',
  116. stack: '总量',
  117. data: [150, 232, 201, 154, 190, 330, 410]
  118. },
  119. {
  120. name: '直接访问',
  121. type: 'line',
  122. stack: '总量',
  123. data: [320, 332, 301, 334, 390, 330, 320]
  124. },
  125. {
  126. name: '搜索引擎',
  127. type: 'line',
  128. stack: '总量',
  129. data: [820, 932, 901, 934, 1290, 1330, 1320]
  130. }
  131. ]
  132. };
  133. echartsRecords.setOption(optionRecords);
  134. window.addEventListener("resize", function () {
  135. echartsRecords.resize();
  136. });
  137. })
  138. let util = layui.util;
  139. util.on({
  140. showComposerInfo: function () {
  141. // <div style="padding: 25px;">12313</div>
  142. let html = ``
  143. ea.request.get({
  144. url: ea.url('ajax/composerInfo'),
  145. }, function (success) {
  146. let data = success.data
  147. data.forEach(function (item) {
  148. html += `${item.name} ${item.version}\r\n`
  149. })
  150. html = `<pre class="layui-code code-demo">${html}</pre>`
  151. layer.open({
  152. type: 1,
  153. title: 'composer 信息',
  154. area: ['50%', '90%'],
  155. shade: 0.8,
  156. shadeClose: true,
  157. scrollbar: false,
  158. content: html,
  159. success: function () {
  160. layui.code({elem: '.code-demo', theme: 'dark', lang: 'php'});
  161. }
  162. })
  163. }, function (error) {
  164. console.error(error)
  165. return false;
  166. })
  167. }
  168. })
  169. },
  170. editAdmin: function () {
  171. let form = layui.form
  172. form.on('radio(loginType-filter)', function (data) {
  173. let elem = data.elem
  174. let value = elem.value
  175. if (value === '2') {
  176. let width = screen.width < 768 ? '85%' : '60%'
  177. ea.open('绑定谷歌验证码', ea.url('index/set2fa'), width, '75%')
  178. }
  179. });
  180. ea.listen();
  181. },
  182. editPassword: function () {
  183. ea.listen();
  184. },
  185. set2fa: function () {
  186. ea.listen();
  187. },
  188. };
  189. });