注冊

微信小程序API設備概覽,微信小程序綁定設備

2017-12-22
導讀:微信小程序API設備概覽 系統信息——(wx.getSystemInfo、wx.getSystemInfoSync) 網絡狀態(tài)——(wx.getNetworkType) 重力感應——(wx.onAccelerometerChange) 羅 盤——(wx.onCompassChange) 撥打電話——...

微信小程序API設備概覽


 

  • 系統信息——(wx.getSystemInfo、wx.getSystemInfoSync)
  • 網絡狀態(tài)——(wx.getNetworkType)
  • 重力感應——(wx.onAccelerometerChange)
  • 盤——(wx.onCompassChange)
  • 撥打電話——(wx.makePhoneCall)
  • 碼——(wx.scanCode)

 

wx.getSystemInfo(OBJECT)


獲取系統信息。

OBJECT參數說明:

參數 類型 必填 說明
success Function 接口調用成功的回調
fail Function 接口調用失敗的回調函數
complete Function 接口調用結束的回調函數(調用成功、失敗都會執(zhí)行)

success回調參數說明:

屬性 說明
model 手機型號
pixelRatio 設備像素比
windowWidth 窗口寬度
windowHeight 窗口高度
language 微信設置的語言
version 微信版本號
system 操作系統版本
platform 客戶端平臺

示例代碼:

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)
    console.log(res.platform)
  }
})

wx.getSystemInfoSync()


獲取系統信息同步接口

示例代碼:

try {
  var 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)
} catch (e) {
  // Do something when catch error
}
更多微信小程序開發(fā)教程,可以關注hi小程序。
重磅推薦:小程序開店目錄

第一部分:小商店是什么

第二部分:如何開通一個小商店

第三部分:如何登錄小商店

第四部分:開店任務常見問題

第五部分:小商店可以賣什么

第六部分:HiShop小程序特色功能

第七部分:小程序直播

第八部分:小程序收貨/物流

第九部分:小程序怎么結算

第十部分:小程序客服

第十一部分:電商創(chuàng)業(yè)

第十二部分:小程序游戲開發(fā)