From f9d9a1bf5cb635ac90fda08880bc1546795db6e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Tue, 12 Aug 2025 11:16:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/model/UserToken.php | 6 +++--- application/common/controller/BaseCom.php | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/application/api/model/UserToken.php b/application/api/model/UserToken.php index c8efa95..e520885 100644 --- a/application/api/model/UserToken.php +++ b/application/api/model/UserToken.php @@ -10,14 +10,14 @@ class UserToken extends Model public function check_login_token($token) { if (empty($token)) { - return ['code' => 301, 'msg' => '登录失效', 'data' =>null]; + return ['code' => 301, 'msg' => '登录失效!', 'data' =>null]; } $user_token = $this->where('token', $token)->find(); if (empty($user_token)) { - return ['code' => 301, 'msg' => '登录失效', 'data' => null]; + return ['code' => 301, 'msg' => '登录失效!!', 'data' => null]; } if ($user_token['expiretime'] < time()) { - return ['code' => 301, 'msg'=> '登录失效', 'data' => null]; + return ['code' => 301, 'msg'=> '登录失效!!!', 'data' => null]; } $block1 = db::name('block')->where(['type' => 1,'type_text' => $user_token['user_id']])->find(); diff --git a/application/common/controller/BaseCom.php b/application/common/controller/BaseCom.php index cd95e6a..b4279c3 100644 --- a/application/common/controller/BaseCom.php +++ b/application/common/controller/BaseCom.php @@ -20,7 +20,6 @@ class BaseCom extends Controller header("Access-Control-Max-Age: 3600"); //检测系统是否维护中 -// $config = get_system_config(); $is_maintenance = get_system_config_value('is_maintenance'); if($is_maintenance == 2){ return V(203, '系统维护中'); @@ -42,9 +41,9 @@ class BaseCom extends Controller //定义一个常量 define('UID', $this->uid); }else{ - $token = input('token', ''); + $token = request()->header('token'); if (empty($token)) { - $token = request()->header('token'); + $token = input('token', ''); if(empty($token)){ return V(301, '登录失效'); } From a3b3bd04ef684ee93a6f9dc7d09a2ab5944a9901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Tue, 12 Aug 2025 14:05:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/controller/BaseCom.php | 29 ++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/application/common/controller/BaseCom.php b/application/common/controller/BaseCom.php index b4279c3..f588969 100644 --- a/application/common/controller/BaseCom.php +++ b/application/common/controller/BaseCom.php @@ -36,10 +36,33 @@ class BaseCom extends Controller } $zhenshi_version = db::name('version')->where('type', 2)->value('oldversion'); $result = version_compare($version,$zhenshi_version); + //请求的接口 + $api = request()->controller().'/'.request()->action(); if($system == 'iOS' && $result > 0){ - $this->uid = 0; - //定义一个常量 - define('UID', $this->uid); + if($api == 'Index/index_banner' || $api == 'Index/room_type_list' || $api == 'Index/room_list' || $api == 'UserZone/expand_zone' || $api == 'UserZone/zone_list' || $api == 'UserZone/topic_list' || $api == 'UserZone/get_zone_topic'){ + $this->uid = 0; + //定义一个常量 + define('UID', $this->uid); + }else{ + $token = request()->header('token'); + if (empty($token)) { + $token = input('token', ''); + if(empty($token)){ + return V(301, '登录失效'); + } + } + + $reslut = model('UserToken')->check_login_token($token); + if($reslut['code'] != 1) { + model('UserToken')->where('token', $token)->update(['token' => 1]); + return V($reslut['code'], $reslut['msg'],$reslut['data']); + } else { + $this->uid = $reslut['data']; + //定义一个常量 + define('UID', $this->uid); + } + } + }else{ $token = request()->header('token'); if (empty($token)) {