WeChat Mini Program API System Information


Get network status——wx.getNetworkType(OBJECT)

WeChat applet gets network type

OBJECT parameter description:

QQ截图20170208113937.png

wx.getNetworkType({
    success: function (res) {
        var networkType = res.networkType; // 返回网络类型2g,3g,4g,wifi
    }
});

Get system information——wx.getSystemInfo(OBJECT)

WeChat applet gets system information

success callback parameter description :

QQ截图20170208113954.png

##Sample code:

wx.getSystemInfo({
  success:function(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)
  }
})

Listen to the gravity sensor——wx.onAccelerometerChange( CALLBACK)

WeChat applet monitors gravity sensing data, frequency: 50 times/second

CALLBACK return parameters:

QQ截图20170208114006.png

Sample code:

wx.onAccelerometerChange(function (res) {
  console.log(res.x)
  console.log(res.y)
  console.log(res.z)
})

Monitoring compass data——wx.onCompassChange(CALLBACK)

WeChat applet monitors compass data, frequency : 50 times/second

CALLBACK Return parameters:

QQ截图20170208114016.png

Sample code:

wx.onCompassChange(function (res) {
  console.log(res.direction)
})