Base.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\Home\controller;
  3. use think\Db;
  4. class Base
  5. {
  6. public $post="";
  7. public $userinfo="";
  8. public function __construct()
  9. {
  10. $this->post=request()->post();
  11. $token = isset($this->post['token'])&&$this->post['token']!="" ? trim($this->post['token']):"";
  12. if($token==""){
  13. return error_show(102,"token不能为空");
  14. }
  15. $verify = verifyToken($token);
  16. if($verify['code']!=0){
  17. return error_show($verify['code'],$verify['msg']);
  18. }
  19. $tokeninfo = Db::name("account_token")->where(["token"=>$token])->find();
  20. if(!isset($tokeninfo['accountid'])){
  21. return error_show(1004,"未找到账户id");
  22. }
  23. $userinfo = Db::name("account_list")->where(["id"=>$tokeninfo['accountid']])->field("id,username,status,starttime,expiretime,activetime,addtime,nickname,avatar,mobile,remark")->find();
  24. //var_dump($userinfo);
  25. if(empty($userinfo)){
  26. return error_show(1004,"未找到账户数据");
  27. }
  28. $this->userinfo=$userinfo;
  29. }
  30. }