// pages/sysinfo/sysinfo.js
var app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
sysinfotest:""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that=this;
wx.getSystemInfo({
success: function(res) {
that.setData({
sysinfotest:JSON.stringify(res)
})
console.log("res:"+that.data.sysinfotest)
//获取res.platform进行判断即可
console.log("手机平台:"+res.platform)
}
})
},
获取的数据如下
红米k20pro
res:{
"locationEnabled": true,
"screenWidth": 393,
"benchmarkLevel": 9,
"screenHeight": 851,
"windowHeight": 769,
"bluetoothEnabled": true,
"errMsg": "getSystemInfo:ok",
"language": "zh_CN",
"microphoneAuthorized": true,
"version": "7.0.12",
"cameraAuthorized": true,
"system": "Android 10",
"fontSizeSetting": 16,
"locationAuthorized": true,
"pixelRatio": 2.75,
"notificationAuthorized": true,
"model": "Redmi K20 Pro",
"statusBarHeight": 35,
"deviceOrientation": "portrait",
"wifiEnabled": false,
"safeArea": {
"width": 393,
"right": 393,
"top": 0,
"left": 0,
"bottom": 851,
"height": 851
},
"brand": "Xiaomi",
"windowWidth": 393,
"screenTop": 83,
"platform": "android",
"SDKVersion": "2.10.3",
"devicePixelRatio": 2.75
}
手机平台:android
iphone7:
res:{
"language": "zh_CN",
"wifiEnabled": true,
"safeArea": {
"bottom": 667,
"height": 647,
"top": 20,
"width": 375,
"left": 0,
"right": 375
},
"bluetoothEnabled": true,
"locationAuthorized": true,
"deviceOrientation": "portrait",
"notificationSoundAuthorized": true,
"screenHeight": 667,
"windowHeight": 603,
"version": "7.0.10",
"fontSizeSetting": 17,
"system": "iOS 13.3.1",
"notificationAuthorized": true,
"statusBarHeight": 20,
"pixelRatio": 2,
"windowWidth": 375,
"notificationBadgeAuthorized": true,
"errMsg": "getSystemInfo:ok",
"locationEnabled": true,
"model": "iPhone 7",
"batteryLevel": 95,
"screenWidth": 375,
"screenTop": 0,
"microphoneAuthorized": true,
"cameraAuthorized": true,
"albumAuthorized": true,
"notificationAlertAuthorized": true,
"brand": "iPhone",
"platform": "ios",
"SDKVersion": "2.10.3",
"devicePixelRatio": 2
}
手机平台:ios