微信小程序開發(十一)獲取手機的完整詳細信息


// succ.wxml
<view style='position:absolute; top:30%; left:35%;font-size:36rpx'>{{name}}:簽到成功。{{oaid}}</view>
<view>手機型號:{{mobileModel}}</view>
<view>手機像素比:{{mobileePixelRatio}}</view>
<view>窗口寬度:{{windowWidth}}</view>
<view>窗口高度:{{windowHeight}}</view>
<view>微信設置的語言:{{language}}</view>
<view>微信版本號:{{version}}</view>
<view>手機IP:{{motto.query}}</view>
<view>手機網絡狀態:{{netWorkType}}</view>
<view>WIFI ssid:{{wifissid}}</view>
<view>WIFI bssid:{{wifiBssid}}</view>

// succ.js
var app = getApp()
Page({
  data: {
    mobileModel: '',  // 手機型號
    mobileePixelRatio: '',  // 手機像素比
    windowWidth: '',  // 窗口寬度
    windowHeight: '',  // 窗口高度
    language: '',  // 微信設置的語言
    version: '',  // 微信版本號
    netWorkType: '',  // 手機網絡狀態
    name: '',  // 用戶姓名
    oaid: '',  // oa賬號
    netWorkType: '', // 網絡類型
    wifissid: '',  // WIFI ssid
    wifiBssid: '',  // WIFI bssid
    motto: ''  // IP地址
  },
  onLoad: function (e) {  // 獲取參數
    var that = this;
    this.setData({
      name: e.name,
      oaid: e.oaid
    })
    wx.getNetworkType({  // 獲取網絡類型
      success: function (res) {
        that.setData({
          netWorkType: res.networkType
        })
      }
    })
    wx.getConnectedWifi({
      success: function(e){
        console.log(e,"eeeeeeeee")
        console.log(e.wifi)
        that.setData({
          wifissid: e.wifi.SSID,
          wifiBssid: e.wifi.BSSID
        })
      }
    })
    wx.request({  // 獲取ip
      url: 'http://ip-api.com/json',
      success: function (e) {
        that.setData({
          motto: e.data
        })
      }
    })
    wx.getLocation(
      {
        success: function (res) {
          console.log(res,'res')
          that.setData({
            hasLocation: true,
            location1: res.longitude, 
            location2:res.latitude//這里是獲取經緯度
          })
        }
      })
    wx.getSystemInfo({
      success: function (res) {  // 獲取手機信息
        console.log(res, 'res111111')
        that.setData({
          mobileModel: res.model,
          mobileePixelRatio: res.pixelRatio,
          windowWidth: res.windowWidth,
          windowHeight: res.windowHeight,
          language: res.language,
          version: res.version
        })
      }
    })
  }
})

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM