更新判断
This commit is contained in:
parent
5940e5c6b6
commit
a63a444cb7
@ -1543,49 +1543,25 @@ class Auth extends BaseController
|
|||||||
//获取app版本更新信息
|
//获取app版本更新信息
|
||||||
public function appVersion()
|
public function appVersion()
|
||||||
{
|
{
|
||||||
$brandArray = [
|
|
||||||
'huawei',
|
|
||||||
'honor',
|
|
||||||
'iphone',
|
|
||||||
'samsung',
|
|
||||||
'xiaomi',
|
|
||||||
'redmi',
|
|
||||||
'mi',
|
|
||||||
'oppo',
|
|
||||||
'vivo',
|
|
||||||
'nokia',
|
|
||||||
'meizu',
|
|
||||||
'moto'
|
|
||||||
];
|
|
||||||
Log::info("请求版本参数:" . json_encode(request()->param()));
|
|
||||||
$type = $this->request->param('type', '-1');
|
$type = $this->request->param('type', '-1');
|
||||||
$version = $this->request->param('version', '');
|
// $version = $this->request->param('version', '');
|
||||||
$phoneBrand = $this->request->param('phone_brand', '');
|
// $phoneBrand = $this->request->param('phone_brand', '');
|
||||||
$queryBuilder = Db::name('AppUpdate')->where('type', $type);
|
// $queryBuilder = Db::name('AppUpdate')->where('type', $type);
|
||||||
if ($type == 3) {
|
if ($type == 3) {
|
||||||
$android = (Db::name('AppUpdate')->where('type', 1)->where('phone_brand', '')->order('id', 'desc')->find()) ?? (object)[];
|
$android = (Db::name('AppUpdate')->where('type', 1)->where('phone_brand', '')->order('id', 'desc')->find()) ?? (object)[];
|
||||||
$ios = (Db::name('AppUpdate')->where('type', 2)->where('phone_brand', '')->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'));
|
return app('json')->success(compact('android', 'ios'));
|
||||||
} else {
|
} else {
|
||||||
if ($version) {
|
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
|
||||||
$queryBuilder = $queryBuilder->where('version', '>', $version);
|
// 检查是否为iOS设备,包括iPhone和iPad
|
||||||
}
|
if (strpos($agent, 'iphone') !== false || strpos($agent, 'ipad') !== false) {
|
||||||
if ($phoneBrand) {
|
$appInfo=[];
|
||||||
$spos = false;
|
} elseif (strpos($agent, 'android') !== false) {
|
||||||
foreach ($brandArray as $b) {
|
// 检查是否为Android设备
|
||||||
$pos = stripos($phoneBrand, $b);
|
$appInfo = Db::name('AppUpdate')->where('type', $type)->order('id','desc')->find();
|
||||||
if ($pos !== false) {
|
} else {
|
||||||
$spos = true;
|
$appInfo=[];
|
||||||
$queryBuilder = $queryBuilder->where('phone_brand', $b);
|
// 如果都不是,则输出其他
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($spos === false) {
|
|
||||||
$queryBuilder = $queryBuilder->where('phone_brand', '');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$appInfo = $queryBuilder->order('version', 'desc')->fetchSql(false)->find();
|
|
||||||
if (empty($appInfo)) {
|
|
||||||
$appInfo = (Db::name('AppUpdate')->where('type', $type)->where('version', '>', $version)->find()) ?? (object)[];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user