Base.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. if(request()->isOptions()){
  11. echo '';
  12. die();
  13. }
  14. $this->post=request()->post();
  15. $token = isset($this->post['token'])&&$this->post['token']!="" ? trim($this->post['token']):"";
  16. if($token==""){
  17. return error_show(102,"token不能为空");
  18. }
  19. $verify = verifyToken($token);
  20. if($verify['code']!=0){
  21. return error_show($verify['code'],$verify['msg']);
  22. }
  23. $tokeninfo = Db::name("account_token")->where(["token"=>$token])->find();
  24. if(!isset($tokeninfo['accountid'])){
  25. return error_show(1004,"未找到账户id");
  26. }
  27. $userinfo = Db::name("account")->alias('a')->where(["a.id"=>$tokeninfo['accountid'],'a.is_del'=>0])
  28. ->join("fc_rela_account b", "a.id = b.accountid", "left")
  29. ->join("fc_account_info c", "b.account_info= c.id", "left")
  30. ->field("`a`.`id` AS `id`,
  31. `a`.`username` AS `username`,
  32. `a`.`account_type` AS `type`,
  33. `a`.`status` AS `status`,
  34. `a`.`is_del` AS `is_del`,
  35. `a`.`starttime` AS `starttime`,
  36. `a`.`expiretime` AS `expiretime`,
  37. `a`.`activetime` AS `activetime`,
  38. `a`.`addtime` AS `addtime`,
  39. `c`.`nickname` AS `nickname`,
  40. `c`.`avatar` AS `avatar`,
  41. `c`.`mobile` AS `mobile`,
  42. `c`.`remark` AS `remark`,
  43. `c`.`sex` AS `sex`")
  44. ->find();
  45. if(empty($userinfo)){
  46. return error_show(1004,"未找到账户数据");
  47. }
  48. $this->userinfo=$userinfo;
  49. }
  50. }