wx.getNetworkType(OBJECT)
获取网络类型
OBJECT参数说明:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| success | Function | 是 | 返回网络类型networkType |
| fail | Function | 否 | 接口调用失败的回调函数 |
| complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
wx.getNetworkType({
success: function (res) {
var networkType = res.networkType; // 返回网络类型2g,3g,4g,wifi
}
});
wx.getSystemInfo(OBJECT)
获取系统信息
success回调参数说明:
| 属性 | 说明 |
|---|---|
| model | 手机型号 |
| pixelRatio | 设备像素比 |
| windowWidth | 窗口宽度 |
| windowHeight | 窗口高度 |
| language | 微信设置的语言 |
| version | 微信版本号 |
示例代码:
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)
}
})
wx.onAccelerometerChange(CALLBACK)
监听重力感应数据,频率:50次/秒
CALLBACK返回参数:
| 参数 | 类型 | 说明 |
|---|---|---|
| x | Number | X 轴 |
| y | Number | Y 轴 |
| z | Number | Z 轴 |
示例代码:
wx.onAccelerometerChange(function (res) {
console.log(res.x)
console.log(res.y)
console.log(res.z)
})
wx.onCompassChange(CALLBACK)
监听罗盘数据,频率:50次/秒
CALLBACK返回参数:
| 参数 | 类型 | 说明 |
|---|---|---|
| direction | Number | 面对的方向度数 |
示例代码:
wx.onCompassChange(function (res) {
console.log(res.direction)
})
