微信小程序开发(十一)获取手机的完整详细信息

时间:2021-06-02 11:58:39   收藏:0   阅读:0
// 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
        })
      }
    })
  }
})

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!