Base.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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`.`password` AS `password`,
  33. `a`.`salt` AS `salt`,
  34. `a`.`status` AS `status`,
  35. `a`.`is_del` AS `is_del`,
  36. `a`.`starttime` AS `starttime`,
  37. `a`.`expiretime` AS `expiretime`,
  38. `a`.`activetime` AS `activetime`,
  39. `a`.`addtime` AS `addtime`,
  40. `c`.`nickname` AS `nickname`,
  41. `c`.`avatar` AS `avatar`,
  42. `c`.`mobile` AS `mobile`,
  43. `c`.`remark` AS `remark`,
  44. `c`.`sex` AS `sex`")
  45. ->find();
  46. if(empty($userinfo)){
  47. return error_show(1004,"未找到账户数据");
  48. }
  49. $this->userinfo=$userinfo;
  50. }
  51. }