Explorar o código

检测提示wifi是否打开

htc hai 3 semanas
pai
achega
1c17a52525
Modificáronse 1 ficheiros con 12 adicións e 0 borrados
  1. 12 0
      pagesMy/wifiSet.vue

+ 12 - 0
pagesMy/wifiSet.vue

@@ -288,12 +288,24 @@
 			startSearchWifi() {
 				wx.showLoading({title:'设备初始化获取WiFi中...'})
 				this.wifiList = [];
+				let that = this;
 				uni.startWifi({
 					success: (res) => {
 						console.log('初始化WiFi模块成功', res);
 						this.getWifiList();
 					},
 					fail: (err) => {
+						wx.hideLoading();
+						wx.showModal({
+							title: '温馨提示',
+							content: '初始化WiFi模块失败,请确保已打开手机WiFi。',
+							showCancel: false,
+							success: (res) => {
+								if(res.confirm){
+									that.startSearchWifi(); // 尝试重新初始化
+								}
+							}
+						});
 						console.error('startWifi fail:', err);
 					}
 				});