Explorar o código

fix:修改小程序空密码的输入问题

zeng.chen hai 5 meses
pai
achega
b194b82c29

+ 18 - 4
pages/deviceConnect1/deviceConnect1.js

@@ -43,9 +43,21 @@ Page({
       is5GWifi: str
     });
   },
-
+  onFocus(event) {
+    console.log("onFocus:", event)
+    if (event.detail.value !== this.data.pwdData) {
+      this.setPwd(event);
+    }
+  },
+  onBlur(event) {
+    console.log("onBlur", event)
+    if (event.detail.value !== this.data.pwdData) {
+      this.setPwd(event);
+    }
+  },
   ///Wifi名称
   setPwd: function (e) {
+    console.log("设置密码:", e.detail.value)
     var that = this;
     app.globalData.pwdData = e.detail.value;
     that.setData({
@@ -81,11 +93,13 @@ Page({
                   app.globalData.ssid = ssid;
                   wx.getStorage({
                     key: 'wifiInfo',
-                    success(wifiInfo) {
-                      const resData = JSON.parse(wifiInfo.data);
+                    success(wifiRes) {
+                      console.log("wifiInfo:", wifiRes)
+                      const resData = JSON.parse(wifiRes.data ?? "{}")?? {};
+                      console.log("wifiInfo2:", resData)
                       if (resData.ssid === res.wifi.SSID) {
                         that.setData({
-                          pwdData: resData.password,
+                          pwdData: resData.password ?? "",
                         });
                       }
                     }

+ 5 - 8
pages/deviceConnect1/deviceConnect1.wxml

@@ -1,8 +1,7 @@
-<!--pages/deviceRoter1/deviceRoter1.wxml-->
-<!--pages/deviceRoter0/deviceRoter0.wxml-->
+<!-- pages/deviceRoter1/deviceRoter1.wxml -->
+<!-- pages/deviceRoter0/deviceRoter0.wxml -->
 <view class="deviceRoter deviceRoter1">
-  <nav-bar bind:goBack="_goBack" nav-bgc-class="ex-nav-bgc-class" nav-title-class="ex-nav-title-class" ex-back-pre="ex-back-pre" navbar-data='{{nvabarData}}'>
-  </nav-bar>
+  <nav-bar bind:goBack="_goBack" nav-bgc-class="ex-nav-bgc-class" nav-title-class="ex-nav-title-class" ex-back-pre="ex-back-pre" navbar-data='{{nvabarData}}'></nav-bar>
   <view class="roterps">
     <view class="devicePic">
       <image mode="widthFix" src="./../../img/e.png"></image>
@@ -13,7 +12,7 @@
       <input placeholder="请输入WIFI名称" bindinput="setSsid" type="text" value="{{ssid}}" maxlength="30" />
     </view>
     <view class="ssid pwd" maxlength="30">
-      <input wx:if="{{!isShowPwd}}" class="notShow" bindinput="setPwd" password="true" placeholder="请输入WiFi密码" value="{{pwdData}}" />
+      <input wx:if="{{!isShowPwd}}" class="notShow" bindinput="setPwd" bindfocus="onFocus" bindblur="onBlur" password="true" placeholder="请输入WiFi密码" value="{{pwdData}}" />
       <input wx:else class="isShow" bindinput="setPwd" placeholder="请输入WiFi密码" value="{{pwdData}}" />
       <view class="yz" bindtap="showPwd">
         <image mode="widthFix" src="./../../img/yj{{isShowPwd ? '1' : '0'}}.png"></image>
@@ -25,8 +24,6 @@
     </view>
   </view>
   <view class="subBtn">
-    <view class="btn" bindtap="next">
-      下一步
-    </view>
+    <view class="btn" bindtap="next">下一步</view>
   </view>
 </view>

+ 7 - 7
pages/deviceConnect3/deviceConnect3.js

@@ -172,13 +172,13 @@ Page({
       return
     }
 
-    if (!app.globalData.pwdData) {
-      wx.showToast({
-        title: '密码不能为空',
-        icon: 'none'
-      })
-      return;
-    }
+    // if (!app.globalData.pwdData) {
+    //   wx.showToast({
+    //     title: '密码不能为空',
+    //     icon: 'none'
+    //   })
+    //   return;
+    // }
 
     xBlufi.notifySendRouterSsidAndPassword({
       ssid: app.globalData.ssid,