Browse Source

feat: 加入按钮锁定类型button

Damon 8 tháng trước cách đây
mục cha
commit
ef20ed264c
2 tập tin đã thay đổi với 26 bổ sung20 xóa
  1. 1 1
      index.html
  2. 25 19
      resource/js/app.js

+ 1 - 1
index.html

@@ -50,7 +50,7 @@
                 </div></br>
 
                 <!-- am-btn  am_btn_more-->
-                <button id="confirm" class="myapp-login-form-submit am-btn am-btn-primary am-btn-block ">确
+                <button id="confirm" class="myapp-login-form-submit am-btn am-btn-primary am-btn-block " type="button">确
                     定</button>
 
             </form>

+ 25 - 19
resource/js/app.js

@@ -1,5 +1,5 @@
-$(document).ready(function() {
-  $('#toggleEye').click(function() {
+$(document).ready(function () {
+  $('#toggleEye').click(function () {
     var pwdInput = $('#WiFiPwd');
     var pwdType = pwdInput.attr('type');
 
@@ -11,27 +11,32 @@ $(document).ready(function() {
       $(this).removeClass('am-icon-eye').addClass('am-icon-eye-slash');
     }
   });
-  $('#confirm').click(function(event) {
+
+  $('#confirm').click(function (event) {
     event.preventDefault()
     $(this).prop("disabled", true);
-    setTimeout(function() {
+    setTimeout(function () {
       $("#confirm").prop("disabled", false);
     }, 1000);
+
     var wifiName = $('#WiFiName').val();
-    if (wifiName.trim().length === 0){
+    if (wifiName.trim().length === 0) {
       layer.msg('必须输入Wi-Fi账号✅');
       return
     }
+
     var wifiPwd = $('#WiFiPwd').val();
-    if (wifiPwd.trim().length < 8){
+    if (wifiPwd.trim().length < 8) {
       layer.msg('必须输入正确的Wi-Fi密码✅');
       return
     }
+
     var uuId = $('#UUId').val();
-    if (uuId.trim().length === 0){
+    if (uuId.trim().length === 0) {
       layer.msg('必须传UUId✅');
       return
     }
+
     $.ajax({
       url: 'http://ptt.radio1964.com/v1/device/set-wifi', // 替换为后台接口的实际URL
       method: 'POST', // 替换为后台接口的实际请求方法
@@ -40,21 +45,22 @@ $(document).ready(function() {
         wifiPwd: wifiPwd,
         UUId: uuId,
       },
-      success: function(response) {
-        layer.msg( '✅ 设置成功'
-        ,{icon:1},function(){
-              var ua = navigator.userAgent.toLowerCase();
-              if(ua.match(/MicroMessenger/i)=="micromessenger") {
-                WeixinJSBridge.call('closeWindow');
-              } else if(ua.indexOf("alipay")!=-1){
-                AlipayJSBridge.call('closeWebview');
-              }else if(ua.indexOf("baidu")!=-1){
-                BLightApp.closeWindow();
-              }
+      success: function (response) {
+        layer.msg('✅ 设置成功', {
+          icon: 1
+        }, function () {
+          var ua = navigator.userAgent.toLowerCase();
+          if (ua.match(/MicroMessenger/i) == "micromessenger") {
+            WeixinJSBridge.call('closeWindow');
+          } else if (ua.indexOf("alipay") != -1) {
+            AlipayJSBridge.call('closeWebview');
+          } else if (ua.indexOf("baidu") != -1) {
+            BLightApp.closeWindow();
+          }
           window.location.reload();
         });
       },
-      error: function(error) {
+      error: function (error) {
         layer.msg('💤 请稍后再试');
       }
     });