my.getsysteminfo(object object)
支小宝客户端 支持
安诊儿客户端 支持
主体: 企业支付宝小程序 、 个人支付宝小程序
获取手机系统信息
如果只需获取 clientname、clientversion、language、platform 字段,推荐使用更加轻量化的 my.env。
object object
查看示例
属性 | 类型 | 默认值 | 必填 | 描述 |
---|---|---|---|---|
success | function | - | 否 | 调用成功的回调函数 |
fail | function | - | 否 | 调用失败的回调函数 |
complete | function | - | 否 | 调用结束的回调函数(调用成功、失败都会执行) |
success 回调函数
参数
object res
查看示例
属性 | 类型 | 兼容性 | 描述 | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pixelratio | number | - | 设备像素比 |
|||||||||||||||||||||||||
safearea | object | 基础库: 2.7.14 ios 支付宝: 10.2.20 |
在竖屏正方向下的安全区域。安卓端暂不支持 |
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
screenheight | number | - | 屏幕高度。单位:px。此属性在 android 上取值有误,建议使用 screen.height 替代 |
|||||||||||||||||||||||||
screenwidth | number | - | 屏幕宽度。单位:px。此属性在 android 上取值有误,建议使用 screen.width 替代 |
|||||||||||||||||||||||||
screen | object | 支付宝: 10.2.10 |
屏幕宽度和高度 |
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
statusbarheight | number | - | 状态栏高度。单位:px |
|||||||||||||||||||||||||
titlebarheight | number | - | 标题栏高度。单位:px |
|||||||||||||||||||||||||
windowwidth | number | - | 可使用窗口宽度。单位:px |
|||||||||||||||||||||||||
windowheight | number | - | 可使用窗口高度。 单位:px |
|||||||||||||||||||||||||
locationenabled | boolean | 支付宝: 10.2.0 |
地理位置的系统开关 |
|||||||||||||||||||||||||
wifienabled | boolean | 支付宝: 10.2.0 |
wi-fi 的系统开关 |
|||||||||||||||||||||||||
performance | string | android 支付宝: 10.1.62 |
设备性能等级(仅 android 有效) |
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
brand | string | 基础库: 1.0/2.3.1 |
手机品牌 |
|||||||||||||||||||||||||
model | string | - | 手机型号。具体可参考 手机型号与 my.getsysteminfo 返回的 model 值对照表 |
|||||||||||||||||||||||||
system | string | - | 系统版本 |
|||||||||||||||||||||||||
platform | string | - | 客户端平台:android,ios / iphone os,harmony |
|||||||||||||||||||||||||
language | string | - | 支付宝设置的语言 |
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
version | string | - | 支付宝客户端版本号 |
|||||||||||||||||||||||||
albumauthorized | boolean | ios 支付宝: 10.2.0 |
允许支付宝使用相册的开关 (仅 ios 有效) |
|||||||||||||||||||||||||
cameraauthorized | boolean | 支付宝: 10.2.0 |
允许支付宝使用摄像头的开关 |
|||||||||||||||||||||||||
locationauthorized | boolean | 支付宝: 10.2.0 |
允许支付宝使用定位的开关 |
|||||||||||||||||||||||||
microphoneauthorized | boolean | 支付宝: 10.2.0 |
允许支付宝使用麦克风的开关 |
|||||||||||||||||||||||||
notificationauthorized | boolean | 支付宝: 10.2.0 |
允许支付宝通知的开关。暂时仅支持安卓 |
|||||||||||||||||||||||||
app | string | - | 当前运行的客户端 |
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
fontsizesetting | number | 基础库: 1.0/2.3.1 |
用户设置字体大小。单位:px |
|||||||||||||||||||||||||
isiphonexseries | boolean | 基础库: 2.6.0 |
是否 iphonex 系列 |
|||||||||||||||||||||||||
transparenttitle | boolean | - | 透明状态栏 |
|||||||||||||||||||||||||
overlayauthorized | boolean | - | 允许支付宝使用悬浮窗的开关(仅 android 有效) |
|||||||||||||||||||||||||
storage | string | 基础库: 1.0/2.3.1 |
设备磁盘容量 |
|||||||||||||||||||||||||
currentbattery | string | 基础库: 1.0/2.3.1 |
当前电量百分比 |
my.getsysteminfo({
success: (res) => {
console.log(res);
},
fail: (err) => {
console.log(err);
}
})
{
"apilevel": 31,
"app": "alipay",
"appmode": "normal",
"bluetoothenabled": false,
"bluetoothauthorized": true,
"brand": "redmi",
"cameraauthorized": true,
"currentbattery": "46%",
"fontsizesetting": 16,
"isiphonexseries": false,
"language": "zh-hans",
"locationauthorized": true,
"locationenabled": true,
"microphoneauthorized": false,
"model": "xiaomi m2012k11ac",
"notificationauthorized": true,
"overlayauthorized": false,
"performance": "high",
"pixelratio": 2.75,
"platform": "android",
"screen": {
"height": 828,
"width": 393
},
"screenheight": 2276,
"screenwidth": 1080,
"statusbarheight": 30,
"storage": "242 gb",
"system": "12",
"titlebarheight": 48,
"transparenttitle": false,
"version": "10.3.50.8100",
"wifienabled": false,
"windowheight": 725,
"windowwidth": 393
}
-
bugmy.getsysteminfo 中 screenwidth 和 screenheight 在安卓端取值不对,android 少除了 pixelratio,推荐使用 screen.width 和 screen.height 代替。
q:my.getsysteminfo 中 windowheight 和 screenheight 有什么区别?
screenheight 是整个手机屏幕的高度,windowheight 是 webview(不包括手机状态栏、小程序标题栏和 tabbar)的高度。