user = UserModel::where('id',$user_id)->hidden(['password','salt'])->find(); } $this->init(); View::assign('tab',$this->tab); View::assign('user',$this->user); } protected function init() { } protected function checkLogin() { $sessionUserId = session('home.user.id'); if (empty($sessionUserId)) { if (request()->isAjax()) { $res = ['code' => 401, 'msg' => '请登录']; $response = Response::create($res, 'json'); throw new HttpResponseException($response); } else { session('back_url',request()->url()); $response = redirect('/home/login/index'); throw new HttpResponseException($response); } } if (empty($this->user)) { jump('该用户已删除'); } if ($this->user['status'] != UserModel::STATUS_PASS) { jump('该账号暂时无法使用'); } } }