# mt.getSystemInfo(Object object)
异步获取系统信息。
# 支持情况
| 项 | 说明 |
|---|---|
| 兼容性 | 部分兼容 |
# 参数
Object object
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| success | function | — | 否 | 成功回调 |
| fail | function | — | 否 | 失败回调 |
| complete | function | — | 否 | 完成回调(成功或失败均触发) |
success 回调参数
| 属性 | 类型 | 说明 |
|---|---|---|
| brand | string | 设备品牌 |
| model | string | 设备型号 |
| pixelRatio | number | 设备像素比 |
| screenWidth | number | 屏幕宽度,单位 dp |
| screenHeight | number | 屏幕高度,单位 dp |
| windowWidth | number | 可使用窗口宽度,单位 dp |
| windowHeight | number | 可使用窗口高度,单位 dp |
| statusBarHeight | number | 状态栏高度,单位 dp |
| language | string | 系统语言 |
| version | string | 客户端版本号 |
| system | string | 操作系统及版本 |
| platform | string | 客户端平台(android / ios) |
| fontSizeSetting | number | 用户字体大小设置 |
| SDKVersion | string | 基础库版本 |
| benchmarkLevel | number | 设备性能等级:-2/0 设备无法运行小游戏,-1 性能未知,≥1 性能评分(越高越好,目前最高不到 50) |
| safeArea | Object | 在竖屏正方向下的安全区域,含 left / right / top / bottom / width / height(单位 dp) |
| deviceOrientation | string | 游戏画面方向(portrait / landscape) |
| cameraAuthorized | boolean | 允许使用摄像头的开关 |
| locationAuthorized | boolean | 允许使用定位的开关 |
| microphoneAuthorized | boolean | 允许使用麦克风的开关 |
| notificationAuthorized | boolean | 允许通知的开关 |
| bluetoothEnabled | boolean | 蓝牙的系统开关 |
| locationEnabled | boolean | 地理位置的系统开关 |
| wifiEnabled | boolean | Wi-Fi 的系统开关 |
| albumAuthorized | boolean | 使用相册(读取和存储)的权限开关 |
| readContactAuthorized | boolean | 查看手机联系人的权限开关(美团小游戏特有) |
| gameVersion | string | 游戏包版本号(美团小游戏特有) |
| networkType | string | 当前网络类型(美团小游戏特有) |
| deviceId | string | 设备 ID(美团小游戏特有) |
| is64Bit | boolean | 设备是否支持 64 位架构(美团小游戏特有) |
| appType | string | 宿主 App 类型标识(美团小游戏特有,如 meituan、meituanturbo) |
| errMsg | string | 调用结果(getSystemInfo:ok) |
# 返回值
无返回值。
# 示例代码
mt.getSystemInfo({
success(res) {
console.log(res.model)
console.log(res.pixelRatio)
console.log(res.windowWidth)
console.log(res.windowHeight)
console.log(res.language)
console.log(res.version)
console.log(res.platform)
},
fail(err) {
console.error(err.errMsg)
}
})
# 与微信差异
美团小游戏新增字段(微信无):
readContactAuthorized:查看手机联系人权限开关gameVersion:游戏包版本号networkType:当前网络类型deviceId:设备 IDis64Bit:是否支持 64 位架构appType/app:宿主 App 类型标识
单位差异:
screenWidth/screenHeight/windowWidth/windowHeight/statusBarHeight/safeArea子字段:美团小游戏返回 dp(设备独立像素),微信文档标注为 px(物理像素)。在高密度屏幕(如 3× Retina)上两者数值差距明显,使用时需注意转换。
微信有、美团小游戏无的字段:
host:来源信息(场景值对应的来源 App / 小程序等)theme:系统当前主题(light/dark)phoneCalendarAuthorized/locationReducedAccuracy/enableDebug/notificationAlertAuthorized/notificationBadgeAuthorized/notificationSoundAuthorized等权限/调试字段