Sfoglia il codice sorgente

feat: 兼容部分机型

Damon 8 mesi fa
parent
commit
eb26ddb016
2 ha cambiato i file con 61 aggiunte e 65 eliminazioni
  1. 1 5
      index.html
  2. 60 60
      resource/js/app.js

+ 1 - 5
index.html

@@ -57,12 +57,8 @@
         </div>
 
     </div>
-    <!--[if (gte IE 9)|!(IE)]><!-->
-    <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.4.1.min.js"></script>
     <script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
-    <script src="resource/js/amazeui.min.js"></script>
-    <script src="resource/js/app.js"></script>
-    <script src="resource/js/layer.js"></script>
+    <script src="/resource/js/app.js"></script>
 </body>
 
 </html>

+ 60 - 60
resource/js/app.js

@@ -1,68 +1,68 @@
-$(document).ready(function () {
-  $('#toggleEye').click(function () {
-    var pwdInput = $('#WiFiPwd');
-    var pwdType = pwdInput.attr('type');
+document.addEventListener('DOMContentLoaded', function () {
+    document.getElementById('toggleEye').addEventListener('click', function () {
+        var pwdInput = document.getElementById('WiFiPwd');
+        var pwdType = pwdInput.type;
 
-    if (pwdType === 'password' && $(this).hasClass('am-icon-eye-slash')) {
-      pwdInput.attr('type', 'text');
-      $(this).removeClass('am-icon-eye-slash').addClass('am-icon-eye');
-    } else {
-      pwdInput.attr('type', 'password');
-      $(this).removeClass('am-icon-eye').addClass('am-icon-eye-slash');
-    }
-  });
+        if (pwdType === 'password' && this.classList.contains('am-icon-eye-slash')) {
+            pwdInput.type = 'text';
+            this.classList.remove('am-icon-eye-slash');
+            this.classList.add('am-icon-eye');
+        } else {
+            pwdInput.type = 'password';
+            this.classList.remove('am-icon-eye');
+            this.classList.add('am-icon-eye-slash');
+        }
+    });
 
-  $('#confirm').click(function (event) {
-    event.preventDefault()
-    $(this).prop("disabled", true);
-    setTimeout(function () {
-      $("#confirm").prop("disabled", false);
-    }, 1000);
+    document.getElementById('confirm').addEventListener('click', function () {
+        this.disabled = true;
+        setTimeout(() => {
+            this.disabled = false;
+        }, 1000);
 
-    var wifiName = $('#WiFiName').val();
-    if (wifiName.trim().length === 0) {
-      layer.msg('必须输入Wi-Fi账号✅');
-      return
-    }
+        var wifiName = document.getElementById('WiFiName').value.trim();
+        if (wifiName.length === 0) {
+            alert('必须输入Wi-Fi账号✅');
+            return;
+        }
 
-    var wifiPwd = $('#WiFiPwd').val();
-    if (wifiPwd.trim().length < 8) {
-      layer.msg('必须输入正确的Wi-Fi密码✅');
-      return
-    }
+        var wifiPwd = document.getElementById('WiFiPwd').value.trim();
+        if (wifiPwd.length < 8) {
+            alert('必须输入正确的Wi-Fi密码✅');
+            return;
+        }
 
-    var uuId = $('#UUId').val();
-    if (uuId.trim().length === 0) {
-      layer.msg('必须传UUId✅');
-      return
-    }
+        var uuId = document.getElementById('UUId').value.trim();
+        if (uuId.length === 0) {
+            alert('必须传UUId✅');
+            return;
+        }
 
-    $.ajax({
-      url: 'http://ptt.radio1964.com/v1/device/set-wifi', // 替换为后台接口的实际URL
-      method: 'POST', // 替换为后台接口的实际请求方法
-      data: {
-        wifiName: wifiName,
-        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();
-          }
-          window.location.reload();
-        });
-      },
-      error: function (error) {
-        layer.msg('💤 请稍后再试');
-      }
+        fetch('http://ptt.radio1964.com/v1/device/set-wifi', { // 替换为后台接口的实际URL
+            method: 'POST',
+            headers: {
+                'Content-Type': 'application/json',
+            },
+            body: JSON.stringify({
+                wifiName: wifiName,
+                wifiPwd: wifiPwd,
+                UUId: uuId,
+            })
+        }).then(response => response.json())
+            .then(data => {
+                alert('✅ 设置成功')
+                var ua = navigator.userAgent.toLowerCase();
+                if (ua.match(/micromessenger/i)) {
+                    WeixinJSBridge.call('closeWindow');
+                } else if (ua.indexOf("alipay") !== -1) {
+                    AlipayJSBridge.call('closeWebview');
+                } else if (ua.indexOf("baidu") !== -1) {
+                    BLightApp.closeWindow();
+                }
+                window.location.reload();
+            })
+            .catch(error => {
+                alert('💤 请稍后再试');
+            });
     });
-  });
 });