Controller.class.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace Cas\Controller;
  3. use KIF\Cookie;
  4. class Controller extends \KIF\Core\WXController {
  5. public function run() {
  6. $action = $this->action;
  7. $this->$action();
  8. if (self::getUid()) {
  9. // $objWeixinUser = new WeixinUser();
  10. // $user = $objWeixinUser->get(self::getUid());
  11. // if ($user['status'] == 1) {
  12. // $this->setOutput('IS_FOLLOW_WX', 1);
  13. // }
  14. // if ($user['fromsource'] == 'app') { //app中打开时,不显示“底部关注拦”
  15. // $this->setOutput('IS_FOLLOW_WX', 1);
  16. // }
  17. }
  18. // 来源是否是app
  19. define('FROMSOURCE_APP', 'true');
  20. $tmPassortCookie = Cookie::get('TM_PASSPORT_MEMBER');
  21. if(strstr($tmPassortCookie, 'fromsource=app')){
  22. if (!defined('FROMSOURCE_APP')) define('FROMSOURCE_APP', 'true');
  23. }
  24. }
  25. /**
  26. *
  27. * 错误消息
  28. * @param unknown $msg 错误内容
  29. * @param unknown $back_text 文案。如“返回”
  30. * @param unknown $back_url 文案链接
  31. */
  32. public function fail_exit($msg, $back_text = null, $back_url = null) {
  33. $this->tpl = 'error';
  34. $this->setOutput('title', '错误消息');
  35. $this->setOutput('data', array(
  36. 'msg' => $msg,
  37. 'back_text' => $back_text ? $back_text : '返回',
  38. 'back_url' => $back_url ? $back_url : $_SERVER['HTTP_REFERER'],
  39. ));
  40. $this->setOutput('error', 1);
  41. $this->render();exit;
  42. }
  43. /**
  44. *
  45. * 授权错误
  46. * @param unknown $msg
  47. */
  48. public function fail_exit_oauth($msg) {
  49. $this->tpl = 'error';
  50. $this->setOutput('title', '授权失败');
  51. $this->setOutput('data', array(
  52. 'msg' => $msg,
  53. ));
  54. $this->setOutput('error', 2);
  55. $this->render();exit;
  56. }
  57. /**
  58. *
  59. * 404页
  60. * @param unknown $msg
  61. */
  62. public function echo_404() {
  63. $this->tpl = 'error';
  64. $this->setOutput('title', '404');
  65. $this->setOutput('error', 3);
  66. $this->render();exit;
  67. }
  68. }