Files

56 lines
1.3 KiB
PHP

<?php
namespace app\common\library;
use think\Config;
class Platform
{
/**
* 获取请求来源平台
* @return mixed
*/
public static function getPlatform(){
$platform = trim((string)\think\Request::instance()->header('platform'));
$platformMap = [
'h5' => 'H5',
'pc' => 'Pc',
'app' => 'App',
'wxminiprogram' => 'wxMiniProgram',
'wxofficialaccount' => 'wxOfficialAccount',
'dyminiprogram' => 'dyMiniProgram',
'channels' => 'channels',
];
$key = strtolower($platform);
return isset($platformMap[$key]) ? $platformMap[$key] : $platform;
}
/**
* 获取设备终端
* @return string
*/
public static function getDeviceEnd(){
if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
return 'ios';
}else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android')){
return 'android';
}else{
return 'other';
}
}
/**
* 获取系统类型 独立版 or 微擎版
* @return void
*/
public static function getSystemType(){
if(defined('TUZHI_SYSTEM_TYPE') && TUZHI_SYSTEM_TYPE == 'single'){
return 'single';
}
return 'w7';
}
}