Base.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\inter\controller;
  3. use app\admin\library\Auth;
  4. use app\admin\model\Admin;
  5. use think\Controller;
  6. use think\Db;
  7. use think\Session;
  8. use think\Config;
  9. use think\Cookie;
  10. use think\Cache;
  11. use think\Log;
  12. use think\Request;
  13. class Base extends Controller
  14. {
  15. protected $logined = false; //登录状态
  16. /**
  17. * 无需登录的方法,同时也就不需要鉴权了
  18. * @var array
  19. */
  20. protected $noNeedLogin = [];
  21. public $sessionid;
  22. /**
  23. * 初始化操作
  24. */
  25. public function _initialize()
  26. {
  27. $sessionid = Request::instance()->param('sessionid');
  28. log::record($sessionid);
  29. log::record('-----------base 页面cache-------------');
  30. log::record($sessionid);
  31. log::record('------------------------');
  32. $admin = Cache::get($sessionid);
  33. if (!$admin) {
  34. die(json_encode(['status'=>'fail','code'=>'1010','msg'=>'对不起,您还未进行登录,请先登录']));
  35. // $this->error('对不起,您还未进行登录,请先登录','inter/index');
  36. }
  37. }
  38. public function _construct()
  39. {
  40. $request = Request::instance();
  41. if($request->method() == 'OPTIONS'){
  42. return;
  43. }
  44. }
  45. }