AuthController.php 639 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/12/11
  6. */
  7. namespace app\routine\controller;
  8. use app\routine\model\user\User;
  9. use service\JsonService;
  10. use think\Controller;
  11. use think\Request;
  12. use think\Session;
  13. class AuthController extends Controller
  14. {
  15. public $userInfo = [];
  16. protected function _initialize()
  17. {
  18. parent::_initialize();
  19. $uid = Request::instance()->get('uid',0);
  20. $userInfo = User::get($uid);
  21. if($userInfo) $userInfo->toArray();
  22. else return JsonService::fail('没有获取用户UID');
  23. $this->userInfo = $userInfo;//根据uid获取用户信息
  24. }
  25. }