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.

71 lines
1.9 KiB

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