Browse Source

增加ios提示

htc 2 days ago
parent
commit
a811f400c6
1 changed files with 23 additions and 15 deletions
  1. 23 15
      pagesMy/wifi.vue

+ 23 - 15
pagesMy/wifi.vue

@@ -37,7 +37,9 @@
 			return {
 				openWifi:true,
 				wifiList:[],
-				myWifi:''
+				myWifi:'',
+				platform:'',
+				flag:true
 			}
 		},
 		watch:{
@@ -51,19 +53,26 @@
 		},
 		onLoad() {
 			this.getCurrentWifi();
-			this.dealWifi(true)
-		},
-		onShow() {
 			let sysInfo = wx.getSystemInfoSync();
-			console.log(sysInfo,'sysInfo');
-			let platform = sysInfo.platform;
-			console.log(platform,'platform');
-			if(platform == "ios"){
-				wx.onGetWifiList(res => {
-					console.log(res,'res:onShow');
+			this.platform = sysInfo?.platform;
+			if(this.platform=='ios'){
+				uni.showModal({
+					title:'温馨提示',
+					content:'检测到您的手机为ios系统,即将自动跳转设置-微信,需要您在设置中打开无线局域网,等待获取到WiFi列表后返回小程序选择“Xiaozhi”开头的热点进行连接。',
+					success: (res) => {
+						if(res.confirm){
+							this.dealWifi(true)
+						}
+					}
 				})
+			}else{
+				this.dealWifi(true)
 			}
 		},
+		onShow() {
+			let sysInfo = wx.getSystemInfoSync();
+			this.platform = sysInfo?.platform;
+		},
 		methods:{
 			getCurrentWifi(){
 				let that = this;
@@ -90,14 +99,10 @@
 					})
 					wx.startWifi({
 						success (res) {
-							console.log(res,'res');
 							wx.getWifiList({
 								success(res2) {
-									console.log(res2,'res2');
 									wx.onGetWifiList(res3 => {
 										let temp = [];
-										console.log(res3,'res3');
-										console.log(res3.wifiList,'res3.wifiList');
 										res3.wifiList.forEach(w=>{
 											if(w.SSID){
 												let exit = temp.find(t=>t.SSID===w.SSID);
@@ -127,6 +132,8 @@
 			toSet(item){
 				let that = this;
 				if(item.SSID.indexOf('Xiaozhi-')>-1){
+					if(!this.flag) return
+					this.flag = false;
 					uni.showLoading({
 						title:'热点连接中'
 					})
@@ -134,8 +141,8 @@
 						SSID: item.SSID,
 						password: '',
 						success: (resu) => {
-							console.log(resu,'resu');
 							uni.hideLoading();
+							this.flag = true;
 							// if(resu.errCode===0||resu.errMsg==='connectWifi:ok'){
 								setTimeout(()=>{
 									uni.navigateTo({
@@ -146,6 +153,7 @@
 						},
 						fail: (err) => {
 							uni.hideLoading();
+							this.flag = true;
 							console.log(err,'err:connectWifi');
 						}
 					});