123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- $(document).ready(function () {
- $('#toggleEye').click(function () {
- var pwdInput = $('#WiFiPwd');
- var pwdType = pwdInput.attr('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');
- }
- });
- window.onload = function () {
- // 从URL中获取UUID参数
- const uuidFromUrl = getQueryParam('uuid');
- // 获取 HTML 元素
- var uuidElement = document.getElementById('UUID');
- // 使用 JavaScript 替换占位符
- uuidElement.textContent = "UUID: " + uuidFromUrl;
- // uuidElement.textContent = uuidElement.textContent.replace('{{.uuid}}', uuidFromUrl);
- };
- // 函数:从URL中获取查询参数的值
- function getQueryParam(param) {
- const urlParams = new URLSearchParams(window.location.search);
- return urlParams.get(param);
- }
- // 确定
- $('#confirm').click(function (event) {
- event.preventDefault()
- $(this).prop("disabled", true);
- setTimeout(function () {
- $("#confirm").prop("disabled", false);
- }, 1000);
- var wifiName = $('#WiFiName').val();
- if (wifiName.trim().length === 0) {
- layer.msg('必须输入Wi-Fi账号✅');
- return
- }
- var wifiPwd = $('#WiFiPwd').val();
- if (wifiPwd.trim().length < 8) {
- layer.msg('必须输入正确的Wi-Fi密码✅');
- return
- }
- var uuId = $('#UUId').val();
- if (uuId.trim().length === 0) {
- layer.msg('必须传UUId✅');
- return
- }
- console.log("gadsfadsfafda===00==" + uuId);
- console.log("gadsfadsfafda===11==" + wifiName);
- console.log("gadsfadsfafda===22==" + wifiPwd);
- // 网络请求
- $.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('💤 请稍后再试');
- }
- });
- });
- });
|