|
@@ -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('💤 请稍后再试');
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
});
|