SystemBasic.php 2.9 KB

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