企业内部开发 客户端API 小程序 基础接口 wx.getSystemInfo
wx.getSystemInfo
最后更新:2020/10/10
可联系渠道经理采购或代理智慧硬件接口已支持设备 联系渠道经理
wx.getSystemInfo
最后更新:2020/10/10

wx.getSystemInfo(Object object)

小程序可以在微信和企业微信中调用此接口,但是在企业微信中调用此接口时,会额外返回一个 environment 字段(微信中不返回),如此字段值为 wxwork,则表示当前小程序运行在企业微信环境中。注意:只有运行在企业微信环境中,才能调用wx.qy的接口。

获取系统信息

参数

Object object
属性类型默认值必填说明
successfunction接口调用成功的回调函数
failfunction接口调用失败的回调函数
completefunction接口调用结束的回调函数(调用成功、失败都会执行)
object.success 回调函数

参数

Object res

属性类型说明
brandstring设备品牌
modelstring设备型号
pixelRationumber设备像素比
screenWidthnumber屏幕宽度,单位px
screenHeightnumber屏幕高度,单位px
windowWidthnumber可使用窗口宽度,单位px
windowHeightnumber可使用窗口高度,单位px
statusBarHeightnumber状态栏的高度,单位px
languagestring微信设置的语言
versionstring微信版本号
systemstring操作系统及版本
platformstring客户端平台
fontSizeSettingnumber用户字体大小(单位px)。以微信客户端「我-设置-通用-字体大小」中的设置为准
SDKVersionstring客户端基础库版本
benchmarkLevelnumber设备性能等级(仅Android小游戏)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好,目前最高不到50)
environmentstring小程序当前运行环境

 

示例代码

wx.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)
    console.log(res.environment)
  }
})
try {
  const res = wx.getSystemInfoSync()
  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)
  console.log(res.environment)
} catch (e) {
  // Do something when catch error
}
上一篇
wx.qy.checkSession
下一篇
wx.getSystemInfoSync