From c872994d0093de0e580e920f90b18c00da74da13 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Mon, 18 Mar 2024 09:50:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E7=89=88=E6=9C=AC=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/Auth.php | 31 +++++++++++++++++++++++++++++++ route/api.php | 1 + 2 files changed, 32 insertions(+) diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 5a329951..59aef1e3 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -980,4 +980,35 @@ class Auth extends BaseController + + //获取app版本更新信息 + public function appVersion() + { + $type = $this->request->param('type', '-1'); + // $version = $this->request->param('version', ''); + // $phoneBrand = $this->request->param('phone_brand', ''); + // $queryBuilder = Db::name('AppUpdate')->where('type', $type); + if ($type == 3) { + $android = (Db::name('AppUpdate')->where('type', 1)->where('phone_brand', '')->where('is_wget',0)->order('id', 'desc')->find()) ?? (object)[]; + $ios = (Db::name('AppUpdate')->where('type', 2)->where('phone_brand', '')->order('id', 'desc')->find()) ?? (object)[]; + return app('json')->success(compact('android', 'ios')); + } else { + $agent = strtolower($this->request->server('HTTP_USER_AGENT')); + // 检查是否为iOS设备,包括iPhone和iPad + if (strpos($agent, 'iphone') !== false || strpos($agent, 'ipad') !== false) { + $appInfo=[]; + } elseif (strpos($agent, 'android') !== false) { + // 检查是否为Android设备 + $appInfo = Db::name('AppUpdate')->where('type', $type)->order('id','desc')->find(); + } else { + $appInfo=[]; + // 如果都不是,则输出其他 + } + } + + return app('json')->success(compact('appInfo')); + } + + + } diff --git a/route/api.php b/route/api.php index c1e40416..9426eb65 100644 --- a/route/api.php +++ b/route/api.php @@ -28,6 +28,7 @@ Route::group('api/', function () { Route::get('business/agree', 'api.Auth/businessAgree'); Route::any('system_group_value', 'api.Common/system_group_value'); Route::get('category/list_level', 'api.server.StoreCategory/list_level'); + Route::any('app/version', 'api.Auth/appVersion'); //强制登录 Route::group(function () {