SystemBasic.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace basic;
  12. use service\JsonService;
  13. class SystemBasic extends \think\Controller
  14. {
  15. /**
  16. * 操作失败提示框
  17. * @param string $msg 提示信息
  18. * @param string $backUrl 跳转地址
  19. * @param string $title 标题
  20. * @param int $duration 持续时间
  21. * @return mixed
  22. */
  23. protected function failedNotice($msg = '操作失败', $backUrl = 0, $info = '', $duration = 3)
  24. {
  25. $type = 'error';
  26. $this->assign(compact('msg','backUrl','info','duration','type'));
  27. return $this->fetch('public/notice');
  28. }
  29. /**
  30. * 失败提示一直持续
  31. * @param $msg
  32. * @param int $backUrl
  33. * @param string $title
  34. * @return mixed
  35. */
  36. protected function failedNoticeLast($msg = '操作失败', $backUrl = 0, $info = '')
  37. {
  38. return $this->failedNotice($msg,$backUrl,$info,0);
  39. }
  40. /**
  41. * 操作成功提示框
  42. * @param string $msg 提示信息
  43. * @param string $backUrl 跳转地址
  44. * @param string $title 标题
  45. * @param int $duration 持续时间
  46. * @return mixed
  47. */
  48. protected function successfulNotice($msg = '操作成功',$backUrl = 0,$info = '',$duration = 3)
  49. {
  50. $type = 'success';
  51. $this->assign(compact('msg','backUrl','info','duration','type'));
  52. return $this->fetch('public/notice');
  53. }
  54. /**
  55. * 成功提示一直持续
  56. * @param $msg
  57. * @param int $backUrl
  58. * @param string $title
  59. * @return mixed
  60. */
  61. protected function successfulNoticeLast($msg = '操作成功',$backUrl = 0,$info = '')
  62. {
  63. return $this->successfulNotice($msg,$backUrl,$info,0);
  64. }
  65. /**
  66. * 错误提醒页面
  67. * @param string $msg
  68. * @param int $url
  69. */
  70. protected function failed($msg = '哎呀…亲…您访问的页面出现错误', $url = 0)
  71. {
  72. if($this->request->isAjax()){
  73. exit(JsonService::fail($msg,$url)->getContent());
  74. }else{
  75. $this->assign(compact('msg','url'));
  76. exit($this->fetch('public/error'));
  77. }
  78. }
  79. /**
  80. * 成功提醒页面
  81. * @param string $msg
  82. * @param int $url
  83. */
  84. protected function successful($msg, $url = 0)
  85. {
  86. if($this->request->isAjax()){
  87. exit(JsonService::successful($msg,$url)->getContent());
  88. }else{
  89. $this->assign(compact('msg','url'));
  90. exit($this->fetch('public/success'));
  91. }
  92. }
  93. protected function exception($msg = '无法打开页面')
  94. {
  95. $this->assign(compact('msg'));
  96. exit($this->fetch('public/exception'));
  97. }
  98. }