Base.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  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. if(empty($userinfo)){
  25. return error_show(1004,"未找到账户数据");
  26. }
  27. $this->userinfo=$userinfo;
  28. }
  29. }