SystemBasic.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace app\admin\controller;
  3. use crmeb\services\JsonService;
  4. use crmeb\basic\BaseController;
  5. class SystemBasic extends BaseController
  6. {
  7. /**
  8. * 操作失败提示框
  9. * @param string $msg 提示信息
  10. * @param string $backUrl 跳转地址
  11. * @param string $title 标题
  12. * @param int $duration 持续时间
  13. * @return mixed
  14. */
  15. protected function failedNotice($msg = '操作失败', $backUrl = 0, $info = '', $duration = 3)
  16. {
  17. $type = 'error';
  18. $this->assign(compact('msg', 'backUrl', 'info', 'duration', 'type'));
  19. return $this->fetch('public/notice');
  20. }
  21. /**
  22. * 失败提示一直持续
  23. * @param $msg
  24. * @param int $backUrl
  25. * @param string $title
  26. * @return mixed
  27. */
  28. protected function failedNoticeLast($msg = '操作失败', $backUrl = 0, $info = '')
  29. {
  30. return $this->failedNotice($msg, $backUrl, $info, 0);
  31. }
  32. /**
  33. * 操作成功提示框
  34. * @param string $msg 提示信息
  35. * @param string $backUrl 跳转地址
  36. * @param string $title 标题
  37. * @param int $duration 持续时间
  38. * @return mixed
  39. */
  40. protected function successfulNotice($msg = '操作成功', $backUrl = 0, $info = '', $duration = 3)
  41. {
  42. $type = 'success';
  43. $this->assign(compact('msg', 'backUrl', 'info', 'duration', 'type'));
  44. return $this->fetch('public/notice');
  45. }
  46. /**
  47. * 成功提示一直持续
  48. * @param $msg
  49. * @param int $backUrl
  50. * @param string $title
  51. * @return mixed
  52. */
  53. protected function successfulNoticeLast($msg = '操作成功', $backUrl = 0, $info = '')
  54. {
  55. return $this->successfulNotice($msg, $backUrl, $info, 0);
  56. }
  57. /**
  58. * 错误提醒页面
  59. * @param string $msg
  60. * @param int $url
  61. */
  62. protected function failed($msg = '哎呀…亲…您访问的页面出现错误', $url = 0)
  63. {
  64. if ($this->request->isAjax()) {
  65. exit(JsonService::fail($msg, $url)->getContent());
  66. } else {
  67. $this->assign(compact('msg', 'url'));
  68. exit($this->fetch('public/error'));
  69. }
  70. }
  71. /**
  72. * 成功提醒页面
  73. * @param string $msg
  74. * @param int $url
  75. */
  76. protected function successful($msg, $url = 0)
  77. {
  78. if ($this->request->isAjax()) {
  79. exit(JsonService::successful($msg, $url)->getContent());
  80. } else {
  81. $this->assign(compact('msg', 'url'));
  82. exit($this->fetch('public/success'));
  83. }
  84. }
  85. /**异常抛出
  86. * @param $name
  87. */
  88. protected function exception($msg = '无法打开页面')
  89. {
  90. $this->assign(compact('msg'));
  91. exit($this->fetch('public/exception'));
  92. }
  93. /**找不到页面
  94. * @param $name
  95. */
  96. public function _empty($name)
  97. {
  98. exit($this->fetch('public/404'));
  99. }
  100. }