美文网首页uniapp
uniapp 获取设备系统信息、网络状态、拨打电话

uniapp 获取设备系统信息、网络状态、拨打电话

作者: 暴躁程序员 | 来源:发表于2022-05-06 11:19 被阅读0次
  1. 获取设备系统信息
uni.getSystemInfo({
    success: (res) => {
        this.systemInfo = res
    }
})

// 设备型号: this.systemInfo.model
// 客户端平台: this.systemInfo.platform
// 操作系统版本: this.systemInfo.system
// 语言: this.systemInfo.model
// 版本: this.systemInfo.version
// 屏幕宽度: this.systemInfo.screenWidth
// 屏幕高度: this.systemInfo.screenHeight
// 可使用窗口高度: this.systemInfo.windowHeight
// 可使用窗口的顶部位置: this.systemInfo.windowTop
// 可使用窗口的底部位置: this.systemInfo.windowBottom
// 状态栏的高度: this.systemInfo.statusBarHeight
// DPI: this.systemInfo.pixelRatio
// 基础库版本: this.systemInfo.SDKVersion
  1. 获取设备网络状态
// 获取网络信息
uni.getNetworkType({
    success: (res) => {
        console.log(res)
    },
    fail: () => {
        uni.showModal({
            content:'获取失败!',
            showCancel:false
        })
    }
})
、
// 获取 wifi 信息
uni.startWifi({
    success: function() {
        uni.getConnectedWifi({
            success: function(res) {
                console.log(res)
            },
            fail: function(res) {
            }
        })
    },
    fail: function(res) {
    }
})
  1. 拨打电话
uni.makePhoneCall({
    phoneNumber: this.inputValue, // 输入框中获取的手机号
    success: () => {
        console.log("成功拨打电话")
    }
})

相关文章

网友评论

    本文标题:uniapp 获取设备系统信息、网络状态、拨打电话

    本文链接:https://www.haomeiwen.com/subject/bhgayrtx.html