let _this = this
// 获取当前wifi
uni.getConnectedWifi({
success: function(res) {
console.log(res);
_this.wifiData = res.wifi
_this.setData.BSSID = res.wifi.BSSID
_this.setData.SSID = res.wifi.SSID
},
fail: function(err) {
console.log(err);
uni.showToast({
title: '获取失败!',
icon: "error"
})
}
})
link() {
uni.showLoading()
let that = this
uni.getSystemInfo({
success: (res) => {
let system = ''
// console.log("当前手机型号===>",res)
if (res.platform == 'android') {
system = parseInt(res.platform.substr(8))
}
if (res.platform == 'ios') {
system = parseInt(res.platform.substr(4))
}
if (res.platform == 'android' && system < 6) {
uni.showToast({
title: '手机版本不支持',
icon: 'none'
})
return
}
if (res.platform == 'ios' && system < 11.2) {
uni.showToast({
title: '手机版本不支持',
icon: 'none'
})
return
}
//初始wifi模块
that.start_wifi()
}
})
},
start_wifi() {
let that = this
uni.startWifi({
success: (res) => {
console.log("startWifi==>", res)
that.connected()
},
fail: (error) => {
console.log(error)
uni.showToast({
title: '链接失败',
icon: 'error'
})
}
})
},
connected() {
let that = this
uni.connectWifi({
SSID: this.shareData.SSID,
password: this.shareData.password,
success: (res) => {
uni.showToast({
title: "链接成功"
})
that.color = '#78c345'
},
fail: (error) => {
uni.showToast({
title: '链接失败',
icon: 'error'
})
}
})
},