Browse Source

配网增加错误提示

htc 4 days ago
parent
commit
5ad39e7e3e
1 changed files with 17 additions and 3 deletions
  1. 17 3
      pagesMy/wifiSet.vue

+ 17 - 3
pagesMy/wifiSet.vue

@@ -31,7 +31,7 @@
 			<div class="fail_box adffcacjc">
 				<image src="http://106.54.209.120:8188/static/connect_off.png"></image>
 				<text>网络连接失败</text>
-				<p>请检查你的网络设置后刷新</p>
+				<p>请检查你的网络设置或密码后刷新</p>
 				<div class="zt_btn" @tap="toTryAgain">重试</div>
 			</div>
 		</u-popup>
@@ -62,6 +62,7 @@
 				wx.request({
 					url:'http://192.168.4.1/scan',
 					success:res=>{
+						console.log(res,'res');
 						uni.hideLoading();
 						if(res.errMsg==='request:ok'){
 							let temp = [];
@@ -84,6 +85,7 @@
 				})
 			},
 			toConnectWiFi(){
+				if(!this.wifiSSID) return this.$showToast('请从下方选择一个wifi进行连接')
 				if(!this.wifiPwd) return this.$showToast('请输入密码')
 				if(!this.flag) return
 				this.flag  = false;
@@ -99,15 +101,21 @@
 						password:this.wifiPwd
 					},
 					success:res2=>{
-						if(res2.errMsg!=='request:ok'){
+						console.log(res2,'res2');
+						if(res2.errMsg!=='request:ok'||!res2.data.success){
+							uni.hideLoading();
 							that.show = true;
+							that.flag = true;
 							return
 						}
 						wx.request({
 							url:'http://192.168.4.1/reboot',
 							method:'POST',
 							success:res3=>{
-								if(res3.errMsg!=='request:ok') return that.$showToast('设备重启失败')
+								if(res3.errMsg!=='request:ok'){
+									that.$showToast('设备重启失败')
+									return
+								} 
 								that.flag = true;
 								uni.hideLoading();
 								setTimeout(()=>{
@@ -117,13 +125,17 @@
 								},2000)
 							},
 							fail:err3=>{
+								console.log(err3,'err3');
 								that.flag = true;
+								that.$showModal(JSON.stringify(err3));
 								uni.hideLoading();
 							}
 						})
 					},
 					fail:err2=>{
+						console.log(err2,'err2');
 						that.flag = true;
+						that.$showModal(JSON.stringify(err2));
 						uni.hideLoading();
 					}
 				})
@@ -136,6 +148,7 @@
 			},
 			toTryAgain(){
 				this.show = false;
+				this.flag = true;
 				this.toConnectWiFi();
 			}
 		}
@@ -242,6 +255,7 @@
 				color: #A6A6A6;
 				line-height: 24rpx;
 				margin-top: 24rpx;
+				text-align: center;
 			}
 			.zt_btn{
 				margin-top: 40rpx;