Base.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace app\Admin\controller;
  3. use think\Db;
  4. class Base
  5. {
  6. public $post="";
  7. public $userinfo="";
  8. public function __construct()
  9. {
  10. if(request()->isOptions()){
  11. echo '';
  12. die();
  13. }
  14. $post=request()->post();
  15. $token = isset($post['token']) && $post['token']!=""?$post['token']:"";
  16. if($token==""){
  17. return error_show(104,"参数token 不能为空");
  18. }
  19. $verify = verifyToken($token);
  20. if($verify['code']!=0){
  21. return error_show($verify['code'],$verify['msg']);
  22. }
  23. $tokeninfo = Db::name("admin_token")->where(["token"=>$token])->find();
  24. if(!isset($tokeninfo['adminid'])){
  25. return error_show(1004,"未找到账户id");
  26. }
  27. $userinfo = Db::name("admin")->where(["id"=>$tokeninfo['adminid']])->find();
  28. if(empty($userinfo)){
  29. return error_show(1004,"未找到账户数据");
  30. }
  31. $this->userinfo=$userinfo;
  32. $this->post=$post;
  33. }
  34. }