浏览代码

检测提示wifi是否打开

htc 3 周之前
父节点
当前提交
1c17a52525
共有 1 个文件被更改,包括 12 次插入0 次删除
  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);
 					}
 				});