index.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. define(['jquery', 'form'], function($, Form) {
  2. var Controller = {
  3. index: function() {
  4. require(['pearAdmin'], function(pearAdmin) {
  5. pearAdmin.render({
  6. "menu": {
  7. "data": Yzn.api.fixurl("index/index"),
  8. "method": "POST",
  9. "accordion": true, // 是否开启手风琴效果
  10. "collapse": false, // 菜单是否默认收缩(折叠)
  11. "control": false, // 菜单模式: false为常规菜单,true为多系统菜单
  12. "select": 0,
  13. "async": true
  14. },
  15. "tab": {
  16. "enable": true, // 是否启用标签页功能
  17. "keepState": true,
  18. "session": true,
  19. "preload": true,
  20. "max": "10", // 最大允许打开的标签页数量
  21. "index": {
  22. "id": 0,
  23. "href": Yzn.api.fixurl("main/index"),
  24. "title": "控制台"
  25. }
  26. },
  27. "theme": {
  28. "defaultColor": "2",
  29. "defaultMenu": "dark-theme",
  30. "defaultHeader": "light-theme",
  31. "allowCustom": true,
  32. "banner": false
  33. },
  34. "colors": [
  35. { "id": "1", "color": "#2d8cf0", "second": "#ecf5ff" },
  36. { "id": "2", "color": "#36b368", "second": "#f0f9eb" },
  37. { "id": "3", "color": "#f6ad55", "second": "#fdf6ec" },
  38. { "id": "4", "color": "#f56c6c", "second": "#fef0f0" },
  39. { "id": "5", "color": "#3963bc", "second": "#ecf5ff" }
  40. ],
  41. "other": {
  42. "keepLoad": "1200",
  43. "autoHead": false,
  44. "footer": false
  45. }
  46. });
  47. // 登出逻辑
  48. pearAdmin.logout(function() {
  49. location.href = Yzn.api.fixurl("index/logout");
  50. // 注销逻辑 返回 true / false
  51. return true;
  52. })
  53. //清除缓存
  54. $('body').on('click', "dl#deletecache dd a", function() {
  55. $.ajax({
  56. url: Yzn.api.fixurl("index/cache"),
  57. dataType: 'json',
  58. data: { type: $(this).data("type") },
  59. cache: false,
  60. success: function(ret) {
  61. var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
  62. if (ret.code == 1) {
  63. var index = layer.msg('清除缓存中,请稍候', { icon: 16, time: false, shade: 0.8 });
  64. setTimeout(function() {
  65. layer.close(index);
  66. Toastr.success(msg ? msg : "缓存清除成功!");
  67. }, 1000);
  68. } else {
  69. Toastr.error(msg ? msg : '清除缓存失败');
  70. }
  71. },
  72. error: function() {
  73. Toastr.error(msg ? msg : '清除缓存失败');
  74. }
  75. });
  76. });
  77. window.pearAdmin = pearAdmin;
  78. })
  79. },
  80. login: function() {
  81. //让错误提示框居中
  82. Yzn.config.toastr.positionClass = "toast-top-center";
  83. Form.api.bindevent($(".layui-form"), function(data, res) {
  84. layer.msg('登入成功', {
  85. offset: '15px',
  86. icon: 1,
  87. time: 1000
  88. }, function() {
  89. window.location.href = Backend.api.fixurl(res.url);
  90. });
  91. return false;
  92. }, function(res) {
  93. $("#verify").click();
  94. });
  95. //刷新验证码
  96. $("#verify").click(function() {
  97. var verifyimg = $("#verify").attr("src");
  98. $("#verify").attr("src", verifyimg.replace(/\?.*$/, '') + '?' + Math.random());
  99. });
  100. }
  101. };
  102. return Controller;
  103. });