SystemBasic.php 2.8 KB

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