修复iOS WIFI问题

master
许宏杰 1 year ago
parent 918ae73292
commit e0b972e425

@ -57,6 +57,7 @@
time: null, time: null,
wifiForm: {}, wifiForm: {},
posterForm: {}, posterForm: {},
platform: null,
} }
}, },
onLoad(option) { onLoad(option) {
@ -73,7 +74,7 @@
}) })
} }
// this.getNetinfo(8) // this.getNetinfo(11)
}, },
methods: { methods: {
//id //id
@ -165,6 +166,7 @@
uni.getSystemInfo({ uni.getSystemInfo({
success: function(res) { success: function(res) {
var system = ''; var system = '';
that.platform = res.platform
if (res.platform == 'android') system = parseInt(res.system.substr(8)); if (res.platform == 'android') system = parseInt(res.system.substr(8));
if (res.platform == 'ios') system = parseInt(res.system.substr(4)); if (res.platform == 'ios') system = parseInt(res.system.substr(4));
if (res.platform == 'android' && system < 6 || res.platform == 'ios' && system < if (res.platform == 'android' && system < 6 || res.platform == 'ios' && system <
@ -195,32 +197,62 @@
} }
}) })
}, },
linkWifi() {
addNetHistory({
netId: this.wifiForm.id,
netName: this.wifiForm.netName,
wifiName: this.wifiForm.wifiName,
wifiPass: this.wifiForm.wifiPass,
shanghuId: this.wifiForm.shanghuId
})
uni.showToast({
title: '连接成功',
icon: 'success'
})
this.showBtn = false
},
Connected() { Connected() {
var that = this var that = this
uni.connectWifi({ uni.connectWifi({
SSID: this.wifiForm.wifiName, //wifi SSID: this.wifiForm.wifiName, //wifi
BSSID: '',
password: this.wifiForm.wifiPass, //wifi password: this.wifiForm.wifiPass, //wifi
success: function(res) { success: function(res) {
addNetHistory({ if (that.platform == 'ios') {
netId: that.wifiForm.id, uni.getConnectedWifi({
netName: that.wifiForm.netName, partialInfo: true,
wifiName: that.wifiForm.wifiName, success: function(reult) {
wifiPass: that.wifiForm.wifiPass, console.log('成功', reult, that.wifiForm.wifiName)
shanghuId: that.wifiForm.shanghuId if (reult.wifi.SSID == that.wifiForm.wifiName) {
that.linkWifi()
} else {
uni.showToast({
title: '连接失败!',
icon: "error"
}) })
}
},
fail: function(error) {
uni.showToast({ uni.showToast({
title: '连接成功', title: '连接失败!',
icon: 'success' icon: "error"
}) })
that.showBtn = false console.log('失败', error)
}
})
} else {
that.linkWifi()
}
}, },
fail: function(res) { fail: function(err) {
uni.showToast({ uni.showToast({
title: '连接失败', title: '连接失败',
icon: 'error' icon: 'error'
}) })
} },
}) })
}, },
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -222,7 +222,8 @@ var _default = {
//视频播放时间 //视频播放时间
time: null, time: null,
wifiForm: {}, wifiForm: {},
posterForm: {} posterForm: {},
platform: null
}; };
}, },
onLoad: function onLoad(option) { onLoad: function onLoad(option) {
@ -237,7 +238,7 @@ var _default = {
}); });
} }
// this.getNetinfo(8) // this.getNetinfo(11)
}, },
methods: { methods: {
@ -327,6 +328,7 @@ var _default = {
uni.getSystemInfo({ uni.getSystemInfo({
success: function success(res) { success: function success(res) {
var system = ''; var system = '';
that.platform = res.platform;
if (res.platform == 'android') system = parseInt(res.system.substr(8)); if (res.platform == 'android') system = parseInt(res.system.substr(8));
if (res.platform == 'ios') system = parseInt(res.system.substr(4)); if (res.platform == 'ios') system = parseInt(res.system.substr(4));
if (res.platform == 'android' && system < 6 || res.platform == 'ios' && system < 11.2) { if (res.platform == 'android' && system < 6 || res.platform == 'ios' && system < 11.2) {
@ -356,29 +358,55 @@ var _default = {
} }
}); });
}, },
linkWifi: function linkWifi() {
(0, _index.addNetHistory)({
netId: this.wifiForm.id,
netName: this.wifiForm.netName,
wifiName: this.wifiForm.wifiName,
wifiPass: this.wifiForm.wifiPass,
shanghuId: this.wifiForm.shanghuId
});
uni.showToast({
title: '连接成功',
icon: 'success'
});
this.showBtn = false;
},
Connected: function Connected() { Connected: function Connected() {
var that = this; var that = this;
uni.connectWifi({ uni.connectWifi({
SSID: this.wifiForm.wifiName, SSID: this.wifiForm.wifiName,
//wifi名 //wifi名
BSSID: '',
password: this.wifiForm.wifiPass, password: this.wifiForm.wifiPass,
//wifi密码 //wifi密码
success: function success(res) { success: function success(res) {
(0, _index.addNetHistory)({ if (that.platform == 'ios') {
netId: that.wifiForm.id, uni.getConnectedWifi({
netName: that.wifiForm.netName, partialInfo: true,
wifiName: that.wifiForm.wifiName, success: function success(reult) {
wifiPass: that.wifiForm.wifiPass, console.log('成功', reult, that.wifiForm.wifiName);
shanghuId: that.wifiForm.shanghuId if (reult.wifi.SSID == that.wifiForm.wifiName) {
that.linkWifi();
} else {
uni.showToast({
title: '连接失败!',
icon: "error"
}); });
}
},
fail: function fail(error) {
uni.showToast({ uni.showToast({
title: '连接成功', title: '连接失败!',
icon: 'success' icon: "error"
}); });
that.showBtn = false; console.log('失败', error);
}
});
} else {
that.linkWifi();
}
}, },
fail: function fail(res) { fail: function fail(err) {
uni.showToast({ uni.showToast({
title: '连接失败', title: '连接失败',
icon: 'error' icon: 'error'

@ -1,4 +1,4 @@
{ {
"usingComponents": {}, "component": true,
"component": true "usingComponents": {}
} }
Loading…
Cancel
Save