From cf09472af748aa4cc1ff7e06ee85bc51d940346d Mon Sep 17 00:00:00 2001 From: devil_gong Date: Wed, 27 Feb 2019 10:17:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E7=99=BB=E5=BD=95=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Common.php | 5 +---- application/index/controller/Common.php | 5 +++-- .../plugins/commonrightnavigation/Index.php | 5 +++-- .../usernotloginhidegoodsprice/Hook.php | 11 +++++++++-- application/service/UserService.php | 18 ++++++++++++++++++ 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/application/api/controller/Common.php b/application/api/controller/Common.php index de58b36f5..0b46a2bf6 100755 --- a/application/api/controller/Common.php +++ b/application/api/controller/Common.php @@ -119,10 +119,7 @@ class Common extends Controller private function CommonInit() { // 用户数据 - if(!empty($this->data_request['user_id'])) - { - $this->user = UserService::UserLoginRecord($this->data_request['user_id'], true); - } + $this->user = UserService::LoginUserInfo(); } /** diff --git a/application/index/controller/Common.php b/application/index/controller/Common.php index 1671373b0..613c887b3 100755 --- a/application/index/controller/Common.php +++ b/application/index/controller/Common.php @@ -19,6 +19,7 @@ use app\service\MessageService; use app\service\SearchService; use app\service\ConfigService; use app\service\LinkService; +use app\service\UserService; /** * 前端公共控制器 @@ -128,7 +129,7 @@ class Common extends Controller */ protected function IsLogin() { - if(session('user') == null) + if(empty($this->user)) { if(IS_AJAX) { @@ -151,7 +152,7 @@ class Common extends Controller // 用户数据 if(session('user') != null) { - $this->user = session('user'); + $this->user = UserService::LoginUserInfo(); } } diff --git a/application/plugins/commonrightnavigation/Index.php b/application/plugins/commonrightnavigation/Index.php index 1278047e8..3162f0a98 100644 --- a/application/plugins/commonrightnavigation/Index.php +++ b/application/plugins/commonrightnavigation/Index.php @@ -13,6 +13,7 @@ namespace app\plugins\commonrightnavigation; use think\Controller; use app\service\AnswerService; use app\service\BuyService; +use app\service\UserService; /** * 右侧快捷导航 - 前端 @@ -34,7 +35,7 @@ class Index extends Controller public function answer($params = []) { $params = input('post.'); - $params['user'] = session('user'); + $params['user'] = UserService::LoginUserInfo(); return AnswerService::Add($params); } @@ -57,7 +58,7 @@ class Index extends Controller $this->assign('module_controller_action', $module_name.$controller_name.$action_name); // 购物车 - $cart_list = BuyService::CartList(['user'=>session('user')]); + $cart_list = BuyService::CartList(['user'=>UserService::LoginUserInfo()]); // 基础数据 $base = [ diff --git a/application/plugins/usernotloginhidegoodsprice/Hook.php b/application/plugins/usernotloginhidegoodsprice/Hook.php index bf0796372..5711fbe48 100644 --- a/application/plugins/usernotloginhidegoodsprice/Hook.php +++ b/application/plugins/usernotloginhidegoodsprice/Hook.php @@ -12,6 +12,7 @@ namespace app\plugins\usernotloginhidegoodsprice; use think\Controller; use app\service\PluginsService; +use app\service\UserService; /** * 未登录隐藏商品价格 - 钩子入口 @@ -55,9 +56,15 @@ class Hook extends Controller } // 用户是否已登录 - if(session('user') != null) + $user = UserService::LoginUserInfo(); + if(!empty($user)) { - return DataReturn('无需处理', 0); + // 查询用户状态是否待审核状态 + $user = UserService::UserInfo('id', $user['id']); + if(isset($user['status']) && in_array($user['status'], [0,1])) + { + return DataReturn('无需处理', 0); + } } // 获取应用数据 diff --git a/application/service/UserService.php b/application/service/UserService.php index 9317a7855..3f955c864 100755 --- a/application/service/UserService.php +++ b/application/service/UserService.php @@ -23,6 +23,24 @@ use app\service\RegionService; */ class UserService { + /** + * 获取用户登录信息 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2019-02-27 + * @desc description + */ + public static function LoginUserInfo() + { + if(APPLICATION == 'web') + { + return session('user'); + } else { + $params = input(); + return empty($params['user_id']) ? null : self::UserLoginRecord($params['user_id'], true); + } + } /** * 用户列表 * @author Devil -- GitLab