You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.7 KiB

7 years ago
7 years ago
7 years ago
  1. <?php
  2. namespace App\Http\Controllers\Weixin;
  3. use App\Http\Controllers\Controller;
  4. class CommonController extends Controller
  5. {
  6. public function __construct()
  7. {
  8. parent::__construct();
  9. }
  10. /**
  11. * 操作错误跳转的快捷方法
  12. * @access protected
  13. * @param string $msg 错误信息
  14. * @param string $url 页面跳转地址
  15. * @param mixed $time 当数字时指定跳转时间
  16. * @return void
  17. */
  18. public function error_jump($msg='', $url='', $time=3)
  19. {
  20. if ($url=='' && isset($_SERVER["HTTP_REFERER"]))
  21. {
  22. $url = $_SERVER["HTTP_REFERER"];
  23. }
  24. if(!headers_sent())
  25. {
  26. header("Location:".route('weixin_jump')."?error=$msg&url=$url&time=$time");
  27. exit();
  28. }
  29. else
  30. {
  31. $str = "<meta http-equiv='Refresh' content='URL=".route('weixin_jump')."?error=$msg&url=$url&time=$time"."'>";
  32. exit($str);
  33. }
  34. }
  35. /**
  36. * 操作成功跳转的快捷方法
  37. * @access protected
  38. * @param string $msg 提示信息
  39. * @param string $url 页面跳转地址
  40. * @param mixed $time 当数字时指定跳转时间
  41. * @return void
  42. */
  43. public function success_jump($msg='', $url='', $time=1)
  44. {
  45. if ($url=='' && isset($_SERVER["HTTP_REFERER"]))
  46. {
  47. $url = $_SERVER["HTTP_REFERER"];
  48. }
  49. if(!headers_sent())
  50. {
  51. header("Location:".route('weixin_jump')."?message=$msg&url=$url&time=$time");
  52. exit();
  53. }
  54. else
  55. {
  56. $str = "<meta http-equiv='Refresh' content='URL=".route('weixin_jump')."?message=$msg&url=$url&time=$time"."'>";
  57. exit($str);
  58. }
  59. }
  60. }